eye-of-newt 0.0.11 → 0.0.15

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
- SHA1:
3
- metadata.gz: cc1184f54a4aac5a3e779685f661ff8d67575e45
4
- data.tar.gz: ef2c419a4acb019a36ad2acf7af13a8cefef1f5c
2
+ SHA256:
3
+ metadata.gz: 273010052f34b67d89c3543a3b1111779d7fff441e75fc7d09a0ddcb4de27fcb
4
+ data.tar.gz: 1c273f1b42b1d555661f22548d557f00798f3f79d8fb1127af65bcd496ffe34d
5
5
  SHA512:
6
- metadata.gz: 3987e80af077ae560f675b21000311e2300135bf60a2bc1983745193c5c2ca01f4dce8d8b80c676afca52df89699f58927e9c0f51619649dce71c54deee3a795
7
- data.tar.gz: 47b9df47b03212cefd21583f1b8329d38f8eb7e38a89176d61b87f7a0237c804b52d8175d5fdc2bddbc6b7b7a455c89f430b5254c6fe3ee0a00502b7bedcf63f
6
+ metadata.gz: b919b9775ce56dc136c4224a67d9bedad3aea134ccd1c2beb3438daad025ee5af8ac1db51b0d02d015da603a15a5a1404c3615fba0a96019f1a000f27bc80271
7
+ data.tar.gz: '09576ffd8e91cadbb26cdc82d43b7ed2e0d03f0cb5c7d278c0b53739474e57259a86df4bc543be168416b0a39c34acf1faf95e96bae9e3cb5317f9d2e275386a'
data/eye_of_newt.gemspec CHANGED
@@ -18,12 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "activesupport", "~> 4"
21
+ spec.add_dependency "activesupport", ">= 5"
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.5"
24
- spec.add_development_dependency "rake", "~> 10"
25
- spec.add_development_dependency "racc", "~> 1"
26
- spec.add_development_dependency "pry", "~> 0"
27
- spec.add_development_dependency "pry-byebug", "~> 1"
28
- spec.add_development_dependency "pry-rescue", "~> 1"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "racc"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "pry-byebug"
28
+ spec.add_development_dependency "pry-rescue"
29
29
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.11
4
- # from Racc grammer file "".
3
+ # This file is automatically generated by Racc 1.6.0
4
+ # from Racc grammar file "".
5
5
  #
6
6
 
7
7
  require 'racc/parser.rb'
@@ -37,28 +37,28 @@ module EyeOfNewt
37
37
  ##### State transition tables begin ###
38
38
 
39
39
  racc_action_table = [
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,
40
+ -47, 22, 19, 21, 12, 32, 20, -47, 11, -47,
41
+ 13, -47, 14, 19, 12, 12, 35, 20, 38, 24,
42
+ 36, 25, 14, 19, 19, 39, 40, 20, 20, 24,
43
+ 24, 25, 25, 29, -35, 30, 31, 12, 42, 58,
44
+ 46, 47, 30, 31, 30, 31, 44, 48, 31, 42,
45
+ 42, 59, 60, 21, 21, 63, 46, 64, 65, 31,
46
46
  31, 68, 69 ]
47
47
 
48
48
  racc_action_check = [
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,
49
+ 11, 1, 0, 0, 0, 4, 0, 11, 0, 11,
50
+ 0, 11, 0, 2, 6, 7, 6, 2, 8, 2,
51
+ 6, 2, 6, 18, 32, 9, 9, 18, 32, 18,
52
+ 32, 18, 32, 3, 13, 3, 3, 33, 14, 33,
53
+ 21, 21, 23, 23, 26, 26, 15, 22, 27, 30,
54
+ 31, 34, 37, 39, 40, 41, 44, 46, 47, 49,
55
55
  51, 55, 57 ]
56
56
 
57
57
  racc_action_pointer = [
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,
58
+ 0, 1, 11, 24, -2, nil, 10, 11, 12, 11,
59
+ nil, 0, nil, 30, 33, 43, nil, nil, 21, nil,
60
+ nil, 24, 47, 31, nil, nil, 33, 36, nil, nil,
61
+ 44, 45, 22, 33, 45, nil, nil, 46, nil, 50,
62
62
  51, 42, nil, nil, 40, nil, 54, 55, nil, 47,
63
63
  nil, 48, nil, nil, nil, 48, nil, 56, nil, nil,
64
64
  nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
@@ -73,22 +73,22 @@ racc_action_default = [
73
73
  -24, -37, -38, -36, -51, -52, -1, -3, -34, -16 ]
74
74
 
75
75
  racc_goto_table = [
76
- 28, 9, 8, 6, 3, 27, 23, 7, 34, 37,
77
- 41, 45, 26, 33, 1, 10, 2, 43, nil, nil,
76
+ 28, 9, 8, 1, 3, 27, 23, 7, 34, 37,
77
+ 41, 2, 26, 33, 45, 6, 10, 43, nil, nil,
78
78
  50, nil, nil, 52, 53, 49, 54, 55, 51, nil,
79
79
  nil, nil, nil, nil, nil, 57, 56, nil, nil, nil,
80
80
  61, 62, nil, nil, nil, nil, 66, nil, 67 ]
81
81
 
82
82
  racc_goto_check = [
83
- 5, 12, 11, 9, 3, 4, 3, 10, 11, 11,
84
- 14, 8, 6, 10, 1, 13, 2, 16, nil, nil,
83
+ 5, 12, 11, 1, 3, 4, 3, 10, 11, 11,
84
+ 14, 2, 6, 10, 8, 9, 13, 16, nil, nil,
85
85
  5, nil, nil, 5, 5, 4, 14, 14, 4, nil,
86
86
  nil, nil, nil, nil, nil, 11, 3, nil, nil, nil,
87
87
  12, 12, nil, nil, nil, nil, 5, nil, 5 ]
88
88
 
89
89
  racc_goto_pointer = [
90
- nil, 14, 16, 4, 2, -3, 9, nil, -7, 3,
91
- 7, 2, 1, 15, -4, nil, 2, nil, nil ]
90
+ nil, 3, 11, 4, 2, -3, 9, nil, -4, 15,
91
+ 7, 2, 1, 16, -4, nil, 2, nil, nil ]
92
92
 
93
93
  racc_goto_default = [
94
94
  nil, nil, nil, nil, nil, nil, nil, 4, 5, nil,
@@ -169,7 +169,7 @@ racc_token_table = {
169
169
  "(" => 12,
170
170
  ")" => 13,
171
171
  "-" => 14,
172
- "\u{2013}" => 15,
172
+ "\xE2\x80\x93" => 15,
173
173
  "/" => 16,
174
174
  "." => 17 }
175
175
 
@@ -209,7 +209,7 @@ Racc_token_to_s_table = [
209
209
  "\"(\"",
210
210
  "\")\"",
211
211
  "\"-\"",
212
- "\"\u{2013}\"",
212
+ "\"\\xE2\\x80\\x93\"",
213
213
  "\"/\"",
214
214
  "\".\"",
215
215
  "$start",
@@ -267,7 +267,7 @@ Racc_debug_parser = false
267
267
  # reduce 14 omitted
268
268
 
269
269
  def _reduce_15(val, _values, result)
270
- @ingredient.names << result
270
+ @ingredient.names << result
271
271
  result
272
272
  end
273
273
 
@@ -296,64 +296,64 @@ end
296
296
  # reduce 27 omitted
297
297
 
298
298
  def _reduce_28(val, _values, result)
299
- @ingredient.amount = result
299
+ @ingredient.amount = result
300
300
  result
301
301
  end
302
302
 
303
303
  def _reduce_29(val, _values, result)
304
- @ingredient.amount = result
304
+ @ingredient.amount = result
305
305
  result
306
306
  end
307
307
 
308
308
  def _reduce_30(val, _values, result)
309
- @ingredient.amount = 1
309
+ @ingredient.amount = 1
310
310
  result
311
311
  end
312
312
 
313
313
  def _reduce_31(val, _values, result)
314
- @ingredient.unit = to_unit(result)
314
+ @ingredient.unit = to_unit(result)
315
315
  result
316
316
  end
317
317
 
318
318
  def _reduce_32(val, _values, result)
319
- @ingredient.unit = to_unit(result)
319
+ @ingredient.unit = to_unit(result)
320
320
  result
321
321
  end
322
322
 
323
323
  def _reduce_33(val, _values, result)
324
- @ingredient.style = val[1]
324
+ @ingredient.style = val[1]
325
325
  result
326
326
  end
327
327
 
328
328
  def _reduce_34(val, _values, result)
329
- @ingredient.note = val[1]
329
+ @ingredient.note = val[1]
330
330
  result
331
331
  end
332
332
 
333
333
  def _reduce_35(val, _values, result)
334
- @ingredient.unit_modifier = val[0]
334
+ @ingredient.unit_modifier = val[0]
335
335
  result
336
336
  end
337
337
 
338
338
  def _reduce_36(val, _values, result)
339
- @ingredient.unit_modifier = val[1]
339
+ @ingredient.unit_modifier = val[1]
340
340
  result
341
341
  end
342
342
 
343
343
  def _reduce_37(val, _values, result)
344
- result = [val[0], val[2]]
344
+ result = [val[0], val[2]]
345
345
  result
346
346
  end
347
347
 
348
348
  def _reduce_38(val, _values, result)
349
- result = [val[0], val[2]]
349
+ result = [val[0], val[2]]
350
350
  result
351
351
  end
352
352
 
353
353
  # reduce 39 omitted
354
354
 
355
355
  def _reduce_40(val, _values, result)
356
- result = val[0] + val[1]
356
+ result = val[0] + val[1]
357
357
  result
358
358
  end
359
359
 
@@ -362,7 +362,7 @@ end
362
362
  # reduce 42 omitted
363
363
 
364
364
  def _reduce_43(val, _values, result)
365
- result = val.join(' ')
365
+ result = val.join(' ')
366
366
  result
367
367
  end
368
368
 
@@ -379,17 +379,17 @@ end
379
379
  # reduce 49 omitted
380
380
 
381
381
  def _reduce_50(val, _values, result)
382
- result = val[0].to_i
382
+ result = val[0].to_i
383
383
  result
384
384
  end
385
385
 
386
386
  def _reduce_51(val, _values, result)
387
- result = val[0].to_f / val[2].to_f
387
+ result = val[0].to_f / val[2].to_f
388
388
  result
389
389
  end
390
390
 
391
391
  def _reduce_52(val, _values, result)
392
- result = val.join.to_f
392
+ result = val.join.to_f
393
393
  result
394
394
  end
395
395
 
@@ -398,4 +398,4 @@ def _reduce_none(val, _values, result)
398
398
  end
399
399
 
400
400
  end # class Parser
401
- end # module EyeOfNewt
401
+ end # module EyeOfNewt
@@ -20,6 +20,7 @@ module EyeOfNewt
20
20
  @units = units
21
21
  @unit_modifiers = unit_modifiers
22
22
  @ss = StringScanner.new(string)
23
+ @scan_text = nil
23
24
  end
24
25
 
25
26
  def next_token
@@ -56,7 +56,7 @@ module EyeOfNewt
56
56
  end
57
57
 
58
58
  def setup(&block)
59
- instance_eval &block
59
+ instance_eval(&block)
60
60
  self
61
61
  end
62
62
 
@@ -84,6 +84,9 @@ module EyeOfNewt
84
84
  add_unit "g", "g.", "gr", "gr.", "gram", "grams"
85
85
  add_unit "mg", "mg", "mg.", "milligram", "milligrams"
86
86
 
87
+ # english distance units
88
+ add_unit "inch", "inches"
89
+
87
90
  # nonstandard units
88
91
  add_unit "pinches", "pinch"
89
92
  add_unit "dashes", "dash"
@@ -95,6 +98,7 @@ module EyeOfNewt
95
98
  add_unit "cans", "can"
96
99
  add_unit "packages", "package"
97
100
  add_unit "containers", "container"
101
+ add_unit "sticks", "stick"
98
102
 
99
103
  add_unit_modifier "big"
100
104
  add_unit_modifier "large"
@@ -102,6 +106,7 @@ module EyeOfNewt
102
106
  add_unit_modifier "small"
103
107
  add_unit_modifier "heaping"
104
108
  add_unit_modifier "level"
109
+ add_unit_modifier "scant"
105
110
 
106
111
  # unquantified units
107
112
  add_unit "to taste", unquantified: true
@@ -1,3 +1,3 @@
1
1
  module EyeOfNewt
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.15"
3
3
  end
data/test/examples.txt CHANGED
@@ -29,3 +29,4 @@ heaping tablespoon of sugar | sugar | 1 | tbsp | | | heaping
29
29
  1 (46 oz) can tomato juice | tomato juice | 1 | cans | | | 46 oz
30
30
  kale or chard or spinach | kale,chard,spinach | 1 | units
31
31
  kale OR chard OR spinach | kale,chard,spinach | 1 | units
32
+ 1 inch ginger | ginger | 1 | inch
@@ -31,9 +31,9 @@ class EyeOfNewtTest < ActiveSupport::TestCase
31
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
- assert_equal style, ingr.style, %Q{incorrect style}
35
- assert_equal note, ingr.note, %Q{incorrect note}
36
- assert_equal unit_modifier, ingr.unit_modifier, %Q{incorrect unit modifier}
34
+ assert_equal_or_nil style, ingr.style, %Q{incorrect style}
35
+ assert_equal_or_nil note, ingr.note, %Q{incorrect note}
36
+ assert_equal_or_nil unit_modifier, ingr.unit_modifier, %Q{incorrect unit modifier}
37
37
  end
38
38
  end
39
39
 
@@ -42,4 +42,12 @@ class EyeOfNewtTest < ActiveSupport::TestCase
42
42
  EyeOfNewt.parse("1")
43
43
  end
44
44
  end
45
+
46
+ def assert_equal_or_nil(expected, actual, message)
47
+ if expected
48
+ assert_equal expected, actual, message
49
+ else
50
+ assert_nil actual, message
51
+ end
52
+ end
45
53
  end
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eye-of-newt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter McCracken
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2021-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4'
19
+ version: '5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4'
26
+ version: '5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.5'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.5'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: racc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry-byebug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1'
89
+ version: '0'
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: '1'
96
+ version: '0'
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: '1'
103
+ version: '0'
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: '1'
110
+ version: '0'
111
111
  description: Parses natural ingredients (e.g. "1 1/2 pounds of potatoes, peeled")
112
112
  into usable parts.
113
113
  email:
@@ -145,7 +145,7 @@ homepage: http://github.com/peterjm/eye_of_newt
145
145
  licenses:
146
146
  - MIT
147
147
  metadata: {}
148
- post_install_message:
148
+ post_install_message:
149
149
  rdoc_options: []
150
150
  require_paths:
151
151
  - lib
@@ -160,9 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  requirements: []
163
- rubyforge_project:
164
- rubygems_version: 2.2.2
165
- signing_key:
163
+ rubygems_version: 3.2.20
164
+ signing_key:
166
165
  specification_version: 4
167
166
  summary: Natural language ingredient parser
168
167
  test_files: