hangry 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/hangry.gemspec +21 -0
- data/lib/hangry/version.rb +3 -0
- data/lib/hangry.rb +115 -0
- data/spec/fixtures/food_network_schema_org.html +2447 -0
- data/spec/hangry_spec.rb +77 -0
- data/spec/real_examples/food_network_spec.rb +53 -0
- metadata +103 -0
data/spec/hangry_spec.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'hangry'
|
2
|
+
|
3
|
+
describe Hangry do
|
4
|
+
|
5
|
+
describe "schema.org" do
|
6
|
+
|
7
|
+
let(:html) do
|
8
|
+
<<-eos
|
9
|
+
<!DOCTYPE html>
|
10
|
+
<html>
|
11
|
+
<body>
|
12
|
+
<div itemscope itemtype="http://schema.org/Recipe">
|
13
|
+
<span itemprop="name">Mom's World Famous Banana Bread</span>
|
14
|
+
By <span itemprop="author">John Smith</span>,
|
15
|
+
<meta itemprop="datePublished" content="2009-05-08">May 8, 2009
|
16
|
+
<img itemprop="image" src="bananabread.jpg" />
|
17
|
+
|
18
|
+
<span itemprop="description">This classic banana bread recipe comes from my mom -- the walnuts add a nice texture and flavor to the banana bread.</span>
|
19
|
+
|
20
|
+
Prep Time: <meta itemprop="prepTime" content="PT15M">15 minutes
|
21
|
+
Cook time: <meta itemprop="cookTime" content="PT1H">1 hour
|
22
|
+
Yield: <span itemprop="recipeYield">1 loaf</span>
|
23
|
+
|
24
|
+
<div itemprop="nutrition"
|
25
|
+
itemscope itemtype="http://schema.org/NutritionInformation">
|
26
|
+
Nutrition facts:
|
27
|
+
<span itemprop="calories">240 calories</span>,
|
28
|
+
<span itemprop="fatContent">9 grams fat</span>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
Ingredients:
|
32
|
+
- <span itemprop="ingredients">3 or 4 ripe bananas, smashed</span>
|
33
|
+
- <span itemprop="ingredients">1 egg</span>
|
34
|
+
- <span itemprop="ingredients">3/4 cup of sugar</span>
|
35
|
+
...
|
36
|
+
|
37
|
+
Instructions:
|
38
|
+
<span itemprop="recipeInstructions">Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add the flour last. Pour the mixture into a loaf pan and bake for one hour.</span>
|
39
|
+
|
40
|
+
140 comments:
|
41
|
+
<meta itemprop="interactionCount" content="UserComments:140" />
|
42
|
+
From Janel, May 5 -- thank you, great recipe!
|
43
|
+
...
|
44
|
+
</div>
|
45
|
+
</body>
|
46
|
+
</html>
|
47
|
+
eos
|
48
|
+
end
|
49
|
+
|
50
|
+
subject { Hangry.parse(html) }
|
51
|
+
|
52
|
+
its(:author) { should == "John Smith" }
|
53
|
+
its(:cook_time) { should == "PT1H" }
|
54
|
+
its(:description) { should == 'This classic banana bread recipe comes from my mom -- the walnuts add a nice texture and flavor to the banana bread.' }
|
55
|
+
its(:ingredients) { should == ["3 or 4 ripe bananas, smashed", "1 egg", "3/4 cup of sugar"] }
|
56
|
+
its(:instructions) { should == "Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add the flour last. Pour the mixture into a loaf pan and bake for one hour." }
|
57
|
+
|
58
|
+
its(:name) { should == "Mom's World Famous Banana Bread" }
|
59
|
+
its(:prep_time) { should == "PT15M" }
|
60
|
+
its(:published_date) { should == Date.parse("2009-05-08") }
|
61
|
+
its(:yield) { should == '1 loaf' }
|
62
|
+
|
63
|
+
context "with no input" do
|
64
|
+
subject { Hangry.parse("") }
|
65
|
+
|
66
|
+
it "should set all attributes to nil" do
|
67
|
+
Hangry::RECIPE_ATTRIBUTES.each do |attribute|
|
68
|
+
subject.send(attribute).should be_nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'hangry'
|
2
|
+
|
3
|
+
describe Hangry do
|
4
|
+
|
5
|
+
context "food network recipe" do
|
6
|
+
subject { Hangry.parse(File.read("/Users/ian/Code/rubygems/hangry/spec/fixtures/food_network_schema_org.html")) }
|
7
|
+
|
8
|
+
its(:cook_time) { should == "PT0H20M" }
|
9
|
+
its(:description) { should == nil }
|
10
|
+
its(:ingredients) do
|
11
|
+
should == [
|
12
|
+
"4 boneless, skinless chicken breasts, 6 ounces",
|
13
|
+
"Large plastic food storage bags or waxed paper",
|
14
|
+
"1 package, 10 ounces, frozen chopped spinach",
|
15
|
+
"2 tablespoons butter",
|
16
|
+
"12 small mushroom caps, crimini or button",
|
17
|
+
"2 cloves garlic, cracked",
|
18
|
+
"1 small shallot, quartered",
|
19
|
+
"Salt and freshly ground black pepper",
|
20
|
+
"1 cup part skim ricotta cheese",
|
21
|
+
"1/2 cup grated Parmigiano or Romano, a couple of handfuls",
|
22
|
+
"1/2 teaspoon fresh grated or ground nutmeg",
|
23
|
+
"Toothpicks",
|
24
|
+
"2 tablespoons extra-virgin olive oil",
|
25
|
+
"2 tablespoons butter",
|
26
|
+
"2 tablespoons flour",
|
27
|
+
"1/2 cup white wine",
|
28
|
+
"1 cup chicken broth"
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
its(:instructions) do
|
33
|
+
instructions = <<-instructions
|
34
|
+
Place breasts in the center of a plastic food storage bag or 2 large sheets of waxed paper. Pound out the chicken from the center of the bag outward using a heavy-bottomed skillet or mallet. Be firm but controlled with your strokes.\n Defrost spinach in the microwave. Transfer spinach to a kitchen towel. Twist towel around spinach and wring it out until very dry. Transfer to a medium-mixing bowl.\n Place a nonstick skillet over moderate heat. When skillet is hot, add butter, mushrooms, garlic and shallot. Season with salt and pepper and saute 5 minutes. Transfer mushrooms, garlic and shallot to the food processor. Pulse to grind the mushrooms and transfer to the mixing bowl, adding the processed mushrooms to the spinach. Add ricotta and grated cheese to the bowl and the nutmeg. Stir to combine the stuffing. Return your skillet to the stove over medium high heat.\n Place a mound of stuffing on each breast and wrap and roll breast over the stuffing. Secure breasts with toothpicks. Add 3 tablespoons oil to the pan, 3 turns of the pan. Add breasts to the pan and brown on all sides, cooking chicken 10 to 12 minutes. The meat will cook quickly because it is thin. Remove breasts; add butter to the pan and flour. Cook butter and flour for a minute, whisk in wine and reduce another minute. Whisk in broth and return breasts to the pan. Reduce heat and simmer until ready to serve. Remove toothpicks. Serve breasts whole or, remove from pan, slice on an angle and fan out on dinner plates. Top stuffed chicken breasts or sliced stuffed breasts with generous spoonfuls of the sauce.
|
35
|
+
instructions
|
36
|
+
should == instructions.strip
|
37
|
+
end
|
38
|
+
|
39
|
+
its(:name) { should == "Spinach and Mushroom Stuffed Chicken Breasts" }
|
40
|
+
its(:prep_time) { should == "PT0H15M" }
|
41
|
+
its(:published_date) { should == Date.parse("2013-02-06") }
|
42
|
+
its(:total_time) { should == "PT0H35M" }
|
43
|
+
its(:yield) { should == "4 servings" }
|
44
|
+
|
45
|
+
it 'should parse the name of a schema.org Person when they are the author' do
|
46
|
+
subject.author.should == 'Rachael Ray'
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hangry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ian C. Anderson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-04 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70201936519260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70201936519260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: pry
|
27
|
+
requirement: &70201936518840 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70201936518840
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
requirement: &70201936518420 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70201936518420
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: &70201936518000 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70201936518000
|
58
|
+
description: A recipe microformat parser.
|
59
|
+
email:
|
60
|
+
- ian@iancanderson.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- hangry.gemspec
|
71
|
+
- lib/hangry.rb
|
72
|
+
- lib/hangry/version.rb
|
73
|
+
- spec/fixtures/food_network_schema_org.html
|
74
|
+
- spec/hangry_spec.rb
|
75
|
+
- spec/real_examples/food_network_spec.rb
|
76
|
+
homepage: https://github.com/iancanderson/hangry
|
77
|
+
licenses: []
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.8.10
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Parses microformatted recipe HTML into a plain-old-ruby Recipe object.
|
100
|
+
test_files:
|
101
|
+
- spec/fixtures/food_network_schema_org.html
|
102
|
+
- spec/hangry_spec.rb
|
103
|
+
- spec/real_examples/food_network_spec.rb
|