little-recipe-parser 0.1.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
+ SHA1:
3
+ metadata.gz: 83ddbad0d9debbb63a78bb6341abe99ee94b0900
4
+ data.tar.gz: 0edf4d66d3e632b0a297fe0dd034e9c6acc9b6db
5
+ SHA512:
6
+ metadata.gz: 2754550b036f1ea5ca09913881c29e6ecba586f3d9154235e7d6914e0a5f9adc00e6d3dcce9277592a8579fda619f63a921d32102c16efdff799fe7bdcd2bfee
7
+ data.tar.gz: 348839d54cf87e9a637e84364522e271678e10a6d8bc3a71e390ed5e660ebac390d083660dc9315921b65a59c323c9578b1f0a1f97b63d4d065b883f4c10b6dc
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "activesupport"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0"
12
+ gem "jeweler", "~> 2.0.1"
13
+ gem "simplecov", ">= 0"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,82 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.0.2)
5
+ i18n (~> 0.6, >= 0.6.4)
6
+ minitest (~> 4.2)
7
+ multi_json (~> 1.3)
8
+ thread_safe (~> 0.1)
9
+ tzinfo (~> 0.3.37)
10
+ addressable (2.3.5)
11
+ atomic (1.1.14)
12
+ builder (3.2.2)
13
+ descendants_tracker (0.0.3)
14
+ docile (1.1.2)
15
+ faraday (0.9.0)
16
+ multipart-post (>= 1.2, < 3)
17
+ git (1.2.6)
18
+ github_api (0.11.1)
19
+ addressable (~> 2.3)
20
+ descendants_tracker (~> 0.0.1)
21
+ faraday (~> 0.8, < 0.10)
22
+ hashie (>= 1.2)
23
+ multi_json (>= 1.7.5, < 2.0)
24
+ nokogiri (~> 1.6.0)
25
+ oauth2
26
+ hashie (2.0.5)
27
+ highline (1.6.20)
28
+ httpauth (0.2.0)
29
+ i18n (0.6.9)
30
+ jeweler (2.0.1)
31
+ builder
32
+ bundler (>= 1.0)
33
+ git (>= 1.2.5)
34
+ github_api
35
+ highline (>= 1.6.15)
36
+ nokogiri (>= 1.5.10)
37
+ rake
38
+ rdoc
39
+ json (1.8.1)
40
+ jwt (0.1.11)
41
+ multi_json (>= 1.5)
42
+ mini_portile (0.5.2)
43
+ minitest (4.7.5)
44
+ multi_json (1.8.4)
45
+ multipart-post (2.0.0)
46
+ nokogiri (1.6.1)
47
+ mini_portile (~> 0.5.0)
48
+ oauth2 (0.8.1)
49
+ faraday (~> 0.8)
50
+ httpauth (~> 0.1)
51
+ jwt (~> 0.1.4)
52
+ multi_json (~> 1.0)
53
+ rack (~> 1.2)
54
+ rack (1.5.2)
55
+ rake (10.1.1)
56
+ rdoc (3.12.2)
57
+ json (~> 1.4)
58
+ shoulda (3.5.0)
59
+ shoulda-context (~> 1.0, >= 1.0.1)
60
+ shoulda-matchers (>= 1.4.1, < 3.0)
61
+ shoulda-context (1.1.6)
62
+ shoulda-matchers (2.4.0)
63
+ activesupport (>= 3.0.0)
64
+ simplecov (0.8.2)
65
+ docile (~> 1.1.0)
66
+ multi_json
67
+ simplecov-html (~> 0.8.0)
68
+ simplecov-html (0.8.0)
69
+ thread_safe (0.1.3)
70
+ atomic
71
+ tzinfo (0.3.38)
72
+
73
+ PLATFORMS
74
+ ruby
75
+
76
+ DEPENDENCIES
77
+ activesupport
78
+ bundler (~> 1.0)
79
+ jeweler (~> 2.0.1)
80
+ rdoc (~> 3.12)
81
+ shoulda
82
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Meeka
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Little Recipe Parser
2
+
3
+ ### A gem for parsing recipes
4
+
5
+ --------
6
+
7
+ ## Usage
8
+
9
+ ```ruby
10
+ result = LittleRecipeParser::Parse.new('1 pound of tomatoes')
11
+ print result.quantity
12
+ #=> '1'
13
+ print result.measurement
14
+ #=> 'pound'
15
+ print result.tag
16
+ #=> "Tomato"
17
+ ```
18
+
19
+ Visit the website at:
20
+
21
+ [Live demo](http://thelittleparser.herokuapp.com/)
22
+
23
+
24
+ == Copyright
25
+
26
+ Copyright (c) 2014 Meeka. See LICENSE.txt for
27
+ further details.
28
+
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "little-recipe-parser"
18
+ gem.homepage = "http://github.com/rrgayhart/little-recipe-parser"
19
+ gem.license = "MIT"
20
+ gem.summary = "Recipe Parsing Gem"
21
+ gem.description = "Recipe Parsing Gem - Simply run LittleRecipeParser::Parse.new('1 pound of chicken') - you can then call .quantity, .tag or .measurement on the string"
22
+ gem.email = "rrgayhart@gmail.com"
23
+ gem.authors = ["Meeka"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['test'].execute
39
+ end
40
+
41
+ task :default => :test
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "little-recipe-parser #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,177 @@
1
+ class LittleRecipeParser::GroceryListFormatter
2
+
3
+ def self.check_name(string)
4
+ array = normal.select do |ingredient|
5
+ string.downcase.include?(ingredient.downcase.pluralize) ||
6
+ string.downcase.include?(ingredient.downcase)
7
+ end
8
+ if array.any?
9
+ array.first
10
+ else
11
+ check_secondary(string)
12
+ end
13
+ end
14
+
15
+ def self.check_secondary(string)
16
+ secondary.select do |ingredient|
17
+ string.downcase.include?(ingredient.downcase.pluralize) ||
18
+ string.downcase.include?(ingredient.downcase)
19
+ end.first
20
+ end
21
+
22
+ def self.normal
23
+ ['Allspice',
24
+ 'Salt and Pepper',
25
+ 'Black Peppercorn',
26
+ 'Arrowroot starch',
27
+ 'Basil',
28
+ 'Bay Leaves',
29
+ 'Chili Powder',
30
+ 'Cinnamon',
31
+ 'Garlic',
32
+ 'Red Wine Vinegar',
33
+ 'Coriander',
34
+ 'Cream of tartar',
35
+ 'Cumin',
36
+ 'Curry',
37
+ 'Dill',
38
+ 'Fennel',
39
+ 'Five-spice powder',
40
+ 'Garlic powder',
41
+ 'Fresh Ginger',
42
+ 'Powdered Ginger',
43
+ 'Marjoram',
44
+ 'Mint',
45
+ 'Mustard',
46
+ 'Nutmeg',
47
+ 'Pearl Onion',
48
+ 'Red Onion',
49
+ 'Sweet Onion',
50
+ 'Agave Syrup',
51
+ 'Maple Syrup',
52
+ 'Oregano',
53
+ 'Paprika',
54
+ 'cayenne',
55
+ 'Peppercorns',
56
+ 'Poppy seeds',
57
+ 'Rosemary',
58
+ 'Sage',
59
+ 'Sesame seeds',
60
+ 'Tarragon',
61
+ 'Thyme',
62
+ 'Turmeric',
63
+ 'Vanilla',
64
+ 'Baking Powder',
65
+ 'Baking Soda',
66
+ 'Brown Sugar',
67
+ 'Brownie Mix',
68
+ 'Cake Mix',
69
+ 'Cocoa',
70
+ 'Cornstarch',
71
+ 'Flour',
72
+ 'Sugar',
73
+ 'Vanilla Extract',
74
+ 'Bread Crumbs',
75
+ 'Biscuits',
76
+ 'Bread',
77
+ 'Buns',
78
+ 'Rolls',
79
+ 'Soup',
80
+ 'Canned Tuna',
81
+ 'BBQ Sauce',
82
+ 'Cooking Spray',
83
+ 'Honey',
84
+ 'Horseradish',
85
+ 'Hot sauce',
86
+ 'Jelly',
87
+ 'Ketchup',
88
+ 'Mayonnaise',
89
+ 'Mustard',
90
+ 'Olive Oil',
91
+ 'Peanut Butter',
92
+ 'Salad Dressing',
93
+ 'Salsa',
94
+ 'Soy Sauce',
95
+ 'Vegetable Oil',
96
+ 'Worcestershire',
97
+ 'Dairy',
98
+ 'Butter',
99
+ 'Cheese',
100
+ 'Cottage Cheese',
101
+ 'Cream',
102
+ 'Cream Cheese',
103
+ 'Eggs',
104
+ 'Milk',
105
+ 'Sour Cream',
106
+ 'Pancetta',
107
+ 'Yogurt',
108
+ 'Watercress',
109
+ 'Coffee',
110
+ 'Soda Pop',
111
+ 'Sports Drinks',
112
+ 'Tea',
113
+ 'French Fries',
114
+ 'Frozen Vegetables',
115
+ 'Ice Cream',
116
+ 'Pizza',
117
+ 'Pasta',
118
+ 'Rice',
119
+ 'Spaghetti Sauce',
120
+ 'Meats',
121
+ 'Beef',
122
+ 'Pork Loin',
123
+ 'Chicken',
124
+ 'Fish',
125
+ 'Pork',
126
+ 'Apple',
127
+ 'Asparagus',
128
+ 'Bananas',
129
+ 'Berries',
130
+ 'Broccoli',
131
+ 'Cabbage',
132
+ 'Carrots',
133
+ 'Cauliflower',
134
+ 'Celery',
135
+ 'Corn',
136
+ 'Garlic',
137
+ 'Grapes',
138
+ 'Lemons',
139
+ 'Bacon',
140
+ 'Lettuce',
141
+ 'Lime',
142
+ 'Melons',
143
+ 'Mushrooms',
144
+ 'Nectarines',
145
+ 'Onions',
146
+ 'Oranges',
147
+ 'Peaches',
148
+ 'Pears',
149
+ 'Plums',
150
+ 'Cornstarch',
151
+ 'Rice Wine Vinegar',
152
+ 'sesame oil',
153
+ 'hoisin sauce',
154
+ 'Scallion',
155
+ 'Tomato',
156
+ 'Bean Sprouts',
157
+ 'Tofu',
158
+ 'Tuna',
159
+ 'Radish'
160
+ ]
161
+ end
162
+
163
+ def self.secondary
164
+ [
165
+ 'Salt',
166
+ 'Cloves',
167
+ 'Pepper',
168
+ 'Pork',
169
+ 'Juice',
170
+ 'Onion',
171
+ 'Syrup',
172
+ 'Ginger',
173
+ 'Beans',
174
+ 'Water'
175
+ ]
176
+ end
177
+ end
@@ -0,0 +1,6 @@
1
+ module LittleRecipeParser
2
+ end
3
+ require 'active_support/all'
4
+ require_relative 'grocery_list_formatter.rb'
5
+ require_relative 'parse.rb'
6
+
data/lib/parse.rb ADDED
@@ -0,0 +1,57 @@
1
+ class LittleRecipeParser::Parse
2
+ attr_accessor :raw_ingredient, :measurement, :quantity, :tag
3
+
4
+ def initialize(string)
5
+ @raw_ingredient = string
6
+ @tag = LittleRecipeParser::GroceryListFormatter.check_name(raw_ingredient)
7
+ @measurement = get_measurement
8
+ @quantity = get_quantity
9
+ end
10
+
11
+ def persisted?
12
+ false
13
+ end
14
+
15
+ def get_quantity
16
+ qtys = raw_ingredient[0..8].split.select do |char|
17
+ char =~ /[[:digit:]]/
18
+ end
19
+ joined_qty = qtys.join(' ')
20
+ if joined_qty.include?('(')
21
+ joined_qty = joined_qty.partition('(').first.strip
22
+ end
23
+ if joined_qty == ""
24
+ return nil
25
+ else
26
+ joined_qty
27
+ end
28
+ end
29
+
30
+ def get_measurement
31
+ measurements = acceptable_measurements.select do |measure|
32
+ raw_ingredient.downcase.include?(measure.downcase)
33
+ end
34
+ if measurements.any?
35
+ answer = measurements.first.strip
36
+ else
37
+ answer = check_secondary_measurements
38
+ end
39
+ end
40
+
41
+ def check_secondary_measurements
42
+ secondary_measurements.select do |measure|
43
+ raw_ingredient.downcase.include?(measure.downcase)
44
+ end.first.try(:strip)
45
+ end
46
+
47
+ def acceptable_measurements
48
+ ['teaspoon', 'teaspoons', ' t ', 'tsp', ' cup ', 'cups', ' pound ', 'pounds', ' tablespoon ',
49
+ 'tablespoons', 'tbl', 'tbs', 'tbsp', 'ounce ', 'ounces', ' oz ', 'fl oz', ' pint ', 'pints', ' quart ', 'quarts',
50
+ 'gallon', 'gallons', ' ml ', 'liter', 'litre', ' l ', 'dash']
51
+ end
52
+
53
+ def secondary_measurements
54
+ ['strip', 'strips', 'package', 'can ', 'cans', 'bunch ', 'bunches']
55
+ end
56
+
57
+ end
@@ -0,0 +1,68 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "little-recipe-parser"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Meeka"]
12
+ s.date = "2014-02-15"
13
+ s.description = "Recipe Parsing Gem - Simply run LittleRecipeParser::Parse.new('1 pound of chicken') - you can then call .quantity, .tag or .measurement on the string"
14
+ s.email = "rrgayhart@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/grocery_list_formatter.rb",
28
+ "lib/little-recipe-parser.rb",
29
+ "lib/parse.rb",
30
+ "little-recipe-parser.gemspec",
31
+ "test/helper.rb",
32
+ "test/test_grocery_list_formatter.rb",
33
+ "test/test_parse.rb"
34
+ ]
35
+ s.homepage = "http://github.com/rrgayhart/little-recipe-parser"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "2.0.3"
39
+ s.summary = "Recipe Parsing Gem"
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 4
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
46
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
47
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
50
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<activesupport>, [">= 0"])
53
+ s.add_dependency(%q<shoulda>, [">= 0"])
54
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
56
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
57
+ s.add_dependency(%q<simplecov>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<activesupport>, [">= 0"])
61
+ s.add_dependency(%q<shoulda>, [">= 0"])
62
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
65
+ s.add_dependency(%q<simplecov>, [">= 0"])
66
+ end
67
+ end
68
+
data/test/helper.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ require 'rubygems'
18
+ require 'bundler'
19
+ begin
20
+ Bundler.setup(:default, :development)
21
+ rescue Bundler::BundlerError => e
22
+ $stderr.puts e.message
23
+ $stderr.puts "Run `bundle install` to install missing gems"
24
+ exit e.status_code
25
+ end
26
+ require 'test/unit'
27
+ require 'shoulda'
28
+
29
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
31
+ require 'little-recipe-parser'
32
+
33
+ class Test::Unit::TestCase
34
+ end
@@ -0,0 +1,44 @@
1
+ require 'helper'
2
+
3
+ class GroceryListFormatterTest < Test::Unit::TestCase
4
+
5
+ should "it handles edge cases" do
6
+ assert_equal "Corn", check_name('1 cup of corn')
7
+ assert_equal "Black Peppercorn", check_name('8 black peppercorns')
8
+ assert_equal "Red Wine Vinegar", check_name("1 cup red wine vinegar")
9
+ assert_equal "Cloves", check_name("1 tablespoon of cloves")
10
+ assert_equal "Salt and Pepper", check_name("salt and pepper")
11
+ assert_equal "Olive Oil", check_name("2 tablespoons olive oil")
12
+ assert_equal "Pearl Onion", check_name("8 ounces white or yellow pearl onions")
13
+ assert_equal "Pork Loin", check_name("4 boneless pork loin cutlets, 6-8 ounces each")
14
+ assert_equal "Agave Syrup", check_name('1 1/2 tsp agave syrup')
15
+ assert_equal "Fresh Ginger", check_name('1-inch (3cm) piece fresh ginger, peeled and minced')
16
+ assert_equal "Powdered Ginger", check_name('1-inch tsp powdered ginger')
17
+ assert_equal "Tofu", check_name("1 (12 ounce) package soft tofu, drained and cut into 1/2-inch cubes")
18
+ end
19
+
20
+ should "it handles odd pluralization" do
21
+ assert_equal "Pancetta", check_name("1 cup pancetta, finely diced")
22
+ assert_equal "Bay Leaves", check_name('2 bay leaves')
23
+ end
24
+
25
+ should "it handles juice" do
26
+ assert_equal "Lime", check_name("juice from 2 limes")
27
+ end
28
+
29
+ should "it handles veggies" do
30
+ assert_equal "Bean Sprouts", check_name("3 cups bean sprouts")
31
+ assert_equal "Watercress", check_name('1 bunch watercress, chopped')
32
+ assert_equal "Tomato", check_name('2 tomatoes, cubed')
33
+ assert_equal "Radish", check_name('1/4 cup Japanese pickled radish (optional)')
34
+ end
35
+
36
+ should "it handles meat" do
37
+ assert_equal "Tuna", check_name('2 (6 ounce) cans tuna, drained')
38
+ end
39
+
40
+ def check_name(string)
41
+ LittleRecipeParser::GroceryListFormatter.check_name(string)
42
+ end
43
+
44
+ end
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+
3
+ class ParseTest < Test::Unit::TestCase
4
+
5
+ should 'return formatted answer' do
6
+ parse = LittleRecipeParser::Parse.new('1 pound of chicken')
7
+ assert_equal '1', parse.quantity
8
+ assert_equal 'pound', parse.measurement
9
+ assert_equal 'Chicken', parse.tag
10
+ end
11
+
12
+ should 'it handles normal cases' do
13
+ assert_equal 'pound', method_measurement('1 pound chicken')
14
+ assert_equal 'cups', method_measurement("3 cups bean sprouts")
15
+ end
16
+
17
+ should 'it handles edge cases' do
18
+ assert_equal 'strip', method_measurement('8 strips thick-cut bacon')
19
+ assert_equal 'package', method_measurement('1 (12 ounce) package soft tofu, drained and cut into 1/2-inch cubes')
20
+ assert_equal 'cans', method_measurement('2 (6 ounce) cans tuna, drained')
21
+ assert_equal 'bunch', method_measurement('1 bunch watercress, chopped')
22
+ end
23
+
24
+ should 'it handles quantity edge cases' do
25
+ assert_equal '1', method_quantity("1 (12 ounce) package soft tofu, drained and cut into 1/2-inch cubes")
26
+ assert_equal '2', method_quantity('2 (6 ounce) cans tuna, drained')
27
+ end
28
+
29
+ def method_measurement(string)
30
+ parse = LittleRecipeParser::Parse.new(string)
31
+ parse.get_measurement
32
+ end
33
+
34
+ def method_quantity(string)
35
+ parse = LittleRecipeParser::Parse.new(string)
36
+ parse.get_quantity
37
+ end
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: little-recipe-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Meeka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: shoulda
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Recipe Parsing Gem - Simply run LittleRecipeParser::Parse.new('1 pound
98
+ of chicken') - you can then call .quantity, .tag or .measurement on the string
99
+ email: rrgayhart@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files:
103
+ - LICENSE.txt
104
+ - README.md
105
+ files:
106
+ - .document
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - VERSION
113
+ - lib/grocery_list_formatter.rb
114
+ - lib/little-recipe-parser.rb
115
+ - lib/parse.rb
116
+ - little-recipe-parser.gemspec
117
+ - test/helper.rb
118
+ - test/test_grocery_list_formatter.rb
119
+ - test/test_parse.rb
120
+ homepage: http://github.com/rrgayhart/little-recipe-parser
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.0.3
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Recipe Parsing Gem
144
+ test_files: []