jekyll-cooklang-converter 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 84eb0c0f3f9686e895d90daa24604cad91fc3f336ba5311c20010c8fe08a877b
4
+ data.tar.gz: a48f36af64fb5dcd32e86d38525634f3c27c5e8c767c79646128c85ea167c8c2
5
+ SHA512:
6
+ metadata.gz: 796cd7fd7ebb8c7321f87cc82ca7c1708be46b657ea11fcbda63f4724a99fd739b034720aae0e1248ebdb715c32d9e271d5104c3f0493cdcdc0f633eedaffa6b
7
+ data.tar.gz: 26699a51dfc7a327fe0a0077ad3075ce8818dc22c84f492baec3efcae7d8eb310f9b725598056a427398c11f56870442c225f1461d4f9808823f63dfb03fbfd8
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/standardrb/standard
3
+ ruby_version: 3.0
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Jekyll::Cooklang::Converter
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/cooklang/converter`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-cooklang-converter.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "standard/rake"
5
+ require "rspec/core/rake_task"
6
+
7
+ task default: [:standard, :spec, :clash]
8
+
9
+ task :clash do |t|
10
+ sh "bundle exec clash clash"
11
+ end
12
+
13
+ RSpec::Core::RakeTask.new(:spec) do |t|
14
+ t.pattern = Dir.glob("spec/**/*_spec.rb")
15
+ t.rspec_opts = "--format documentation"
16
+ end
data/clash/_clash.yml ADDED
@@ -0,0 +1,5 @@
1
+ -
2
+ title: "Test Build"
3
+ dir: test-site
4
+ build: true
5
+ compare: _expected _site
@@ -0,0 +1,12 @@
1
+ name: Test site
2
+ timezone: UTC
3
+ markdown: kramdown
4
+ gems:
5
+ - jekyll-cooklang-converter
6
+ plugins:
7
+ - jekyll-cooklang-converter
8
+ whitelist:
9
+ - jekyll-cooklang-converter
10
+ collections:
11
+ recipes:
12
+ output: true
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ </head>
6
+ <body>
7
+ <div class='site'>Test content
8
+ </div>
9
+ </body>
10
+ </html>
@@ -0,0 +1,52 @@
1
+ <h2>Ingredients</h2>
2
+ <ul>
3
+ <li><em>1 box</em> mushrooms</li>
4
+ <li><em>1 pound</em> ground sausage</li>
5
+ <li><em>some</em> garlic powder</li>
6
+ <li><em>some</em> italian seasoning</li>
7
+ <li><em>some</em> chili powder</li>
8
+ <li><em>1</em> large yellow onion</li>
9
+ <li><em>some</em> olive oil</li>
10
+ <li><em>some</em> salt</li>
11
+ <li><em>1</em> bell pepper</li>
12
+ <li><em>1 jar</em> pasta sauce</li>
13
+ <li><em>1 15oz package</em> ricotta</li>
14
+ <li><em>1 cup</em> shredded mozarella</li>
15
+ <li><em>1 package</em> sliced provolone</li>
16
+ <li><em>2 cups</em> mozarella cheese</li>
17
+ </ul>
18
+ <h2>Cookware</h2>
19
+ <ul>
20
+ <li><em>1</em> pot</li>
21
+ <li><em>1</em> casserole dish</li>
22
+ </ul>
23
+ <h2>Steps</h2>
24
+ <ol>
25
+ <li>
26
+ <p>set a pot of water on the stove, to boil (you'll need for pasta later), and preheat the oven to 350</p>
27
+ </li>
28
+ <li>
29
+ <p>cut mushrooms into slices, and sautee (no oil) in a pan over medium high heat until browned. Set aside</p>
30
+ </li>
31
+ <li>
32
+ <p>brown ground sausage in the same pan, seasoning with garlic powder, italian seasoning, and chili powder set aside</p>
33
+ </li>
34
+ <li>
35
+ <p>the water should hopefully be boiling by now</p>
36
+ </li>
37
+ <li>
38
+ <p>chop and sautee large yellow onion in olive oil. Seasoning with salt. Add the bell pepper, chopped</p>
39
+ </li>
40
+ <li>
41
+ <p>add back in the mushrooms and sausage, and pour pasta sauce over everything. Mix well, and allow it to simmer until it bubbles a bit at the bottom</p>
42
+ </li>
43
+ <li>
44
+ <p>mix together ricotta and shredded mozarella</p>
45
+ </li>
46
+ <li>
47
+ <p>layer half of the cooked pasta into the bottom of a greased casserole dish. Ladle half of the meat + veggie mixture on top. Then, spread the cheese mixture from the previous step on top of everything. Layer sliced provolone on that, followed by the rest of the sauce, the rest of the pasta, and a final layer of mozarella cheese. Sprinkle the top with italian seasoning</p>
48
+ </li>
49
+ <li>
50
+ <p>put the dish in the preheated oven for . Then it's all ready!</p>
51
+ </li>
52
+ </ol>
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ </head>
6
+ <body>
7
+ <div class='site'>{{ content }}</div>
8
+ </body>
9
+ </html>
@@ -0,0 +1,19 @@
1
+ ---
2
+ ---
3
+ set a #pot of water on the stove, to boil (you'll need for pasta later), and preheat the oven to 350
4
+
5
+ cut @mushrooms{1%box} into slices, and sautee (no oil) in a pan over medium high heat until browned. Set aside
6
+
7
+ brown @ground sausage{1%pound} in the same pan, seasoning with @garlic powder{}, @italian seasoning{}, and @chili powder{} set aside
8
+
9
+ the water should hopefully be boiling by now-- add @dry ziti{1%pound} and leave to cook according to package instructions (usually around 10 minutes)
10
+
11
+ chop and sautee @large yellow onion{1} in @olive oil{}. Seasoning with @salt{}. Add the @bell pepper{1}, chopped
12
+
13
+ add back in the mushrooms and sausage, and pour @pasta sauce{1%jar} over everything. Mix well, and allow it to simmer until it bubbles a bit at the bottom
14
+
15
+ mix together @ricotta{1%15oz package} and @shredded mozarella{1%cup}
16
+
17
+ layer half of the cooked pasta into the bottom of a greased #casserole dish{}. Ladle half of the meat + veggie mixture on top. Then, spread the cheese mixture from the previous step on top of everything. Layer @sliced provolone{1%package} on that, followed by the rest of the sauce, the rest of the pasta, and a final layer of @mozarella cheese{2%cups}. Sprinkle the top with italian seasoning
18
+
19
+ put the dish in the preheated oven for ~{25%minutes}. Then it's all ready!
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ </head>
6
+ <body>
7
+ <div class='site'>Test content
8
+ </div>
9
+ </body>
10
+ </html>
@@ -0,0 +1,52 @@
1
+ <h2>Ingredients</h2>
2
+ <ul>
3
+ <li><em>1 box</em> mushrooms</li>
4
+ <li><em>1 pound</em> ground sausage</li>
5
+ <li><em>some</em> garlic powder</li>
6
+ <li><em>some</em> italian seasoning</li>
7
+ <li><em>some</em> chili powder</li>
8
+ <li><em>1</em> large yellow onion</li>
9
+ <li><em>some</em> olive oil</li>
10
+ <li><em>some</em> salt</li>
11
+ <li><em>1</em> bell pepper</li>
12
+ <li><em>1 jar</em> pasta sauce</li>
13
+ <li><em>1 15oz package</em> ricotta</li>
14
+ <li><em>1 cup</em> shredded mozarella</li>
15
+ <li><em>1 package</em> sliced provolone</li>
16
+ <li><em>2 cups</em> mozarella cheese</li>
17
+ </ul>
18
+ <h2>Cookware</h2>
19
+ <ul>
20
+ <li><em>1</em> pot</li>
21
+ <li><em>1</em> casserole dish</li>
22
+ </ul>
23
+ <h2>Steps</h2>
24
+ <ol>
25
+ <li>
26
+ <p>set a pot of water on the stove, to boil (you'll need for pasta later), and preheat the oven to 350</p>
27
+ </li>
28
+ <li>
29
+ <p>cut mushrooms into slices, and sautee (no oil) in a pan over medium high heat until browned. Set aside</p>
30
+ </li>
31
+ <li>
32
+ <p>brown ground sausage in the same pan, seasoning with garlic powder, italian seasoning, and chili powder set aside</p>
33
+ </li>
34
+ <li>
35
+ <p>the water should hopefully be boiling by now</p>
36
+ </li>
37
+ <li>
38
+ <p>chop and sautee large yellow onion in olive oil. Seasoning with salt. Add the bell pepper, chopped</p>
39
+ </li>
40
+ <li>
41
+ <p>add back in the mushrooms and sausage, and pour pasta sauce over everything. Mix well, and allow it to simmer until it bubbles a bit at the bottom</p>
42
+ </li>
43
+ <li>
44
+ <p>mix together ricotta and shredded mozarella</p>
45
+ </li>
46
+ <li>
47
+ <p>layer half of the cooked pasta into the bottom of a greased casserole dish. Ladle half of the meat + veggie mixture on top. Then, spread the cheese mixture from the previous step on top of everything. Layer sliced provolone on that, followed by the rest of the sauce, the rest of the pasta, and a final layer of mozarella cheese. Sprinkle the top with italian seasoning</p>
48
+ </li>
49
+ <li>
50
+ <p>put the dish in the preheated oven for . Then it's all ready!</p>
51
+ </li>
52
+ </ol>
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ Test content
@@ -0,0 +1,128 @@
1
+ module Jekyll
2
+ module Converters
3
+ class ToHTML
4
+ def to_html
5
+ "<em>hello world</em>"
6
+ end
7
+
8
+ def to_list_item
9
+ "<li>#{to_html}</li>"
10
+ end
11
+ end
12
+
13
+ class Ingredient < ToHTML
14
+ def initialize(quantity, unit, name)
15
+ @name = name
16
+ @unit = unit
17
+ @quantity = quantity
18
+ end
19
+
20
+ def to_html
21
+ return "<em>#{@quantity}</em> #{@name}" if @unit.empty?
22
+ "<em>#{@quantity} #{@unit}</em> #{@name}"
23
+ end
24
+ end
25
+
26
+ class CookWare < ToHTML
27
+ def initialize(quantity, name)
28
+ @name = name
29
+ @quantity = quantity
30
+ end
31
+
32
+ def to_html
33
+ return @name.to_s if @quantity.empty?
34
+ "<em>#{@quantity}</em> #{@name}"
35
+ end
36
+ end
37
+
38
+ class OrderedList < ToHTML
39
+ def initialize(items)
40
+ @items = items
41
+ end
42
+
43
+ def to_html
44
+ list_items = @items.map do |item|
45
+ item.to_list_item
46
+ end
47
+ "<ol>" + list_items.join + "</ol>"
48
+ end
49
+ end
50
+
51
+ class UnorderedList < ToHTML
52
+ def initialize(items)
53
+ @items = items
54
+ end
55
+
56
+ def to_html
57
+ list_items = @items.map do |item|
58
+ item.to_list_item
59
+ end
60
+ "<ul>" + list_items.join + "</ul>"
61
+ end
62
+ end
63
+
64
+ class Step < ToHTML
65
+ def initialize(step)
66
+ @text = step.map do |substep|
67
+ case substep["type"]
68
+ when "cookware"
69
+ substep["name"]
70
+ when "ingredient"
71
+ substep["name"]
72
+ when "text"
73
+ substep["value"]
74
+ end
75
+ end.join
76
+ end
77
+
78
+ def to_html
79
+ "<p>#{@text}</p>"
80
+ end
81
+ end
82
+
83
+ class CooklangConverter < Converter
84
+ safe true
85
+
86
+ def matches(ext)
87
+ ext =~ /^.cook/i
88
+ end
89
+
90
+ def output_ext(ext)
91
+ ".html"
92
+ end
93
+
94
+ def convert(content)
95
+ recipe = CooklangRb::Recipe.from(content)
96
+
97
+ ingredients = recipe["steps"].flatten.select { |item|
98
+ item["type"] == "ingredient"
99
+ }.map { |item|
100
+ Ingredient.new(item["quantity"].to_s, item["units"].to_s, item["name"].to_s)
101
+ }
102
+
103
+ cookware = recipe["steps"].flatten.select { |item|
104
+ item["type"] == "cookware"
105
+ }.map { |item|
106
+ CookWare.new(item["quantity"].to_s, item["name"].to_s)
107
+ }
108
+
109
+ steps = recipe["steps"].map do |step|
110
+ Step.new(step)
111
+ end
112
+
113
+ ingredients_list = UnorderedList.new(ingredients)
114
+ cookware_list = UnorderedList.new(cookware)
115
+ steps_list = OrderedList.new(steps)
116
+
117
+ HtmlBeautifier.beautify(
118
+ "<h2>Ingredients</h2>" +
119
+ ingredients_list.to_html +
120
+ "<h2>Cookware</h2>" +
121
+ cookware_list.to_html +
122
+ "<h2>Steps</h2>" +
123
+ steps_list.to_html
124
+ ) + "\n"
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module CooklangConverter
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require "jekyll"
2
+ require "cooklang_rb"
3
+ require "htmlbeautifier"
4
+ require "jekyll-cooklang-converter/version"
5
+ require "jekyll/converters/cooklang"
6
+
7
+ module Jekyll
8
+ module CooklangConverter
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Jekyll
2
+ module Cooklang
3
+ module Converter
4
+ VERSION: String
5
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
6
+ end
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-cooklang-converter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - BraeTroutman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.3.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.3.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: cooklang_rb
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.2.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: htmlbeautifier
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.4'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.4.3
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.4'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.4.3
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.2'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '3.2'
81
+ - !ruby/object:Gem::Dependency
82
+ name: clash
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '2.3'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 2.3.1
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '2.3'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 2.3.1
101
+ description:
102
+ email:
103
+ - btroutma@redhat.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".standard.yml"
109
+ - README.md
110
+ - Rakefile
111
+ - clash/_clash.yml
112
+ - clash/test-site/_config.yml
113
+ - clash/test-site/_expected/index.html
114
+ - clash/test-site/_expected/recipes/baked-ziti.html
115
+ - clash/test-site/_layouts/default.html
116
+ - clash/test-site/_recipes/baked-ziti.cook
117
+ - clash/test-site/_site/index.html
118
+ - clash/test-site/_site/recipes/baked-ziti.html
119
+ - clash/test-site/index.html
120
+ - lib/jekyll-cooklang-converter.rb
121
+ - lib/jekyll-cooklang-converter/version.rb
122
+ - lib/jekyll/converters/cooklang.rb
123
+ - sig/jekyll/cooklang/converter.rbs
124
+ homepage: https://github.com/BraeTroutman/jekyll-cooklang-converter
125
+ licenses:
126
+ - MIT
127
+ metadata:
128
+ homepage_uri: https://github.com/BraeTroutman/jekyll-cooklang-converter
129
+ source_code_uri: https://github.com/BraeTroutman/jekyll-cooklang-converter
130
+ changelog_uri: https://github.com/BraeTroutman/jekyll-cooklang-converter
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 3.0.0
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubygems_version: 3.3.7
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: A simple Jekyll Converter that maps .cook files to HTML
150
+ test_files: []