eye-of-newt 0.0.4 → 0.0.6

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: d3877e1bb1d601343963f3e7d402565f11c725ff
4
- data.tar.gz: c6b868ec895b6bf17e0673d55d5c2ff23282dd27
3
+ metadata.gz: de4710dcb531ffd8b1874697da048da3b8c86692
4
+ data.tar.gz: e13c944fe7319f5487d03d1f16fd7c16640684cc
5
5
  SHA512:
6
- metadata.gz: 19e84d86352917ac640de46644d5daf49965e14b2b33ddc6de916ac12dd17be18ba0985698f9430e72c7a63eb405a1e6b694041b60f831ffac97cda9bb3662d9
7
- data.tar.gz: 8931700e8bdc05341d68b189a7fd364d9b644d48266a89c4ce0e23a3515f7333aa4906feb7de38a2221e72b92031ba801dbc3b5354905ceb121c98aa3b49393e
6
+ metadata.gz: 83f7233696d639af0a6c1396f2b39962a6eec892b1eea04d7dff864b96aef26042d8abade4e096654cf4bf38719bd7b1fcbd2218628c617224dbc58fa39c6a74
7
+ data.tar.gz: 227d72db1af79cb8557c8dab469d07bbdd06c34ff2ca50f867f885c884194e5684d6e9ebd6ad2d426e6024f5ea6cb2e78154ad83205314bbfa4ef4314a793ce1
data/eye_of_newt.gemspec CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rake", "~> 10"
25
25
  spec.add_development_dependency "racc", "~> 1"
26
26
  spec.add_development_dependency "pry", "~> 0"
27
- spec.add_development_dependency "pry-byebug", "~> 0"
28
- spec.add_development_dependency "pry-rescue", "~> 0"
27
+ spec.add_development_dependency "pry-byebug", "~> 1"
28
+ spec.add_development_dependency "pry-rescue", "~> 1"
29
29
  end
@@ -37,50 +37,50 @@ module EyeOfNewt
37
37
  ##### State transition tables begin ###
38
38
 
39
39
  racc_action_table = [
40
- -30, 11, 13, 21, 22, 12, 9, 11, -30, -30,
41
- -30, 12, 16, 11, 20, 21, 22, 12, 16, 25,
42
- 31, 24, 29, 30, 21, 22, 27, 14, 22, 38,
43
- 38, 40, 29, 41, 42, 22, 22, 45 ]
40
+ -32, 12, 22, 23, 24, 13, 18, 12, -32, -32,
41
+ -32, 13, 18, 12, 15, 14, 29, 13, 10, 14,
42
+ 33, 26, 23, 24, 31, 32, 23, 24, 27, 16,
43
+ 24, 40, 40, 42, 31, 43, 44, 24, 24, 47 ]
44
44
 
45
45
  racc_action_check = [
46
- 9, 0, 0, 15, 15, 0, 0, 2, 9, 9,
47
- 9, 2, 2, 10, 3, 3, 3, 10, 10, 5,
48
- 14, 5, 13, 13, 17, 17, 6, 1, 18, 21,
49
- 22, 23, 27, 29, 30, 32, 34, 39 ]
46
+ 10, 11, 3, 3, 3, 11, 11, 2, 10, 10,
47
+ 10, 2, 2, 0, 0, 0, 7, 0, 0, 5,
48
+ 16, 5, 19, 19, 15, 15, 17, 17, 6, 1,
49
+ 20, 23, 24, 25, 29, 31, 32, 34, 36, 41 ]
50
50
 
51
51
  racc_action_pointer = [
52
- -1, 27, 5, 6, nil, 15, 23, nil, nil, 0,
53
- 11, nil, nil, 10, 20, -6, nil, 15, 18, nil,
54
- nil, 24, 25, 25, nil, nil, nil, 20, nil, 30,
55
- 31, nil, 25, nil, 26, nil, nil, nil, nil, 26,
56
- nil, nil, nil, nil, nil, nil ]
52
+ 11, 29, 5, -6, nil, 15, 22, 13, nil, nil,
53
+ 0, -1, nil, nil, nil, 12, 20, 17, nil, 13,
54
+ 20, nil, nil, 26, 27, 27, nil, nil, nil, 22,
55
+ nil, 32, 33, nil, 27, nil, 28, nil, nil, nil,
56
+ nil, 28, nil, nil, nil, nil, nil, nil ]
57
57
 
58
58
  racc_action_default = [
59
- -36, -36, -36, -12, -13, -17, -18, -20, -21, -22,
60
- -27, -29, -31, -33, -36, -8, -30, -10, -11, -6,
61
- -23, -36, -36, -15, -16, -32, -19, -36, -26, -36,
62
- -36, 46, -7, -2, -9, -4, -5, -24, -28, -36,
63
- -14, -34, -35, -1, -3, -25 ]
59
+ -38, -38, -38, -12, -13, -17, -19, -20, -22, -23,
60
+ -24, -29, -31, -33, -34, -35, -38, -8, -32, -10,
61
+ -11, -6, -25, -38, -38, -15, -16, -18, -21, -38,
62
+ -28, -38, -38, 48, -7, -2, -9, -4, -5, -26,
63
+ -30, -38, -14, -36, -37, -1, -3, -27 ]
64
64
 
65
65
  racc_goto_table = [
66
- 19, 7, 28, 3, 18, 15, 17, 26, 37, 39,
67
- 5, 23, 33, 6, 35, 36, 32, 2, 34, 8,
68
- 1, nil, nil, nil, nil, nil, nil, nil, nil, 43,
69
- nil, 44 ]
66
+ 21, 8, 6, 3, 20, 17, 30, 25, 28, 39,
67
+ 41, 5, 19, 7, 35, 2, 37, 38, 34, 9,
68
+ 36, 1, nil, nil, nil, nil, nil, nil, nil, nil,
69
+ nil, 45, nil, 46 ]
70
70
 
71
71
  racc_goto_check = [
72
- 5, 11, 7, 3, 4, 3, 6, 11, 13, 13,
73
- 8, 9, 5, 10, 5, 5, 4, 2, 4, 12,
74
- 1, nil, nil, nil, nil, nil, nil, nil, nil, 5,
75
- nil, 5 ]
72
+ 5, 11, 9, 3, 4, 3, 7, 9, 11, 13,
73
+ 13, 8, 6, 10, 5, 2, 5, 5, 4, 12,
74
+ 4, 1, nil, nil, nil, nil, nil, nil, nil, nil,
75
+ nil, 5, nil, 5 ]
76
76
 
77
77
  racc_goto_pointer = [
78
- nil, 20, 17, 3, 1, -3, 3, -8, 10, 6,
79
- 13, 1, 19, -13, nil ]
78
+ nil, 21, 15, 3, 1, -3, 9, -5, 11, 2,
79
+ 13, 1, 19, -14, nil ]
80
80
 
81
81
  racc_goto_default = [
82
82
  nil, nil, nil, nil, nil, nil, nil, 4, nil, nil,
83
- nil, nil, nil, nil, 10 ]
83
+ nil, nil, nil, nil, 11 ]
84
84
 
85
85
  racc_reduce_table = [
86
86
  0, 0, :racc_error,
@@ -101,28 +101,30 @@ racc_reduce_table = [
101
101
  2, 16, :_reduce_none,
102
102
  2, 16, :_reduce_none,
103
103
  1, 16, :_reduce_none,
104
- 1, 22, :_reduce_18,
105
- 2, 22, :_reduce_19,
104
+ 2, 16, :_reduce_none,
105
+ 1, 16, :_reduce_none,
106
106
  1, 22, :_reduce_20,
107
- 1, 22, :_reduce_21,
107
+ 2, 22, :_reduce_21,
108
108
  1, 22, :_reduce_22,
109
- 1, 20, :_reduce_23,
110
- 2, 18, :_reduce_24,
111
- 3, 19, :_reduce_25,
112
- 2, 21, :_reduce_26,
109
+ 1, 22, :_reduce_23,
110
+ 1, 22, :_reduce_24,
111
+ 1, 20, :_reduce_25,
112
+ 2, 18, :_reduce_26,
113
+ 3, 19, :_reduce_27,
114
+ 2, 21, :_reduce_28,
113
115
  1, 21, :_reduce_none,
114
116
  1, 27, :_reduce_none,
115
117
  1, 28, :_reduce_none,
116
118
  1, 28, :_reduce_none,
117
119
  1, 28, :_reduce_none,
118
- 1, 23, :_reduce_32,
119
- 1, 24, :_reduce_33,
120
- 3, 25, :_reduce_34,
121
- 3, 26, :_reduce_35 ]
120
+ 1, 23, :_reduce_34,
121
+ 1, 24, :_reduce_35,
122
+ 3, 25, :_reduce_36,
123
+ 3, 26, :_reduce_37 ]
122
124
 
123
- racc_reduce_n = 36
125
+ racc_reduce_n = 38
124
126
 
125
- racc_shift_n = 46
127
+ racc_shift_n = 48
126
128
 
127
129
  racc_token_table = {
128
130
  false => 0,
@@ -234,77 +236,81 @@ end
234
236
 
235
237
  # reduce 17 omitted
236
238
 
237
- def _reduce_18(val, _values, result)
239
+ # reduce 18 omitted
240
+
241
+ # reduce 19 omitted
242
+
243
+ def _reduce_20(val, _values, result)
238
244
  @ingredient.amount = result
239
245
  result
240
246
  end
241
247
 
242
- def _reduce_19(val, _values, result)
248
+ def _reduce_21(val, _values, result)
243
249
  @ingredient.amount = val[0] + val[1]
244
250
  result
245
251
  end
246
252
 
247
- def _reduce_20(val, _values, result)
253
+ def _reduce_22(val, _values, result)
248
254
  @ingredient.amount = result
249
255
  result
250
256
  end
251
257
 
252
- def _reduce_21(val, _values, result)
258
+ def _reduce_23(val, _values, result)
253
259
  @ingredient.amount = result
254
260
  result
255
261
  end
256
262
 
257
- def _reduce_22(val, _values, result)
263
+ def _reduce_24(val, _values, result)
258
264
  @ingredient.amount = 1
259
265
  result
260
266
  end
261
267
 
262
- def _reduce_23(val, _values, result)
268
+ def _reduce_25(val, _values, result)
263
269
  @ingredient.unit = to_unit(result)
264
270
  result
265
271
  end
266
272
 
267
- def _reduce_24(val, _values, result)
273
+ def _reduce_26(val, _values, result)
268
274
  @ingredient.style = val[1]
269
275
  result
270
276
  end
271
277
 
272
- def _reduce_25(val, _values, result)
278
+ def _reduce_27(val, _values, result)
273
279
  @ingredient.note = val[1]
274
280
  result
275
281
  end
276
282
 
277
- def _reduce_26(val, _values, result)
283
+ def _reduce_28(val, _values, result)
278
284
  result = val.join(' ')
279
285
  result
280
286
  end
281
287
 
282
- # reduce 27 omitted
283
-
284
- # reduce 28 omitted
285
-
286
288
  # reduce 29 omitted
287
289
 
288
290
  # reduce 30 omitted
289
291
 
290
292
  # reduce 31 omitted
291
293
 
292
- def _reduce_32(val, _values, result)
294
+ # reduce 32 omitted
295
+
296
+ # reduce 33 omitted
297
+
298
+ def _reduce_34(val, _values, result)
293
299
  @ingredient.unit = to_unit(result)
294
300
  result
295
301
  end
296
302
 
297
- def _reduce_33(val, _values, result)
303
+ def _reduce_35(val, _values, result)
298
304
  result = val[0].to_i
299
305
  result
300
306
  end
301
307
 
302
- def _reduce_34(val, _values, result)
308
+ def _reduce_36(val, _values, result)
303
309
  result = val[0].to_f / val[2].to_f
304
310
  result
305
311
  end
306
312
 
307
- def _reduce_35(val, _values, result)
313
+ def _reduce_37(val, _values, result)
308
314
  result = val.join.to_f
309
315
  result
310
316
  end
@@ -23,6 +23,8 @@ rule
23
23
  | amount unit
24
24
  | amount OF
25
25
  | amount
26
+ | unit OF
27
+ | unit
26
28
  ;
27
29
  amount
28
30
  : number { @ingredient.amount = result }
@@ -1,3 +1,3 @@
1
1
  module EyeOfNewt
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
data/test/examples.txt CHANGED
@@ -12,11 +12,16 @@ tomatoes | tomatoes | 1 | units
12
12
  1 cup of flour | flour | 1 | cups
13
13
  1 teaspoon of cream of tartar | cream of tartar | 1 | tsp
14
14
  a pinch of salt | salt | 1 | pinches
15
+ pinch of salt | salt | 1 | pinches
15
16
  4 large leeks, trimmed & thinly sliced | large leeks | 4 | units | trimmed & thinly sliced
16
17
  3 pounds potatoes, washed and cut into 2-inch chunks | potatoes | 3 | lb | washed and cut into 2-inch chunks
17
18
  salt to taste | salt | 1 | to taste
18
19
  an apple, sliced (I like Fuji, but any variety will do) | apple | 1 | units | sliced | I like Fuji, but any variety will do
19
- #4-5 handfuls of spinach, very roughly chopped
20
+ #4-5 handfuls of spinach, very roughly chopped | spinach | 4-5 | handfuls | very roughly chopped
21
+
22
+
23
+
24
+
20
25
  #3 tablespoons sunflower oil, ghee, or clarified butter
21
26
  #1/2 cup crumbled feta, fresh ricotta, or fresh paneer
22
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eye-of-newt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter McCracken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-13 00:00:00.000000000 Z
11
+ date: 2015-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry-rescue
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '1'
111
111
  description: Parses natural ingredients (e.g. "1 1/2 pounds of potatoes, peeled")
112
112
  into usable parts.
113
113
  email: