eye-of-newt 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a593b4f889ec78c7e789daba91965f94f9419810
4
- data.tar.gz: f341eda16d664a480c92dbb5efbf65bfdf64873c
3
+ metadata.gz: a22153a502ff31dcf2c78bbc353759a09e3a972d
4
+ data.tar.gz: 9942d74541ae7d441540ef11c99ef39d44a106c0
5
5
  SHA512:
6
- metadata.gz: 00a299e06e879fdf92dc3ff06899494575fa77df6b549726a6bb4c4756b0680be936e765c2529da3a6f9d04a1566989002fc2df5a95106faf7683945a7b49ec5
7
- data.tar.gz: 23bbf21df97753bbfe355adbf9a95c4177baa764ab1adf7e9c64fcb21f3620009c552de652eae07356e25eb7116750e3892b73ec78d36fb5002242546d5d6252
6
+ metadata.gz: cf13232d805fc460a0e5accb943d6841fa17b9ad3eb7ccc5d11eb1d4e93dac5b5408a31ea5afa3c6be1ab38903b6aa32f8b3b48e3e3b14f133b33ea5e993de48
7
+ data.tar.gz: 677735c13e5b2d58cae5523c86fef5a2d328166e9cedef99682a47612999c59d75d8f635b4481a328a131b7630b96cfd6a354c2ddadd355b3f4577fee3e72723
@@ -1,14 +1,22 @@
1
1
  module EyeOfNewt
2
2
  class Ingredient
3
- attr_accessor :amount, :unit, :unit_modifier, :name, :style, :note
3
+ attr_accessor :amount, :unit, :unit_modifier, :names, :style, :note
4
4
 
5
- def initialize(amount: nil, unit: nil, unit_modifier: nil, name: nil, style: nil, note: nil)
5
+ def initialize(amount: nil, unit: nil, unit_modifier: nil, names: [], style: nil, note: nil)
6
6
  self.amount = amount
7
7
  self.unit = unit
8
8
  self.unit_modifier = unit_modifier
9
- self.name = name
9
+ self.names = names
10
10
  self.style = style
11
11
  self.note = note
12
12
  end
13
+
14
+ def name
15
+ names.first
16
+ end
17
+
18
+ def name=(n)
19
+ self.names = [n]
20
+ end
13
21
  end
14
22
  end
@@ -37,117 +37,121 @@ module EyeOfNewt
37
37
  ##### State transition tables begin ###
38
38
 
39
39
  racc_action_table = [
40
- -45, 42, 18, 20, 11, 40, 19, 10, -45, 12,
41
- -45, 13, 18, 11, -33, 33, 19, 23, 34, 24,
42
- 13, 18, 11, 46, 55, 19, 23, 28, 24, 29,
43
- 30, 37, 38, 29, 30, 44, 45, 29, 30, 36,
44
- 11, 30, 40, 40, 21, 56, 57, 20, 20, 60,
45
- 44, 61, 62, 30, 30, 65, 66 ]
40
+ -47, 44, 19, 21, 12, 42, 20, -47, 11, -47,
41
+ 13, -47, 14, 19, 19, 39, 40, 20, 20, 24,
42
+ 24, 25, 25, 19, 12, -35, 35, 20, 48, 24,
43
+ 36, 25, 14, 29, 38, 30, 31, 12, 12, 58,
44
+ 30, 31, 46, 47, 30, 31, 31, 42, 42, 32,
45
+ 22, 59, 60, 21, 21, 63, 46, 64, 65, 31,
46
+ 31, 68, 69 ]
46
47
 
47
48
  racc_action_check = [
48
- 10, 14, 0, 0, 0, 13, 0, 0, 10, 0,
49
- 10, 0, 2, 5, 12, 5, 2, 2, 5, 2,
50
- 5, 17, 31, 21, 31, 17, 17, 3, 17, 3,
51
- 3, 8, 8, 22, 22, 20, 20, 25, 25, 7,
52
- 6, 26, 29, 30, 1, 32, 35, 37, 38, 39,
53
- 42, 44, 45, 47, 49, 53, 54 ]
49
+ 11, 15, 0, 0, 0, 14, 0, 11, 0, 11,
50
+ 0, 11, 0, 2, 18, 9, 9, 2, 18, 2,
51
+ 18, 2, 18, 32, 6, 13, 6, 32, 22, 32,
52
+ 6, 32, 6, 3, 8, 3, 3, 33, 7, 33,
53
+ 23, 23, 21, 21, 26, 26, 27, 30, 31, 4,
54
+ 1, 34, 37, 39, 40, 41, 44, 46, 47, 49,
55
+ 51, 55, 57 ]
54
56
 
55
57
  racc_action_pointer = [
56
- 0, 44, 10, 19, nil, 9, 36, 33, 18, nil,
57
- 0, nil, 10, 0, -2, nil, nil, 19, nil, nil,
58
- 20, 23, 23, nil, nil, 27, 30, nil, nil, 37,
59
- 38, 18, 39, nil, nil, 40, nil, 44, 45, 37,
60
- nil, nil, 35, nil, 48, 49, nil, 42, nil, 43,
61
- nil, nil, nil, 43, 50, nil, nil, nil, nil, nil,
62
- nil, nil, nil, nil, nil, nil, nil ]
58
+ 0, 50, 11, 24, 42, nil, 20, 34, 28, 1,
59
+ nil, 0, nil, 21, 0, -2, nil, nil, 12, nil,
60
+ nil, 26, 28, 29, nil, nil, 33, 34, nil, nil,
61
+ 42, 43, 21, 33, 45, nil, nil, 46, nil, 50,
62
+ 51, 42, nil, nil, 40, nil, 54, 55, nil, 47,
63
+ nil, 48, nil, nil, nil, 48, nil, 56, nil, nil,
64
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
63
65
 
64
66
  racc_action_default = [
65
- -51, -51, -51, -12, -13, -21, -51, -25, -26, -27,
66
- -28, -29, -47, -51, -37, -39, -40, -42, -44, -46,
67
- -48, -51, -8, -45, -47, -10, -11, -6, -30, -51,
68
- -51, -19, -17, -20, -33, -23, -24, -51, -51, -51,
69
- -43, -38, -51, -41, -51, -51, 67, -7, -2, -9,
70
- -4, -5, -31, -51, -15, -18, -16, -22, -35, -36,
71
- -34, -49, -50, -1, -3, -32, -14 ]
67
+ -53, -53, -53, -12, -14, -15, -23, -53, -27, -28,
68
+ -29, -30, -31, -49, -53, -39, -41, -42, -44, -46,
69
+ -48, -50, -53, -8, -47, -49, -10, -11, -6, -32,
70
+ -53, -53, -53, -21, -19, -22, -35, -25, -26, -53,
71
+ -53, -53, -45, -40, -53, -43, -53, -53, 70, -7,
72
+ -2, -9, -4, -5, -33, -53, -13, -17, -20, -18,
73
+ -24, -37, -38, -36, -51, -52, -1, -3, -34, -16 ]
72
74
 
73
75
  racc_goto_table = [
74
- 27, 8, 7, 5, 39, 26, 6, 32, 35, 43,
75
- 3, 31, 22, 25, 1, 9, 2, 41, nil, 48,
76
- 52, 53, 50, 51, 47, nil, nil, 49, nil, nil,
77
- nil, nil, nil, 54, nil, nil, nil, nil, 58, 59,
78
- nil, nil, nil, nil, 63, nil, 64 ]
76
+ 28, 9, 8, 6, 3, 27, 23, 7, 34, 37,
77
+ 41, 45, 26, 33, 1, 10, 2, 43, nil, nil,
78
+ 50, nil, nil, 52, 53, 49, 54, 55, 51, nil,
79
+ nil, nil, nil, nil, nil, 57, 56, nil, nil, nil,
80
+ 61, 62, nil, nil, nil, nil, 66, nil, 67 ]
79
81
 
80
82
  racc_goto_check = [
81
- 5, 11, 10, 8, 13, 4, 9, 10, 10, 7,
82
- 3, 9, 3, 6, 1, 12, 2, 15, nil, 5,
83
- 13, 13, 5, 5, 4, nil, nil, 4, nil, nil,
84
- nil, nil, nil, 10, nil, nil, nil, nil, 11, 11,
85
- nil, nil, nil, nil, 5, nil, 5 ]
83
+ 5, 12, 11, 9, 3, 4, 3, 10, 11, 11,
84
+ 14, 8, 6, 10, 1, 13, 2, 16, nil, nil,
85
+ 5, nil, nil, 5, 5, 4, 14, 14, 4, nil,
86
+ nil, nil, nil, nil, nil, 11, 3, nil, nil, nil,
87
+ 12, 12, nil, nil, nil, nil, 5, nil, 5 ]
86
88
 
87
89
  racc_goto_pointer = [
88
- nil, 14, 16, 10, 2, -3, 10, -8, 3, 6,
89
- 2, 1, 15, -9, nil, 3, nil, nil ]
90
+ nil, 14, 16, 4, 2, -3, 9, nil, -7, 3,
91
+ 7, 2, 1, 15, -4, nil, 2, nil, nil ]
90
92
 
91
93
  racc_goto_default = [
92
- nil, nil, nil, nil, nil, nil, nil, 4, nil, nil,
93
- nil, nil, nil, nil, 14, 15, 16, 17 ]
94
+ nil, nil, nil, nil, nil, nil, nil, 4, 5, nil,
95
+ nil, nil, nil, nil, nil, 15, 16, 17, 18 ]
94
96
 
95
97
  racc_reduce_table = [
96
98
  0, 0, :racc_error,
97
- 4, 18, :_reduce_none,
98
- 3, 18, :_reduce_none,
99
- 4, 18, :_reduce_none,
100
- 3, 18, :_reduce_none,
101
- 3, 18, :_reduce_none,
102
- 2, 18, :_reduce_none,
103
- 3, 18, :_reduce_none,
104
- 2, 18, :_reduce_none,
105
- 3, 18, :_reduce_none,
106
- 2, 18, :_reduce_none,
107
- 2, 18, :_reduce_none,
108
- 1, 18, :_reduce_none,
109
- 1, 20, :_reduce_13,
110
99
  4, 19, :_reduce_none,
111
100
  3, 19, :_reduce_none,
101
+ 4, 19, :_reduce_none,
112
102
  3, 19, :_reduce_none,
113
- 2, 19, :_reduce_none,
114
103
  3, 19, :_reduce_none,
115
104
  2, 19, :_reduce_none,
105
+ 3, 19, :_reduce_none,
116
106
  2, 19, :_reduce_none,
117
- 1, 19, :_reduce_none,
118
107
  3, 19, :_reduce_none,
119
108
  2, 19, :_reduce_none,
120
109
  2, 19, :_reduce_none,
121
110
  1, 19, :_reduce_none,
122
- 1, 25, :_reduce_26,
123
- 1, 25, :_reduce_27,
124
- 1, 25, :_reduce_28,
111
+ 3, 21, :_reduce_none,
112
+ 1, 21, :_reduce_none,
113
+ 1, 25, :_reduce_15,
114
+ 4, 20, :_reduce_none,
115
+ 3, 20, :_reduce_none,
116
+ 3, 20, :_reduce_none,
117
+ 2, 20, :_reduce_none,
118
+ 3, 20, :_reduce_none,
119
+ 2, 20, :_reduce_none,
120
+ 2, 20, :_reduce_none,
121
+ 1, 20, :_reduce_none,
122
+ 3, 20, :_reduce_none,
123
+ 2, 20, :_reduce_none,
124
+ 2, 20, :_reduce_none,
125
+ 1, 20, :_reduce_none,
126
+ 1, 27, :_reduce_28,
125
127
  1, 27, :_reduce_29,
126
- 1, 23, :_reduce_30,
127
- 2, 21, :_reduce_31,
128
- 3, 22, :_reduce_32,
129
- 1, 26, :_reduce_33,
130
- 3, 26, :_reduce_34,
131
- 3, 29, :_reduce_35,
132
- 3, 29, :_reduce_36,
133
- 1, 28, :_reduce_none,
134
- 2, 28, :_reduce_38,
135
- 1, 28, :_reduce_none,
136
- 1, 28, :_reduce_none,
137
- 2, 24, :_reduce_41,
138
- 1, 24, :_reduce_none,
128
+ 1, 27, :_reduce_30,
129
+ 1, 29, :_reduce_31,
130
+ 1, 24, :_reduce_32,
131
+ 2, 22, :_reduce_33,
132
+ 3, 23, :_reduce_34,
133
+ 1, 28, :_reduce_35,
134
+ 3, 28, :_reduce_36,
135
+ 3, 31, :_reduce_37,
136
+ 3, 31, :_reduce_38,
137
+ 1, 30, :_reduce_none,
138
+ 2, 30, :_reduce_40,
139
+ 1, 30, :_reduce_none,
139
140
  1, 30, :_reduce_none,
140
- 1, 34, :_reduce_none,
141
- 1, 34, :_reduce_none,
142
- 1, 34, :_reduce_none,
143
- 1, 34, :_reduce_none,
144
- 1, 31, :_reduce_48,
145
- 3, 32, :_reduce_49,
146
- 3, 33, :_reduce_50 ]
141
+ 2, 26, :_reduce_43,
142
+ 1, 26, :_reduce_none,
143
+ 1, 32, :_reduce_none,
144
+ 1, 36, :_reduce_none,
145
+ 1, 36, :_reduce_none,
146
+ 1, 36, :_reduce_none,
147
+ 1, 36, :_reduce_none,
148
+ 1, 33, :_reduce_50,
149
+ 3, 34, :_reduce_51,
150
+ 3, 35, :_reduce_52 ]
147
151
 
148
- racc_reduce_n = 51
152
+ racc_reduce_n = 53
149
153
 
150
- racc_shift_n = 67
154
+ racc_shift_n = 70
151
155
 
152
156
  racc_token_table = {
153
157
  false => 0,
@@ -157,18 +161,19 @@ racc_token_table = {
157
161
  :UNIT => 4,
158
162
  :TEXT => 5,
159
163
  :OF => 6,
160
- :A => 7,
161
- :TO_TASTE => 8,
162
- :UNIT_MODIFIER => 9,
163
- "," => 10,
164
- "(" => 11,
165
- ")" => 12,
166
- "-" => 13,
167
- "\u{2013}" => 14,
168
- "/" => 15,
169
- "." => 16 }
170
-
171
- racc_nt_base = 17
164
+ :OR => 7,
165
+ :A => 8,
166
+ :TO_TASTE => 9,
167
+ :UNIT_MODIFIER => 10,
168
+ "," => 11,
169
+ "(" => 12,
170
+ ")" => 13,
171
+ "-" => 14,
172
+ "\u{2013}" => 15,
173
+ "/" => 16,
174
+ "." => 17 }
175
+
176
+ racc_nt_base = 18
172
177
 
173
178
  racc_use_result_var = true
174
179
 
@@ -196,6 +201,7 @@ Racc_token_to_s_table = [
196
201
  "UNIT",
197
202
  "TEXT",
198
203
  "OF",
204
+ "OR",
199
205
  "A",
200
206
  "TO_TASTE",
201
207
  "UNIT_MODIFIER",
@@ -209,11 +215,12 @@ Racc_token_to_s_table = [
209
215
  "$start",
210
216
  "ingredient",
211
217
  "quantity",
212
- "ingredient_name",
218
+ "ingredient_names",
213
219
  "style",
214
220
  "note",
215
221
  "to_taste",
216
- "words",
222
+ "ingredient_name",
223
+ "ingredient_words",
217
224
  "amount",
218
225
  "unit_modifier",
219
226
  "unit",
@@ -223,7 +230,7 @@ Racc_token_to_s_table = [
223
230
  "number",
224
231
  "fraction",
225
232
  "decimal",
226
- "word" ]
233
+ "ingredient_word" ]
227
234
 
228
235
  Racc_debug_parser = false
229
236
 
@@ -255,14 +262,14 @@ Racc_debug_parser = false
255
262
 
256
263
  # reduce 12 omitted
257
264
 
258
- def _reduce_13(val, _values, result)
259
- @ingredient.name = result
260
- result
261
- end
265
+ # reduce 13 omitted
262
266
 
263
267
  # reduce 14 omitted
264
268
 
265
- # reduce 15 omitted
269
+ def _reduce_15(val, _values, result)
270
+ @ingredient.names << result
271
+ result
272
+ end
266
273
 
267
274
  # reduce 16 omitted
268
275
 
@@ -284,81 +291,81 @@ end
284
291
 
285
292
  # reduce 25 omitted
286
293
 
287
- def _reduce_26(val, _values, result)
294
+ # reduce 26 omitted
295
+
296
+ # reduce 27 omitted
297
+
298
+ def _reduce_28(val, _values, result)
288
299
  @ingredient.amount = result
289
300
  result
290
301
  end
291
302
 
292
- def _reduce_27(val, _values, result)
303
+ def _reduce_29(val, _values, result)
293
304
  @ingredient.amount = result
294
305
  result
295
306
  end
296
307
 
297
- def _reduce_28(val, _values, result)
308
+ def _reduce_30(val, _values, result)
298
309
  @ingredient.amount = 1
299
310
  result
300
311
  end
301
312
 
302
- def _reduce_29(val, _values, result)
313
+ def _reduce_31(val, _values, result)
303
314
  @ingredient.unit = to_unit(result)
304
315
  result
305
316
  end
306
317
 
307
- def _reduce_30(val, _values, result)
318
+ def _reduce_32(val, _values, result)
308
319
  @ingredient.unit = to_unit(result)
309
320
  result
310
321
  end
311
322
 
312
- def _reduce_31(val, _values, result)
323
+ def _reduce_33(val, _values, result)
313
324
  @ingredient.style = val[1]
314
325
  result
315
326
  end
316
327
 
317
- def _reduce_32(val, _values, result)
328
+ def _reduce_34(val, _values, result)
318
329
  @ingredient.note = val[1]
319
330
  result
320
331
  end
321
332
 
322
- def _reduce_33(val, _values, result)
333
+ def _reduce_35(val, _values, result)
323
334
  @ingredient.unit_modifier = val[0]
324
335
  result
325
336
  end
326
337
 
327
- def _reduce_34(val, _values, result)
338
+ def _reduce_36(val, _values, result)
328
339
  @ingredient.unit_modifier = val[1]
329
340
  result
330
341
  end
331
342
 
332
- def _reduce_35(val, _values, result)
343
+ def _reduce_37(val, _values, result)
333
344
  result = [val[0], val[2]]
334
345
  result
335
346
  end
336
347
 
337
- def _reduce_36(val, _values, result)
348
+ def _reduce_38(val, _values, result)
338
349
  result = [val[0], val[2]]
339
350
  result
340
351
  end
341
352
 
342
- # reduce 37 omitted
353
+ # reduce 39 omitted
343
354
 
344
- def _reduce_38(val, _values, result)
355
+ def _reduce_40(val, _values, result)
345
356
  result = val[0] + val[1]
346
357
  result
347
358
  end
348
359
 
349
- # reduce 39 omitted
360
+ # reduce 41 omitted
350
361
 
351
- # reduce 40 omitted
362
+ # reduce 42 omitted
352
363
 
353
- def _reduce_41(val, _values, result)
364
+ def _reduce_43(val, _values, result)
354
365
  result = val.join(' ')
355
366
  result
356
367
  end
357
368
 
358
- # reduce 42 omitted
359
-
360
- # reduce 43 omitted
361
-
362
369
  # reduce 44 omitted
363
370
 
364
371
  # reduce 45 omitted
@@ -367,17 +374,21 @@ end
367
374
 
368
375
  # reduce 47 omitted
369
376
 
370
- def _reduce_48(val, _values, result)
377
+ # reduce 48 omitted
378
+
379
+ # reduce 49 omitted
380
+
381
+ def _reduce_50(val, _values, result)
371
382
  result = val[0].to_i
372
383
  result
373
384
  end
374
385
 
375
- def _reduce_49(val, _values, result)
386
+ def _reduce_51(val, _values, result)
376
387
  result = val[0].to_f / val[2].to_f
377
388
  result
378
389
  end
379
390
 
380
- def _reduce_50(val, _values, result)
391
+ def _reduce_52(val, _values, result)
381
392
  result = val.join.to_f
382
393
  result
383
394
  end
@@ -1,22 +1,26 @@
1
1
  class EyeOfNewt::Parser
2
- token WORD NUMBER UNIT TEXT OF A TO_TASTE UNIT_MODIFIER
2
+ token WORD NUMBER UNIT TEXT OF OR A TO_TASTE UNIT_MODIFIER
3
3
  rule
4
4
  ingredient
5
- : quantity ingredient_name style note
6
- | quantity ingredient_name note
7
- | ingredient_name to_taste style note
8
- | ingredient_name to_taste note
9
- | ingredient_name style note
10
- | ingredient_name note
11
- | quantity ingredient_name style
12
- | quantity ingredient_name
13
- | ingredient_name to_taste style
14
- | ingredient_name to_taste
15
- | ingredient_name style
5
+ : quantity ingredient_names style note
6
+ | quantity ingredient_names note
7
+ | ingredient_names to_taste style note
8
+ | ingredient_names to_taste note
9
+ | ingredient_names style note
10
+ | ingredient_names note
11
+ | quantity ingredient_names style
12
+ | quantity ingredient_names
13
+ | ingredient_names to_taste style
14
+ | ingredient_names to_taste
15
+ | ingredient_names style
16
+ | ingredient_names
17
+ ;
18
+ ingredient_names
19
+ : ingredient_name OR ingredient_names
16
20
  | ingredient_name
17
21
  ;
18
22
  ingredient_name
19
- : words { @ingredient.name = result }
23
+ : ingredient_words { @ingredient.names << result }
20
24
  ;
21
25
  quantity
22
26
  : amount unit_modifier unit OF
@@ -55,12 +59,12 @@ rule
55
59
  | fraction
56
60
  | decimal
57
61
  ;
58
- words
59
- : word words { result = val.join(' ') }
60
- | word
62
+ ingredient_words
63
+ : ingredient_word ingredient_words { result = val.join(' ') }
64
+ | ingredient_word
61
65
  ;
62
66
  text : TEXT ;
63
- word : WORD | A | OF | UNIT_MODIFIER ;
67
+ ingredient_word : WORD | A | OF | UNIT_MODIFIER ;
64
68
  number : NUMBER { result = val[0].to_i } ;
65
69
  fraction : NUMBER '/' NUMBER { result = val[0].to_f / val[2].to_f } ;
66
70
  decimal : NUMBER '.' NUMBER { result = val.join.to_f } ;
@@ -9,6 +9,7 @@ module EyeOfNewt
9
9
  WORD = /\w+(-\w+)*/
10
10
  NUMBER = /\d+/
11
11
  OF = /of/
12
+ OR = /or/
12
13
  A = /an?/
13
14
  TO_TASTE = /to taste/
14
15
 
@@ -36,6 +37,8 @@ module EyeOfNewt
36
37
  [:OF, text]
37
38
  when text = @ss.scan(/#{A}\b/)
38
39
  [:A, text]
40
+ when text = @ss.scan(/#{OR}\b/)
41
+ [:OR, text]
39
42
  when text = @ss.scan(/#{TO_TASTE}\b/)
40
43
  [:TO_TASTE, text]
41
44
  when text = @ss.scan(/#{unit_matcher}\b/)
@@ -1,3 +1,3 @@
1
1
  module EyeOfNewt
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -27,3 +27,4 @@ heaping tablespoon of sugar | sugar | 1 | tbsp | | | heaping
27
27
  1 pound of large beans | large beans | 1 | lb
28
28
  4-5 handfuls of spinach, very roughly chopped | spinach | 4-5 | handfuls | very roughly chopped
29
29
  1 (46 oz) can tomato juice | tomato juice | 1 | cans | | | 46 oz
30
+ kale or chard or spinach | kale,chard,spinach | 1 | units
@@ -59,6 +59,14 @@ class EyeOfNewt::TokenizerTest < ActiveSupport::TestCase
59
59
  assert_nil t.next_token
60
60
  end
61
61
 
62
+ test "tokenizes OR" do
63
+ t = tok("this or that")
64
+ assert_equal [:WORD, "this"], t.next_token
65
+ assert_equal [:OR, "or"], t.next_token
66
+ assert_equal [:WORD, "that"], t.next_token
67
+ assert_nil t.next_token
68
+ end
69
+
62
70
  test "tokenizes fractions" do
63
71
  t = tok("1 1/2")
64
72
  assert_equal [:NUMBER, "1"], t.next_token
@@ -11,14 +11,14 @@ class EyeOfNewtTest < ActiveSupport::TestCase
11
11
 
12
12
  tokens = line.split('|').map(&:strip)
13
13
  line = tokens.shift
14
- name = tokens.shift
14
+ names = tokens.shift.split(',').map(&:strip)
15
15
  amount = tokens.shift.split('-').map(&:to_f)
16
16
  amount = amount.first unless amount.many?
17
17
  unit = tokens.shift.presence
18
18
  style = tokens.shift.presence
19
19
  note = tokens.shift.presence
20
20
  unit_modifier = tokens.shift.presence
21
- expected = [name, amount, unit, style, note, unit_modifier]
21
+ expected = [names, amount, unit, style, note, unit_modifier]
22
22
  [line, expected]
23
23
  }.compact
24
24
  end
@@ -27,8 +27,8 @@ class EyeOfNewtTest < ActiveSupport::TestCase
27
27
  examples.each do |line, expected|
28
28
  test "parses #{line} correctly" do
29
29
  ingr = EyeOfNewt.parse(line)
30
- name, amount, unit, style, note, unit_modifier = *expected
31
- assert_equal name, ingr.name, %Q{incorrect name}
30
+ names, amount, unit, style, note, unit_modifier = *expected
31
+ assert_equal names, ingr.names, %Q{incorrect names}
32
32
  assert_equal amount, ingr.amount, %Q{incorrect amount}
33
33
  assert_equal unit, ingr.unit, %Q{incorrect unit}
34
34
  assert_equal style, ingr.style, %Q{incorrect style}
@@ -2,3 +2,5 @@ require 'minitest/autorun'
2
2
  require 'active_support/all'
3
3
  require 'pry'
4
4
  require 'eye_of_newt'
5
+
6
+ ActiveSupport::TestCase.test_order = :random
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eye-of-newt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter McCracken