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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88f64929d0e17e3a429aef954e2508bf354afb6c
4
- data.tar.gz: 7811beff315cd7d5b8a06720f1b696611f4a1658
3
+ metadata.gz: a2ca2974e3a5de77a5e8d5223fce6c7edbda70a3
4
+ data.tar.gz: a5c7e5b51181b5fef5a28390519e4048d21862b3
5
5
  SHA512:
6
- metadata.gz: ba0a4c7c3ea79ba9a535569d33b97ac40429341d4fa219f908e02a35dd068c8852469486d0537e87e2845f521abf33a14b15e0127da7a0dd75849bea44083e1f
7
- data.tar.gz: 9056e857a31afc51ad2ac0429a26c6f70a3ed51566c7d0097b2dc560c36c3426632a4a0054546d63f949b7e2ac090223d3e3557cd691c9fbebac3729eae1f547
6
+ metadata.gz: c82784dbada386ed2fc80352864c0d5c92b1112bbb13bb0c43eeb766b93b05c3a7d82f5983512a43fe2619aa4f5e2e92e1035a2cdbc134bd871bd18a5846e372
7
+ data.tar.gz: 265d9d04f9dd1695b751b72228fc4a65f8664494d62b5d1f3e1af0a8f86b559597a1c5d220f76f6ac0cccdbc262a6903ffe0183fd6a93abce753c7a7a25f8c76
@@ -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
- PARSE_REGEX = /((?:\d|\xC2\xBC|\xC2\xBD)+) (?:(#{Emeals::Quantity::UNITS_WITH_PLURALS.join("|")}) )?(.+)/
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
@@ -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
- INGREDIENT_REGEX = /(?:\d|\xC2\xBC|\xC2\xBD)+ .+?(?=, (?:\d|\xC2\xBC|\xC2\xBD)+|$)/
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 =~ /^\d|\xC2\xBC|\xC2\xBD/
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}"
@@ -1,3 +1,3 @@
1
1
  module Emeals
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emeals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Moriarity