ingreedyfork 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +4 -0
- data/build_push_new_gem_version.sh +1 -0
- data/build_reinstall_gem_locally.sh +3 -0
- data/{ingreedy.gemspec → ingreedyfork.gemspec} +3 -2
- data/lib/{ingreedy.rb → ingreedyfork.rb} +1 -1
- data/lib/{ingreedy → ingreedyfork}/amount_parser.rb +5 -1
- data/lib/{ingreedy → ingreedyfork}/case_insensitive_parser.rb +0 -0
- data/lib/{ingreedy → ingreedyfork}/dictionaries/en.yml +0 -0
- data/lib/{ingreedy → ingreedyfork}/dictionaries/pl.yml +13 -2
- data/lib/{ingreedy → ingreedyfork}/dictionary.rb +0 -0
- data/lib/{ingreedy → ingreedyfork}/dictionary_collection.rb +0 -0
- data/lib/{ingreedy → ingreedyfork}/ingreedy_parser.rb +0 -0
- data/lib/{ingreedy → ingreedyfork}/rationalizer.rb +0 -0
- data/lib/{ingreedy → ingreedyfork}/root_parser.rb +0 -0
- data/lib/{ingreedy → ingreedyfork}/unit_variation_mapper.rb +0 -0
- data/lib/ingreedyfork/version.rb +3 -0
- data/spec/ingreedy_spec.rb +72 -12
- data/spec/spec_helper.rb +1 -1
- metadata +32 -17
- data/lib/ingreedy/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8424ae8e7e7888a98e39a093ad74270089968819d9ecaa76a860fa1462b41c7a
|
4
|
+
data.tar.gz: c7e1792a794598eaf9aee10993fc4e4d69ab45afebe63b04167cfc1bc8c87805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 930fb7edb14bdbbdd7fc40672f6e7de3b8aeec2a459a9ce944f1e10ede534b98d984a6b9f5e877c401dd1eeee7ca0fa4aa572425ca4ee4e4ac44d55b9a86cfdb
|
7
|
+
data.tar.gz: cda6a23f88a198d9716e9c0ca8d9274c63582c282a08d68cc25308c2fc06e8ff1b5160bb9f01ffffb5a4a13a0efbbe43a3c3318fc85507154593c2dd22ea3ccf
|
data/.rubocop.yml
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
gem push *.gem
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path("../lib/
|
1
|
+
require File.expand_path("../lib/ingreedyfork/version", __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "ingreedyfork"
|
5
|
-
s.version = Ingreedy::VERSION
|
5
|
+
s.version = Ingreedy::VERSION # is in lib/ingreedyfork/version.rb file
|
6
6
|
s.licenses = ["MIT"]
|
7
7
|
s.authors = ["Ian C. Anderson, support for Polish added by Mateusz Konieczny "]
|
8
8
|
s.email = ["matkoniecz@gmail.com"]
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.add_development_dependency "rake", "~> 0.9", ">= 0.9"
|
24
24
|
s.add_development_dependency "rspec", "~> 3.3.0", ">= 3.3.0"
|
25
|
+
s.add_development_dependency 'matkoniecz-ruby-style'
|
25
26
|
s.add_development_dependency "coveralls", "~> 0.7.0", ">= 0.7.0"
|
26
27
|
s.add_development_dependency "pry", '~> 0'
|
27
28
|
end
|
@@ -59,7 +59,11 @@ module Ingreedy
|
|
59
59
|
private
|
60
60
|
|
61
61
|
def word_digits
|
62
|
-
|
62
|
+
# words are sorted by length, from longest to shortest to ensure that
|
63
|
+
# in case of word A that is prefix of word B
|
64
|
+
# word A appears after word B
|
65
|
+
# real example: words "kilka" and "kilkanaście" in Polish
|
66
|
+
Ingreedy.dictionaries.current.numbers.keys.sort_by { |word| -word.length }
|
63
67
|
end
|
64
68
|
|
65
69
|
def vulgar_fractions
|
File without changes
|
File without changes
|
@@ -21,7 +21,7 @@
|
|
21
21
|
- "łyżeczka"
|
22
22
|
- "łyżeczek"
|
23
23
|
- "łyżeczki"
|
24
|
-
:
|
24
|
+
:rounded_spoon:
|
25
25
|
- "czubata łyżka"
|
26
26
|
- "czubatych łyżek"
|
27
27
|
- "czubate łyżki"
|
@@ -31,7 +31,7 @@
|
|
31
31
|
- "czubatych łyżeczek"
|
32
32
|
- "czubate łyżeczki"
|
33
33
|
- "czubatej łyżeczki"
|
34
|
-
:
|
34
|
+
:heaped_spoon:
|
35
35
|
- "kopiasta łyżka"
|
36
36
|
- "kopiastych łyżek"
|
37
37
|
- "kopiaste łyżki"
|
@@ -164,6 +164,12 @@
|
|
164
164
|
- "łodyga"
|
165
165
|
- "łodyg"
|
166
166
|
- "łodygi"
|
167
|
+
- "gałąź"
|
168
|
+
- "gałęzie"
|
169
|
+
- "gałęzi"
|
170
|
+
- "gałązki"
|
171
|
+
- "gałązka"
|
172
|
+
- "gałązek"
|
167
173
|
:metre:
|
168
174
|
- "m"
|
169
175
|
- "metr"
|
@@ -184,6 +190,9 @@
|
|
184
190
|
- "szczur"
|
185
191
|
- "szczury"
|
186
192
|
- "szczura"
|
193
|
+
:washing:
|
194
|
+
- "pranie"
|
195
|
+
- "prań"
|
187
196
|
:numbers:
|
188
197
|
cwiartka: 0.25
|
189
198
|
ćwiartka: 0.25
|
@@ -227,4 +236,6 @@
|
|
227
236
|
dziesięć: 10
|
228
237
|
dziesięciu: 10
|
229
238
|
|
239
|
+
kilkanaście: 15
|
240
|
+
|
230
241
|
:prepositions:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/ingreedy_spec.rb
CHANGED
@@ -416,6 +416,12 @@ describe Ingreedy, "unit parsing with :pl locale" do
|
|
416
416
|
"2 łyżki mąki" => :spoon,
|
417
417
|
"1 łyżka mąki" => :spoon,
|
418
418
|
"1 płaska łyżka mąki" => :spoon,
|
419
|
+
"1 pęczek mąki" => :small_bundle,
|
420
|
+
"1929 pęczek mąki" => :small_bundle,
|
421
|
+
#failure with mutiple spaces is OK but not demanded
|
422
|
+
#"1929 pęczek zazółći" => :small_bundle,
|
423
|
+
#"1929 pęczek zazółći" => :small_bundle,
|
424
|
+
#"1929 pęczków zazółći" => :small_bundle,
|
419
425
|
}.each do |query, expected|
|
420
426
|
it "parses the #{expected} unit correctly" do
|
421
427
|
expect(Ingreedy.parse(query)).to parse_the_unit(expected)
|
@@ -433,7 +439,7 @@ describe Ingreedy, "without units" do
|
|
433
439
|
after(:all) do
|
434
440
|
Ingreedy.locale = nil
|
435
441
|
end
|
436
|
-
it "parses correctly units
|
442
|
+
it "parses correctly units" do
|
437
443
|
result = Ingreedy.parse "3 płaskie łyżki majonezu"
|
438
444
|
|
439
445
|
expect(result.amount).to eq(3)
|
@@ -443,6 +449,65 @@ describe Ingreedy, "without units" do
|
|
443
449
|
end
|
444
450
|
end
|
445
451
|
|
452
|
+
describe Ingreedy, "parsing unitless case (dziesięć -> 10) with Polish locale" do
|
453
|
+
context "Polish locale" do
|
454
|
+
before(:all) do
|
455
|
+
Ingreedy.locale = :pl
|
456
|
+
end
|
457
|
+
|
458
|
+
after(:all) do
|
459
|
+
Ingreedy.locale = nil
|
460
|
+
end
|
461
|
+
it "parses correctly units that has number with prefix matching name of other number" do
|
462
|
+
result = Ingreedy.parse "dziesięć oliwek"
|
463
|
+
|
464
|
+
expect(result.amount).to eq(10)
|
465
|
+
expect(result.unit).to eq nil
|
466
|
+
expect(result.ingredient).to eq("oliwek")
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
describe Ingreedy, "parsing unitless case (kilkanaście -> 11 to 19)" do
|
472
|
+
context "Polish locale" do
|
473
|
+
before(:all) do
|
474
|
+
Ingreedy.locale = :pl
|
475
|
+
end
|
476
|
+
|
477
|
+
after(:all) do
|
478
|
+
Ingreedy.locale = nil
|
479
|
+
end
|
480
|
+
it "parses correctly units that has number with prefix matching name of other number" do
|
481
|
+
result = Ingreedy.parse "kilkanaście oliwek"
|
482
|
+
|
483
|
+
expect(result.amount).to be >= 11
|
484
|
+
expect(result.amount).to be <= 19
|
485
|
+
expect(result.unit).to eq nil
|
486
|
+
expect(result.ingredient).to eq("oliwek")
|
487
|
+
end
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
describe Ingreedy, "parsing unitless case (kilkanaście in reverse order -> 11 to 19)" do
|
492
|
+
context "Polish locale" do
|
493
|
+
before(:all) do
|
494
|
+
Ingreedy.locale = :pl
|
495
|
+
end
|
496
|
+
|
497
|
+
after(:all) do
|
498
|
+
Ingreedy.locale = nil
|
499
|
+
end
|
500
|
+
it "parses correctly units also when other unit is prefix of it" do
|
501
|
+
result = Ingreedy.parse "oliwek kilkanaście"
|
502
|
+
|
503
|
+
expect(result.amount).to be >= 11
|
504
|
+
expect(result.amount).to be <= 19
|
505
|
+
expect(result.unit).to eq nil
|
506
|
+
expect(result.ingredient).to eq("oliwek")
|
507
|
+
end
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
446
511
|
describe Ingreedy, "amount parsing with :pl locale" do
|
447
512
|
context "Polish locale" do
|
448
513
|
before(:all) do
|
@@ -483,17 +548,12 @@ describe Ingreedy, "amount parsing with :pl locale" do
|
|
483
548
|
"marchewki trzy" => 3,
|
484
549
|
}.each do |query, expected|
|
485
550
|
it "parses the correct amount as a rational" do
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
#puts e.class
|
493
|
-
#necessary as raising e crashes rspec - for further investigation try to run parsing test on something like "banana"
|
494
|
-
# report on https://github.com/rspec/rspec-core/issues?page=2&q=is%3Aissue+is%3Aopen
|
495
|
-
end
|
496
|
-
expect(parsed).to parse_the_amount(expected.to_r)
|
551
|
+
begin
|
552
|
+
expect(Ingreedy.parse(query)).to parse_the_amount(expected.to_r)
|
553
|
+
rescue Ingreedy::ParseFailed
|
554
|
+
puts "failed to parse <#{query}>"
|
555
|
+
raise
|
556
|
+
end
|
497
557
|
end
|
498
558
|
end
|
499
559
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ingreedyfork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'Ian C. Anderson, support for Polish added by Mateusz Konieczny '
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -90,6 +90,20 @@ dependencies:
|
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 3.3.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: matkoniecz-ruby-style
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
type: :development
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
93
107
|
- !ruby/object:Gem::Dependency
|
94
108
|
name: coveralls
|
95
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,19 +154,21 @@ files:
|
|
140
154
|
- Gemfile
|
141
155
|
- README.md
|
142
156
|
- Rakefile
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
- lib/
|
147
|
-
- lib/
|
148
|
-
- lib/
|
149
|
-
- lib/
|
150
|
-
- lib/
|
151
|
-
- lib/
|
152
|
-
- lib/
|
153
|
-
- lib/
|
154
|
-
- lib/
|
155
|
-
- lib/
|
157
|
+
- build_push_new_gem_version.sh
|
158
|
+
- build_reinstall_gem_locally.sh
|
159
|
+
- ingreedyfork.gemspec
|
160
|
+
- lib/ingreedyfork.rb
|
161
|
+
- lib/ingreedyfork/amount_parser.rb
|
162
|
+
- lib/ingreedyfork/case_insensitive_parser.rb
|
163
|
+
- lib/ingreedyfork/dictionaries/en.yml
|
164
|
+
- lib/ingreedyfork/dictionaries/pl.yml
|
165
|
+
- lib/ingreedyfork/dictionary.rb
|
166
|
+
- lib/ingreedyfork/dictionary_collection.rb
|
167
|
+
- lib/ingreedyfork/ingreedy_parser.rb
|
168
|
+
- lib/ingreedyfork/rationalizer.rb
|
169
|
+
- lib/ingreedyfork/root_parser.rb
|
170
|
+
- lib/ingreedyfork/unit_variation_mapper.rb
|
171
|
+
- lib/ingreedyfork/version.rb
|
156
172
|
- spec/ingreedy/amount_parser_spec.rb
|
157
173
|
- spec/ingreedy/rationalizer_spec.rb
|
158
174
|
- spec/ingreedy/unit_variation_mapper_spec.rb
|
@@ -177,8 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
193
|
- !ruby/object:Gem::Version
|
178
194
|
version: '0'
|
179
195
|
requirements: []
|
180
|
-
|
181
|
-
rubygems_version: 2.5.1
|
196
|
+
rubygems_version: 3.1.2
|
182
197
|
signing_key:
|
183
198
|
specification_version: 4
|
184
199
|
summary: Recipe parser (fork of ingreedy)
|
data/lib/ingreedy/version.rb
DELETED