eye-of-newt 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/eye_of_newt.gemspec +7 -7
- data/lib/eye_of_newt/parser.rb +17 -17
- data/lib/eye_of_newt/tokenizer.rb +1 -0
- data/lib/eye_of_newt/units.rb +1 -1
- data/lib/eye_of_newt/version.rb +1 -1
- data/test/eye_of_newt_test.rb +11 -3
- metadata +27 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc7218f76efd989d4a22dfd03275e75844baef9a
|
4
|
+
data.tar.gz: 4f1f5443d3353b2060c65d08bca95ed912d2592b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d68430f015d02ad26c48227dfe5cdcad8f00792cf762db8977d8b4b6ea6a04195d4f37bcfb096328391e436e4cd91dffc1f85e36842d9c285e88d9cbf5912c0
|
7
|
+
data.tar.gz: f78aa1b38f038ba38bfb9cff4a56f4a2be3b23daf893d2d8d57741f16d9f4d445feb5c5bf7d152ec03efc1bf3501f1b2548004d08325f5a29ae912fdfce4508a
|
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", "~>
|
21
|
+
spec.add_dependency "activesupport", "~> 5"
|
22
22
|
|
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"
|
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
|
data/lib/eye_of_newt/parser.rb
CHANGED
@@ -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
|
|
data/lib/eye_of_newt/units.rb
CHANGED
data/lib/eye_of_newt/version.rb
CHANGED
data/test/eye_of_newt_test.rb
CHANGED
@@ -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
|
-
|
35
|
-
|
36
|
-
|
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,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
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter McCracken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,98 +16,98 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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:
|
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.
|
164
|
+
rubygems_version: 2.6.11
|
165
165
|
signing_key:
|
166
166
|
specification_version: 4
|
167
167
|
summary: Natural language ingredient parser
|