tychus 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ describe Tychus::ParserSelector do
2
+ subject(:parser_selector) { Tychus::ParserSelector }
3
+
4
+ context "allrecipes.com uris" do
5
+ before {
6
+ VCR.use_cassette(cassette) do
7
+ @m = Tychus::MetaParser.new(uri).parse
8
+ end
9
+ }
10
+ let(:uri) { "http://allrecipes.com/Recipe/Chicken-Pot-Pie-IX/Detail.aspx?soid=recs_recipe_2" }
11
+ let(:cassette) { "parser_selector_allrecipes_1" }
12
+
13
+ specify "resolve to the AllrecipesParser" do
14
+ expect(subject.resolve_parser(@m)).to eq(Tychus::Parsers::AllrecipesParser)
15
+ end
16
+
17
+ end
18
+
19
+ context "when specific parser doesn't exist but uri uses schema org's microformat" do
20
+ before do
21
+ VCR.use_cassette(cassette) do
22
+ @m = Tychus::MetaParser.new(uri).parse
23
+ end
24
+ end
25
+
26
+ context "for 'cookingquinoa.net'" do
27
+
28
+ let(:uri) { "http://www.cookingquinoa.net/quinoa-bacon-club-wrap/" }
29
+ let(:cassette) { "cooking_quinoa" }
30
+
31
+ it "resolves to the Schema Org Parser" do
32
+ expect(subject.resolve_parser(@m)).to eq(Tychus::Parsers::SchemaOrgParser)
33
+ end
34
+ end
35
+
36
+ context "for 'asideofsweet.com'" do
37
+
38
+ let(:uri) { "http://asideofsweet.com/black-cherry-buttermilk-ice-cream/" }
39
+ let(:cassette) { "a_side_of_sweet" }
40
+
41
+ it "resolves to the Schema Org Parser" do
42
+ expect(subject.resolve_parser(@m)).to eq(Tychus::Parsers::SchemaOrgParser)
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
@@ -1,5 +1,6 @@
1
1
  describe Tychus::Parsers::CampbellsKitchenParser do
2
2
  before { pending "Does NOT use schema.org microformat" }
3
+
3
4
  subject do
4
5
  VCR.use_cassette("campbells_kitchen_1") do
5
6
  Tychus::Parsers::CampbellsKitchenParser.new(campbells_kitchen_uri)
@@ -0,0 +1,69 @@
1
+ describe Tychus::Parsers::SimpleParser do
2
+
3
+ describe "#ingredient_class_search" do
4
+
5
+ specify "simple case" do
6
+ url = "http://www.campbellskitchen.com/recipes/squash-casserole-24122"
7
+ ingredients = [
8
+ "3 cups Pepperidge Farm® Cornbread Stuffing",
9
+ "1/4 cup butter, melted (1/2 stick)",
10
+ "1 can (10 3/4 ounces) Campbell's® Condensed Cream of Chicken Soup (Regular or 98% Fat Free)",
11
+ "1/2 cup sour cream",
12
+ "2 small yellow squash, shredded (about 2 cups)",
13
+ "2 small zucchini, shredded (about 2 cups)",
14
+ "1 small carrot, shredded (about 1/3 cup)",
15
+ "1/2 cup shredded Cheddar cheese (about 2 ounces)"
16
+ ]
17
+
18
+ VCR.use_cassette("campbells_kitchen_1") do
19
+ expect(Tychus::Parsers::SimpleParser.new(url).ingredient_class_search).to eq(ingredients)
20
+ end
21
+ end
22
+
23
+ specify "non-descriptive paragraph element within multi-level div nesting" do
24
+ url = "http://abetterhappierstsebastian.com/journal/2014/8/4/chickpea-veggie-burger-with-fried-halloumi"
25
+ ingredients = [
26
+ "2 whole wheat buns",
27
+ "1 15 oz can garbanzo beans, drained",
28
+ "6 oz porchini mushrooms, diced",
29
+ "1/2 red pepper, diced",
30
+ "1/2 cup cut kale leaves (about 3 stems)",
31
+ "2 thick slices halloumi cheese",
32
+ "1 egg",
33
+ "1/4 cup breadcrumbs",
34
+ "1 1/2 tbs chickpea flour",
35
+ "4 tsp olive oil, divided",
36
+ "1 tsp cumin",
37
+ "3 tsp garlic powder",
38
+ "salt and pepper"
39
+ ]
40
+
41
+ VCR.use_cassette("a_better_happier_st_sebastian") do
42
+ expect(Tychus::Parsers::SimpleParser.new(url).ingredient_class_search).to eq(ingredients)
43
+ end
44
+ end
45
+
46
+ specify "non-descript list of divs " do
47
+ url = "http://www.confessionsofafoodie.me/2014/08/how-to-roast-chicken.html#.U9-_OKPZUxE"
48
+ ingredients = [
49
+ "3 tablespoons butter, room temperature",
50
+ "1 ½ teaspoons sea salt",
51
+ "¼ teaspoon ground cumin",
52
+ "½ teaspoon freshly grated black pepper",
53
+ "1 ½ tablespoons finely chopped fresh rosemary",
54
+ "1 clove garlic, minced",
55
+ "Zest from one medium lemon",
56
+ "1 ½ pounds muscato grapes (or any seedless red grape)",
57
+ "2 tablespoons extra virgin olive oil",
58
+ "1 tablespoon balsamic vinegar",
59
+ "½ teaspoon sea salt",
60
+ "1 ½ tablespoons fresh mint, finely chopped",
61
+ "4 ½ - 5 lb chicken",
62
+ "1 lemon",
63
+ "2 sprigs fresh rosemary"
64
+ ]
65
+ end
66
+
67
+ end
68
+
69
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tychus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne Yang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-28 00:00:00.000000000 Z
11
+ date: 2014-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,23 +174,29 @@ files:
174
174
  - lib/tychus/parsers/kraft_recipes_parser.rb
175
175
  - lib/tychus/parsers/open_graph_protocol_parser.rb
176
176
  - lib/tychus/parsers/schema_org_parser.rb
177
+ - lib/tychus/parsers/simple_parser.rb
177
178
  - lib/tychus/uri_resolver.rb
178
179
  - lib/tychus/version.rb
179
180
  - questions.md
181
+ - spec/fixtures/cassettes/a_better_happier_st_sebastian.yml
182
+ - spec/fixtures/cassettes/a_side_of_sweet.yml
180
183
  - spec/fixtures/cassettes/allrecipes_1.yml
181
184
  - spec/fixtures/cassettes/campbells_kitchen_1.yml
185
+ - spec/fixtures/cassettes/cooking_quinoa.yml
182
186
  - spec/fixtures/cassettes/food_network_single_ingredients_group_1.yml
183
187
  - spec/fixtures/cassettes/kraft_recipes_1.yml
184
188
  - spec/fixtures/cassettes/meta_parser_og_protocol_uri.yml
185
189
  - spec/fixtures/cassettes/meta_parser_schema_org_microformat_uri.yml
186
- - spec/meta_parser.rb
187
- - spec/parser_selector.rb
190
+ - spec/fixtures/cassettes/parser_selector_allrecipes_1.yml
191
+ - spec/meta_parser_spec.rb
192
+ - spec/parser_selector_spec.rb
188
193
  - spec/parsers/allrecipes_parser_spec.rb
189
194
  - spec/parsers/base_spec.rb
190
195
  - spec/parsers/campbells_kitchen_parser_spec.rb
191
196
  - spec/parsers/food_network_parser_spec.rb
192
197
  - spec/parsers/kraft_recipes_parser_spec.rb
193
198
  - spec/parsers/schema_org_parser_spec.rb
199
+ - spec/parsers/simple_parser_spec.rb
194
200
  - spec/spec_helper.rb
195
201
  - spec/tychus_spec.rb
196
202
  - spec/uri_resolver_spec.rb
@@ -220,20 +226,25 @@ signing_key:
220
226
  specification_version: 4
221
227
  summary: Web recipe parser
222
228
  test_files:
229
+ - spec/fixtures/cassettes/a_better_happier_st_sebastian.yml
230
+ - spec/fixtures/cassettes/a_side_of_sweet.yml
223
231
  - spec/fixtures/cassettes/allrecipes_1.yml
224
232
  - spec/fixtures/cassettes/campbells_kitchen_1.yml
233
+ - spec/fixtures/cassettes/cooking_quinoa.yml
225
234
  - spec/fixtures/cassettes/food_network_single_ingredients_group_1.yml
226
235
  - spec/fixtures/cassettes/kraft_recipes_1.yml
227
236
  - spec/fixtures/cassettes/meta_parser_og_protocol_uri.yml
228
237
  - spec/fixtures/cassettes/meta_parser_schema_org_microformat_uri.yml
229
- - spec/meta_parser.rb
230
- - spec/parser_selector.rb
238
+ - spec/fixtures/cassettes/parser_selector_allrecipes_1.yml
239
+ - spec/meta_parser_spec.rb
240
+ - spec/parser_selector_spec.rb
231
241
  - spec/parsers/allrecipes_parser_spec.rb
232
242
  - spec/parsers/base_spec.rb
233
243
  - spec/parsers/campbells_kitchen_parser_spec.rb
234
244
  - spec/parsers/food_network_parser_spec.rb
235
245
  - spec/parsers/kraft_recipes_parser_spec.rb
236
246
  - spec/parsers/schema_org_parser_spec.rb
247
+ - spec/parsers/simple_parser_spec.rb
237
248
  - spec/spec_helper.rb
238
249
  - spec/tychus_spec.rb
239
250
  - spec/uri_resolver_spec.rb
@@ -1,14 +0,0 @@
1
- describe Tychus::ParserSelector do
2
- subject(:parser_selector) { Tychus::ParserSelector.new(uri) }
3
-
4
- context "allrecipes.com uris" do
5
- let(:uri) { "http://allrecipes.com/Recipe/Chicken-Pot-Pie-IX/Detail.aspx?soid=recs_recipe_2" }
6
-
7
- specify "resolves to the AllrecipesParser" do
8
- expect(subject.resolve_parser).to eq(Tychus::Parsers::AllrecipesParser)
9
- end
10
-
11
- end
12
-
13
- end
14
-