hangry 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -1
- data/hangry.gemspec +3 -2
- data/lib/hangry/version.rb +1 -1
- data/lib/hangry.rb +21 -4
- data/spec/fixtures/allrecipes.html +2847 -0
- data/spec/hangry_spec.rb +25 -2
- data/spec/real_examples/all_recipes_spec.rb +35 -0
- data/spec/real_examples/food_network_spec.rb +4 -4
- metadata +28 -13
data/spec/hangry_spec.rb
CHANGED
@@ -50,13 +50,13 @@ describe Hangry do
|
|
50
50
|
subject { Hangry.parse(html) }
|
51
51
|
|
52
52
|
its(:author) { should == "John Smith" }
|
53
|
-
its(:cook_time) { should ==
|
53
|
+
its(:cook_time) { should == 60 }
|
54
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
55
|
its(:ingredients) { should == ["3 or 4 ripe bananas, smashed", "1 egg", "3/4 cup of sugar"] }
|
56
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
57
|
|
58
58
|
its(:name) { should == "Mom's World Famous Banana Bread" }
|
59
|
-
its(:prep_time) { should ==
|
59
|
+
its(:prep_time) { should == 15 }
|
60
60
|
its(:published_date) { should == Date.parse("2009-05-08") }
|
61
61
|
its(:yield) { should == '1 loaf' }
|
62
62
|
|
@@ -71,6 +71,29 @@ describe Hangry do
|
|
71
71
|
|
72
72
|
end
|
73
73
|
|
74
|
+
context "time duration parsing" do
|
75
|
+
|
76
|
+
let(:html) do
|
77
|
+
<<-eos
|
78
|
+
<!DOCTYPE html>
|
79
|
+
<html>
|
80
|
+
<body>
|
81
|
+
<div itemscope itemtype="http://schema.org/Recipe">
|
82
|
+
Prep Time: <meta itemprop="prepTime" content="PT1H15M">1 hour, 15 minutes
|
83
|
+
Cook time: <meta itemprop="cookTime" content="PT1H">1 hour
|
84
|
+
</div>
|
85
|
+
</body>
|
86
|
+
</html>
|
87
|
+
eos
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should convert times to total minutes" do
|
91
|
+
subject.prep_time.should == 75
|
92
|
+
subject.cook_time.should == 60
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
74
97
|
end
|
75
98
|
|
76
99
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'hangry'
|
2
|
+
|
3
|
+
describe Hangry do
|
4
|
+
|
5
|
+
context "allrecipes.com recipe" do
|
6
|
+
subject { Hangry.parse(File.read("spec/fixtures/allrecipes.html")) }
|
7
|
+
|
8
|
+
its(:author) { should == "United Soybean Board" }
|
9
|
+
its(:cook_time) { should == 15 }
|
10
|
+
its(:description) { should == "\"This better-for-you main-dish salad is quick, colorful and full of satisfying texture. To explore a variety of grains, substitute 3 cups cooked regular couscous, brown rice or quinoa.\"" }
|
11
|
+
its(:ingredients) {
|
12
|
+
should == [
|
13
|
+
'3 cups broccoli florets, cut into 1/2-inch pieces',
|
14
|
+
'1 red bell pepper, cut into 1-inch squares',
|
15
|
+
'1 1/2 cups red onion, peeled and cut into 1/4-inch slices',
|
16
|
+
'6 tablespoons soybean oil, divided (often labeled "vegetable oil")',
|
17
|
+
'1/2 tablespoon ground black pepper, divided',
|
18
|
+
'1/2 teaspoon salt, divided',
|
19
|
+
'1 1/2 cups dry giant Israeli couscous',
|
20
|
+
'2 tablespoons balsamic vinegar'
|
21
|
+
]
|
22
|
+
}
|
23
|
+
its(:name) { should == "Roasted Vegetable and Couscous Salad" }
|
24
|
+
its(:instructions) { should == nil }
|
25
|
+
its(:prep_time) { should == 15 }
|
26
|
+
its(:published_date) { should == nil }
|
27
|
+
its(:total_time) { should == 30 }
|
28
|
+
its(:yield) { should == "6 servings" }
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
@@ -3,9 +3,9 @@ require 'hangry'
|
|
3
3
|
describe Hangry do
|
4
4
|
|
5
5
|
context "food network recipe" do
|
6
|
-
subject { Hangry.parse(File.read("
|
6
|
+
subject { Hangry.parse(File.read("spec/fixtures/food_network_schema_org.html")) }
|
7
7
|
|
8
|
-
its(:cook_time) { should ==
|
8
|
+
its(:cook_time) { should == 20 }
|
9
9
|
its(:description) { should == nil }
|
10
10
|
its(:ingredients) do
|
11
11
|
should == [
|
@@ -37,9 +37,9 @@ Place breasts in the center of a plastic food storage bag or 2 large sheets of w
|
|
37
37
|
end
|
38
38
|
|
39
39
|
its(:name) { should == "Spinach and Mushroom Stuffed Chicken Breasts" }
|
40
|
-
its(:prep_time) { should ==
|
40
|
+
its(:prep_time) { should == 15 }
|
41
41
|
its(:published_date) { should == Date.parse("2013-02-06") }
|
42
|
-
its(:total_time) { should ==
|
42
|
+
its(:total_time) { should == 35 }
|
43
43
|
its(:yield) { should == "4 servings" }
|
44
44
|
|
45
45
|
it 'should parse the name of a schema.org Person when they are the author' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hangry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-03-04 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70363735231260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70363735231260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: pry
|
27
|
-
requirement: &
|
27
|
+
requirement: &70363735230840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,29 +32,40 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70363735230840
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activesupport
|
38
|
-
requirement: &
|
38
|
+
requirement: &70363735230340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '0'
|
43
|
+
version: '3.0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70363735230340
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: iso8601
|
49
|
+
requirement: &70363735229840 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.0
|
44
55
|
type: :runtime
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70363735229840
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: nokogiri
|
49
|
-
requirement: &
|
60
|
+
requirement: &70363735229380 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
|
-
- -
|
63
|
+
- - ~>
|
53
64
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
65
|
+
version: '1.5'
|
55
66
|
type: :runtime
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
68
|
+
version_requirements: *70363735229380
|
58
69
|
description: A recipe microformat parser.
|
59
70
|
email:
|
60
71
|
- ian@iancanderson.com
|
@@ -70,8 +81,10 @@ files:
|
|
70
81
|
- hangry.gemspec
|
71
82
|
- lib/hangry.rb
|
72
83
|
- lib/hangry/version.rb
|
84
|
+
- spec/fixtures/allrecipes.html
|
73
85
|
- spec/fixtures/food_network_schema_org.html
|
74
86
|
- spec/hangry_spec.rb
|
87
|
+
- spec/real_examples/all_recipes_spec.rb
|
75
88
|
- spec/real_examples/food_network_spec.rb
|
76
89
|
homepage: https://github.com/iancanderson/hangry
|
77
90
|
licenses: []
|
@@ -98,6 +111,8 @@ signing_key:
|
|
98
111
|
specification_version: 3
|
99
112
|
summary: Parses microformatted recipe HTML into a plain-old-ruby Recipe object.
|
100
113
|
test_files:
|
114
|
+
- spec/fixtures/allrecipes.html
|
101
115
|
- spec/fixtures/food_network_schema_org.html
|
102
116
|
- spec/hangry_spec.rb
|
117
|
+
- spec/real_examples/all_recipes_spec.rb
|
103
118
|
- spec/real_examples/food_network_spec.rb
|