Skip to content

Commit e248541

Browse files
committed
chore: Update README
1 parent b893142 commit e248541

File tree

1 file changed

+64
-38
lines changed

1 file changed

+64
-38
lines changed

README.md

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Gem Version](https://badge.fury.io/rb/cooklang_rb.svg)](https://badge.fury.io/rb/cooklang_rb)
44
[![Ruby](https://github.com/DRBragg/cooklang_rb/actions/workflows/main.yml/badge.svg)](https://github.com/DRBragg/cooklang_rb/actions/workflows/main.yml)
55

6-
A Ruby parser for [Cooklang](https://cooklang.org/).
6+
A Ruby parser for [Cooklang](https://cooklang.org/) — compatible with the [v7 spec](https://cooklang.org/docs/spec/).
77

88
If you're unfamiliar with [Cooklang](https://cooklang.org/), please visit [https://cooklang.org/](https://cooklang.org/) to learn more about using Cooklang.
99

@@ -26,78 +26,104 @@ Or install it yourself as:
2626
## Usage
2727

2828
```ruby
29-
source = <<EOF
30-
>> source: https://www.dinneratthezoo.com/wprm_print/6796
31-
>> total time: 6 minutes
32-
>> servings: 2
29+
source = <<~COOK
30+
---
31+
source: https://www.dinneratthezoo.com/wprm_print/6796
32+
time: 6 minutes
33+
servings: 2
34+
---
3335
34-
Place the @apple juice{1,5%cups}, @banana{one sliced}, @frozen mixed berries{1,5%cups} and @vanilla greek yogurt{3/4%cup} in a #blender{}; blend until smooth. If the smoothie seems too thick, add a little more liquid (1/4 cup).
36+
Place the @apple juice{1.5%cups}, @banana{one sliced}, @frozen mixed berries{1.5%cups} and @vanilla greek yogurt{3/4%cup} in a #blender{}; blend until smooth.
3537
3638
Taste and add @honey{} if desired. Pour into two glasses and garnish with fresh berries and mint sprigs if desired.
37-
EOF
39+
COOK
3840

3941
recipe = CooklangRb::Recipe.new(source)
4042

4143
pp recipe.data
4244
# {
43-
# "metadata"=> {...},
44-
# "steps"=> [
45-
# [...],
46-
# [...]
47-
# ]
45+
# "metadata" => {...},
46+
# "steps" => [
47+
# [...],
48+
# [...]
49+
# ]
4850
# }
4951

5052
pp recipe.metadata
5153
# {
52-
# "source"=>"https://www.dinneratthezoo.com/wprm_print/6796",
53-
# "total time"=>"6 minutes",
54-
# "servings"=>"2"
54+
# "source" => "https://www.dinneratthezoo.com/wprm_print/6796",
55+
# "time" => "6 minutes",
56+
# "servings" => "2"
5557
# }
5658

5759
pp recipe.steps
5860
# [
5961
# [
60-
# {
61-
# "type"=>"text",
62-
# "value"=>"Place the "
63-
# },
64-
# {
65-
# "type"=>"ingredient",
66-
# "name"=>"apple juice",
67-
# "quantity"=>"1,5",
68-
# "units"=>"cups"
69-
# },
70-
# {
71-
# "type"=>"text",
72-
# "value"=>", "
73-
# },
74-
# ...
62+
# {"type" => "text", "value" => "Place the "},
63+
# {"type" => "ingredient", "name" => "apple juice", "quantity" => 1.5, "units" => "cups"},
64+
# {"type" => "text", "value" => ", "},
65+
# {"type" => "ingredient", "name" => "banana", "quantity" => "one sliced", "units" => ""},
66+
# {"type" => "text", "value" => ", "},
67+
# {"type" => "ingredient", "name" => "frozen mixed berries", "quantity" => 1.5, "units" => "cups"},
68+
# {"type" => "text", "value" => " and "},
69+
# {"type" => "ingredient", "name" => "vanilla greek yogurt", "quantity" => 0.75, "units" => "cup"},
70+
# {"type" => "text", "value" => " in a "},
71+
# {"type" => "cookware", "name" => "blender", "quantity" => 1, "units" => ""},
72+
# {"type" => "text", "value" => "; blend until smooth."}
7573
# ],
7674
# [
77-
# {
78-
# "type"=>"text",
79-
# "value"=>"Taste and add "
80-
# },
81-
# ...
75+
# {"type" => "text", "value" => "Taste and add "},
76+
# {"type" => "ingredient", "name" => "honey", "quantity" => "some", "units" => ""},
77+
# {"type" => "text", "value" => " if desired. Pour into two glasses and garnish with fresh berries and mint sprigs if desired."}
8278
# ]
8379
# ]
80+
```
81+
82+
### Metadata
83+
84+
Metadata uses YAML front matter delimited by `---`:
85+
86+
```ruby
87+
source = <<~COOK
88+
---
89+
title: Spaghetti Carbonara
90+
tags:
91+
- pasta
92+
- quick
93+
---
8494
95+
Boil @pasta{500%g} in a #pot{}.
96+
COOK
97+
98+
recipe = CooklangRb::Recipe.new(source)
99+
recipe.metadata
100+
# => {"title" => "Spaghetti Carbonara", "tags" => ["pasta", "quick"]}
101+
```
102+
103+
### Comments
104+
105+
```ruby
106+
source = <<~COOK
107+
-- This is a line comment
108+
@eggs{2} -- inline comment
109+
Slowly add @milk{4%cup} [- block comment -], keep mixing
110+
COOK
85111
```
86112

87-
Please visit the [Cooklang Docs](https://cooklang.org/docs) for more information about the Cooklang specification. Including parser impementations in other languages
113+
Please visit the [Cooklang Docs](https://cooklang.org/docs) for more information about the Cooklang specification.
88114

89115
## Development
90116

91117
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
92118

93119
## Contributing
94120

95-
Bug reports and pull requests are welcome on GitHub at https://github.com/drbragg/cooklang_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/drbragg/cooklang_rb/blob/master/CODE_OF_CONDUCT.md).
121+
Bug reports and pull requests are welcome on GitHub at https://github.com/drbragg/cooklang_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/drbragg/cooklang_rb/blob/main/CODE_OF_CONDUCT.md).
96122

97123
## License
98124

99125
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
100126

101127
## Code of Conduct
102128

103-
Everyone interacting in the CooklangRb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drbragg/cooklang_rb/blob/master/CODE_OF_CONDUCT.md).
129+
Everyone interacting in the CooklangRb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drbragg/cooklang_rb/blob/main/CODE_OF_CONDUCT.md).

0 commit comments

Comments
 (0)