ingreedyfork 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 759c544ed7cfbe977ae98480e6511e51ce3c6398
4
- data.tar.gz: f097040e73d47972e9172e44e0931eeca4c5711d
2
+ SHA256:
3
+ metadata.gz: 8424ae8e7e7888a98e39a093ad74270089968819d9ecaa76a860fa1462b41c7a
4
+ data.tar.gz: c7e1792a794598eaf9aee10993fc4e4d69ab45afebe63b04167cfc1bc8c87805
5
5
  SHA512:
6
- metadata.gz: 97aff1c6885ccf9655ecdc1b5b3e8b03859ef9f77d6e00b5ca4d8f8df5942f00046b7f1d921399995578bed70753b71a8b33ce07ab646d266a1084b6bf2efec8
7
- data.tar.gz: dd00f7ed900419704bfa6f1f8cdd9158dfe3bb8180a17c57b80f84ac5bad86279cbde88b7940a1ffe655f38f2261988f02d500f781c9da9c2b54ac995338ec83
6
+ metadata.gz: 930fb7edb14bdbbdd7fc40672f6e7de3b8aeec2a459a9ce944f1e10ede534b98d984a6b9f5e877c401dd1eeee7ca0fa4aa572425ca4ee4e4ac44d55b9a86cfdb
7
+ data.tar.gz: cda6a23f88a198d9716e9c0ca8d9274c63582c282a08d68cc25308c2fc06e8ff1b5160bb9f01ffffb5a4a13a0efbbe43a3c3318fc85507154593c2dd22ea3ccf
@@ -1,3 +1,7 @@
1
+ inherit_gem:
2
+ matkoniecz-ruby-style:
3
+ - standard_rubocop_config.yml
4
+
1
5
  AllCops:
2
6
  Exclude:
3
7
  - db/schema.rb
@@ -0,0 +1 @@
1
+ gem push *.gem
@@ -0,0 +1,3 @@
1
+ rm *.gem
2
+ gem build *.gemspec
3
+ gem install --user-install *.gem
@@ -1,8 +1,8 @@
1
- require File.expand_path("../lib/ingreedy/version", __FILE__)
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
@@ -1,4 +1,4 @@
1
- path = File.expand_path(File.join(File.dirname(__FILE__), "ingreedy"))
1
+ path = File.expand_path(File.join(File.dirname(__FILE__), "ingreedyfork"))
2
2
 
3
3
  require File.join(path, "case_insensitive_parser")
4
4
  require File.join(path, "ingreedy_parser")
@@ -59,7 +59,11 @@ module Ingreedy
59
59
  private
60
60
 
61
61
  def word_digits
62
- Ingreedy.dictionaries.current.numbers.keys
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
@@ -21,7 +21,7 @@
21
21
  - "łyżeczka"
22
22
  - "łyżeczek"
23
23
  - "łyżeczki"
24
- :rounded_tablespoon:
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
- :heaped_tablespoon:
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:
@@ -0,0 +1,3 @@
1
+ module Ingreedy
2
+ VERSION = "0.1.11"
3
+ end
@@ -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 that is prefix of other unit" do
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
- parsed = nil
487
- begin
488
- parsed = Ingreedy.parse(query)
489
- rescue => e
490
- puts "failed on #{query} with #{e.class}"
491
- #puts e
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
@@ -3,7 +3,7 @@ if ENV["CI"]
3
3
  Coveralls.wear!
4
4
  end
5
5
 
6
- require "ingreedy"
6
+ require "ingreedyfork"
7
7
  require "parslet/rig/rspec"
8
8
  require "pry"
9
9
 
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.10
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: 2017-07-07 00:00:00.000000000 Z
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
- - ingreedy.gemspec
144
- - lib/ingreedy.rb
145
- - lib/ingreedy/amount_parser.rb
146
- - lib/ingreedy/case_insensitive_parser.rb
147
- - lib/ingreedy/dictionaries/en.yml
148
- - lib/ingreedy/dictionaries/pl.yml
149
- - lib/ingreedy/dictionary.rb
150
- - lib/ingreedy/dictionary_collection.rb
151
- - lib/ingreedy/ingreedy_parser.rb
152
- - lib/ingreedy/rationalizer.rb
153
- - lib/ingreedy/root_parser.rb
154
- - lib/ingreedy/unit_variation_mapper.rb
155
- - lib/ingreedy/version.rb
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
- rubyforge_project:
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)
@@ -1,3 +0,0 @@
1
- module Ingreedy
2
- VERSION = "0.1.10"
3
- end