emeals 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/lib/emeals/dish.rb +3 -1
- data/lib/emeals/meal.rb +7 -3
- data/lib/emeals/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2ca2974e3a5de77a5e8d5223fce6c7edbda70a3
|
4
|
+
data.tar.gz: a5c7e5b51181b5fef5a28390519e4048d21862b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c82784dbada386ed2fc80352864c0d5c92b1112bbb13bb0c43eeb766b93b05c3a7d82f5983512a43fe2619aa4f5e2e92e1035a2cdbc134bd871bd18a5846e372
|
7
|
+
data.tar.gz: 265d9d04f9dd1695b751b72228fc4a65f8664494d62b5d1f3e1af0a8f86b559597a1c5d220f76f6ac0cccdbc262a6903ffe0183fd6a93abce753c7a7a25f8c76
|
data/lib/emeals/dish.rb
CHANGED
@@ -31,6 +31,7 @@ class Emeals::Quantity
|
|
31
31
|
case str
|
32
32
|
when "\xC2\xBC"; '1/4'
|
33
33
|
when "\xC2\xBD"; '1/2'
|
34
|
+
when "\xC2\xBE"; '3/4'
|
34
35
|
else str
|
35
36
|
end.to_r
|
36
37
|
end
|
@@ -44,7 +45,8 @@ class Emeals::Ingredient
|
|
44
45
|
@description = description
|
45
46
|
end
|
46
47
|
|
47
|
-
|
48
|
+
NUMBER_PATTERN = /\d|\xC2\xBC|\xC2\xBD|\xC2\xBE/
|
49
|
+
PARSE_REGEX = /((?:#{NUMBER_PATTERN})+) (?:(#{Emeals::Quantity::UNITS_WITH_PLURALS.join("|")}) )?(.+)/
|
48
50
|
|
49
51
|
def self.parse(line)
|
50
52
|
if line =~ PARSE_REGEX
|
data/lib/emeals/meal.rb
CHANGED
@@ -114,7 +114,7 @@ class Emeals::MealParser
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def parse_side_ingredients(line, ingredients)
|
117
|
-
if line =~ /^[A-Z]/
|
117
|
+
if line =~ /^[A-Z]/ and not line =~ /^Zest/
|
118
118
|
[ingredients, [line], :entree_instructions]
|
119
119
|
else
|
120
120
|
[find_ingredients(ingredients, line), nil, :side_ingredients]
|
@@ -137,13 +137,17 @@ class Emeals::MealParser
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
|
140
|
+
NUMBER_PATTERN = Emeals::Ingredient::NUMBER_PATTERN
|
141
|
+
INGREDIENT_REGEX = /(?:#{NUMBER_PATTERN})+ .+?(?=, (?:#{NUMBER_PATTERN})+|$)/
|
141
142
|
|
142
143
|
def find_ingredients(ingredients, line)
|
143
|
-
if line =~
|
144
|
+
if line =~ /^#{NUMBER_PATTERN}/
|
144
145
|
ingredients + line.scan(INGREDIENT_REGEX).map do |match|
|
145
146
|
Emeals::Ingredient.parse(match)
|
146
147
|
end
|
148
|
+
elsif line =~/^Zest/
|
149
|
+
# Special case this
|
150
|
+
ingredients + [Emeals::Ingredient.new(1, nil, line)]
|
147
151
|
else
|
148
152
|
# TODO we shouldn't be modifying this in-place
|
149
153
|
ingredients.last.description << " #{line}"
|
data/lib/emeals/version.rb
CHANGED