Skip to content

Commit 2626613

Browse files
committed
safe navigation in SwimmerDecorator#display_label when gender is not defined; added bias parameter in CmdFindDBEntity <- DbFinders::FuzzySwimmer because sometimes the default 0.8 doesn't fit the case; refactored Swimmer#age_for_category_range from [Admin2]PdfResults::L2Converter; bundle update; vers. 0.8.00
1 parent 8f3b6ca commit 2626613

File tree

14 files changed

+116
-65
lines changed

14 files changed

+116
-65
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
_Please, add the latest build info on top of the list; use Version::MAJOR only after gold release; keep semantic versioning in line with framework's_
44

5+
- **0.8.00** [Steve A.] safe navigation in SwimmerDecorator#display_label when gender is not defined; added bias parameter in CmdFindDBEntity <- DbFinders::FuzzySwimmer because sometimes the default 0.8 doesn't fit the case; refactored Swimmer#age_for_category_range from [Admin2]PdfResults::L2Converter; bundle update
56
- **0.7.25** [Steve A.] amend dumb idea of aliasing #present? to positive? in all TimingManageable sibling classes
67
- **0.7.24** [Steve A.] bundle updates & rubocop updates; moved zero?, positive? & present? helpers directly into TimingManageable; specs updates
78
- **0.7.23** [Steve A.] bundle updates

Gemfile.lock

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
goggles_db (0.7.25)
4+
goggles_db (0.8.00)
55
acts-as-taggable-on
66
acts_as_votable
77
cities
@@ -137,7 +137,7 @@ GEM
137137
country_select (10.0.0)
138138
countries (> 5.0, < 8.0)
139139
crass (1.0.6)
140-
date (3.4.0)
140+
date (3.4.1)
141141
debug_inspector (1.2.0)
142142
devise (4.9.4)
143143
bcrypt (~> 3.0)
@@ -156,13 +156,13 @@ GEM
156156
activesupport (>= 5.0)
157157
request_store (>= 1.0)
158158
ruby2_keywords
159-
erubi (1.13.0)
159+
erubi (1.13.1)
160160
factory_bot (6.5.0)
161161
activesupport (>= 5.0.0)
162162
factory_bot_rails (6.4.4)
163163
factory_bot (~> 6.5)
164164
railties (>= 5.0.0)
165-
faraday (2.12.1)
165+
faraday (2.12.2)
166166
faraday-net_http (>= 2.0, < 3.5)
167167
json
168168
logger
@@ -234,7 +234,7 @@ GEM
234234
sparkr (>= 0.2.0)
235235
term-ansicolor
236236
yard (~> 0.9.12)
237-
json (2.8.2)
237+
json (2.9.1)
238238
jwt (2.9.3)
239239
base64
240240
language_server-protocol (3.17.0.3)
@@ -248,7 +248,7 @@ GEM
248248
listen (3.9.0)
249249
rb-fsevent (~> 0.10, >= 0.10.3)
250250
rb-inotify (~> 0.9, >= 0.9.10)
251-
logger (1.6.1)
251+
logger (1.6.4)
252252
loofah (2.23.1)
253253
crass (~> 1.0.2)
254254
nokogiri (>= 1.12.0)
@@ -262,15 +262,15 @@ GEM
262262
method_source (1.1.0)
263263
mini_magick (5.0.1)
264264
mini_mime (1.1.5)
265-
minitest (5.25.1)
265+
minitest (5.25.4)
266266
multi_json (1.15.0)
267267
multi_xml (0.7.1)
268268
bigdecimal (~> 3.1)
269269
mysql2 (0.5.6)
270270
nenv (0.3.0)
271-
net-http (0.5.0)
271+
net-http (0.6.0)
272272
uri
273-
net-imap (0.5.1)
273+
net-imap (0.5.4)
274274
date
275275
net-protocol
276276
net-pop (0.1.2)
@@ -280,7 +280,7 @@ GEM
280280
net-smtp (0.5.0)
281281
net-protocol
282282
nio4r (2.7.4)
283-
nokogiri (1.16.7-x86_64-linux)
283+
nokogiri (1.17.2-x86_64-linux)
284284
racc (~> 1.4)
285285
notiffany (0.1.3)
286286
nenv (~> 0.1)
@@ -348,9 +348,9 @@ GEM
348348
activesupport (>= 5.0.0)
349349
minitest
350350
nokogiri (>= 1.6)
351-
rails-html-sanitizer (1.6.0)
351+
rails-html-sanitizer (1.6.2)
352352
loofah (~> 2.21)
353-
nokogiri (~> 1.14)
353+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
354354
rails-i18n (6.0.0)
355355
i18n (>= 0.7, < 2)
356356
railties (>= 6.0.0, < 7)
@@ -365,7 +365,7 @@ GEM
365365
rb-fsevent (0.11.2)
366366
rb-inotify (0.11.1)
367367
ffi (~> 1.0)
368-
regexp_parser (2.9.2)
368+
regexp_parser (2.9.3)
369369
request_store (1.7.0)
370370
rack (>= 1.4)
371371
responders (3.1.1)
@@ -392,23 +392,23 @@ GEM
392392
rspec-expectations (~> 3.13)
393393
rspec-mocks (~> 3.13)
394394
rspec-support (~> 3.13)
395-
rspec-support (3.13.1)
395+
rspec-support (3.13.2)
396396
rspec_junit_formatter (0.6.0)
397397
rspec-core (>= 2, < 4, != 2.12.0)
398398
rspec_pacman_formatter (0.1.7)
399399
colorize
400400
rspec
401-
rubocop (1.68.0)
401+
rubocop (1.69.2)
402402
json (~> 2.3)
403403
language_server-protocol (>= 3.17.0)
404404
parallel (~> 1.10)
405405
parser (>= 3.3.0.2)
406406
rainbow (>= 2.2.2, < 4.0)
407-
regexp_parser (>= 2.4, < 3.0)
408-
rubocop-ast (>= 1.32.2, < 2.0)
407+
regexp_parser (>= 2.9.3, < 3.0)
408+
rubocop-ast (>= 1.36.2, < 2.0)
409409
ruby-progressbar (~> 1.7)
410-
unicode-display_width (>= 2.4.0, < 3.0)
411-
rubocop-ast (1.36.1)
410+
unicode-display_width (>= 2.4.0, < 4.0)
411+
rubocop-ast (1.37.0)
412412
parser (>= 3.3.1.0)
413413
rubocop-factory_bot (2.26.1)
414414
rubocop (~> 1.61)
@@ -422,7 +422,7 @@ GEM
422422
rubocop-ast (>= 1.31.1, < 2.0)
423423
rubocop-rake (0.6.0)
424424
rubocop (~> 1.0)
425-
rubocop-rspec (3.2.0)
425+
rubocop-rspec (3.3.0)
426426
rubocop (~> 1.61)
427427
rubocop-rspec_rails (2.30.0)
428428
rubocop (~> 1.61)
@@ -476,15 +476,17 @@ GEM
476476
term-ansicolor (1.11.2)
477477
tins (~> 1.0)
478478
thor (1.3.2)
479-
tilt (2.4.0)
480-
timeout (0.4.2)
481-
tins (1.37.0)
479+
tilt (2.5.0)
480+
timeout (0.4.3)
481+
tins (1.37.1)
482482
bigdecimal
483483
sync
484484
tzinfo (2.0.6)
485485
concurrent-ruby (~> 1.0)
486486
unaccent (0.4.0)
487-
unicode-display_width (2.6.0)
487+
unicode-display_width (3.1.2)
488+
unicode-emoji (~> 4.0, >= 4.0.4)
489+
unicode-emoji (4.0.4)
488490
uniform_notifier (1.16.0)
489491
uri (1.0.2)
490492
version_gem (1.1.4)

app/commands/goggles_db/cmd_find_db_entity.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
module GogglesDb
77
#
88
# = Generic DB entity fuzzy-finder command
9-
# - version: 7-0.5.01
9+
#
10+
# - version: 7-0.8.00
1011
# - author: Steve A.
11-
# - build: 20230401
12+
# - build: 20241223
1213
#
1314
# Uses the DbFinders::Factory to create a specific fuzzy-finder for
1415
# the specified DB entity.
@@ -53,6 +54,7 @@ class CmdFindDbEntity
5354
# the verbose search output on the console (default: false); this will be removed from
5455
# the search terms.
5556
#
57+
# - <tt>bias</tt>: fuzzy search bias for a match (default: BaseStrategy::DEFAULT_MATCH_BIAS)
5658
#
5759
# == Example usage:
5860
#
@@ -68,9 +70,9 @@ class CmdFindDbEntity
6870
# > cmd.result
6971
# => #<GogglesDb::Team id: 1, ...>
7072
#
71-
def initialize(model_klass, search_terms = {})
73+
def initialize(model_klass, search_terms = {}, bias = DbFinders::BaseStrategy::DEFAULT_MATCH_BIAS)
7274
@search_terms = search_terms
73-
@finder = DbFinders::Factory.for(model_klass, search_terms)
75+
@finder = DbFinders::Factory.for(model_klass, search_terms, bias)
7476
@matches = []
7577
end
7678

app/strategies/goggles_db/db_finders/factory.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module DbFinders
77
#
88
# = DbFinders singleton factory
99
#
10-
# - version: 7-0.4.01
10+
# - version: 7-0.8.00
1111
# - author: Steve A.
12-
# - build: 20220804
12+
# - build: 20241223
1313
#
1414
# Allows to create a plug-in strategy object for finding a specific entity given the search
1515
# parameters.
@@ -34,34 +34,36 @@ class Factory
3434
# the verbose search output on the console (default: false); this will be removed from
3535
# the search terms (as all other column names non valid as search terms).
3636
#
37+
# - <tt>bias</tt>: fuzzy search bias for a match (default: BaseStrategy::DEFAULT_MATCH_BIAS)
38+
#
3739
# == Returns
3840
# A <tt>DbFinders::BaseStrategy</tt> sibling
3941
#
4042
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
41-
def self.for(model_klass, search_terms = {})
43+
def self.for(model_klass, search_terms = {}, bias = BaseStrategy::DEFAULT_MATCH_BIAS)
4244
raise(ArgumentError, 'No search term specified') if search_terms.blank? ||
4345
search_terms.except(:toggle_debug).blank?
4446

4547
if model_klass == GogglesDb::Swimmer
4648
# Add also strict parameter checking for the search terms in all models, like this:
4749
search_terms.keep_if { |key, _v| %i[complete_name year_of_birth gender_type_id toggle_debug].include?(key) }
48-
FuzzySwimmer.new(search_terms)
50+
FuzzySwimmer.new(search_terms, bias)
4951

5052
elsif model_klass == GogglesDb::Team
5153
search_terms.keep_if { |key, _v| %i[name editable_name name_variations city_id toggle_debug].include?(key) }
52-
FuzzyTeam.new(search_terms)
54+
FuzzyTeam.new(search_terms, bias)
5355

5456
elsif model_klass == GogglesDb::SwimmingPool
5557
search_terms.keep_if { |key, _v| %i[name nick_name pool_type_id city_id toggle_debug].include?(key) }
56-
FuzzyPool.new(search_terms)
58+
FuzzyPool.new(search_terms, bias)
5759

5860
elsif model_klass == GogglesDb::Meeting
5961
search_terms.keep_if { |key, _v| %i[description code header_year season_id toggle_debug].include?(key) }
60-
FuzzyMeeting.new(search_terms)
62+
FuzzyMeeting.new(search_terms, bias)
6163

6264
elsif model_klass == GogglesDb::City
6365
search_terms.keep_if { |key, _v| %i[name area country country_code toggle_debug].include?(key) }
64-
FuzzyCity.new(search_terms)
66+
FuzzyCity.new(search_terms, bias)
6567

6668
else
6769
raise(ArgumentError, 'New, unsupported or unimplemented model class!')

app/strategies/goggles_db/db_finders/fuzzy_city.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module DbFinders
55
#
66
# = FuzzyCity finder strategy
77
#
8-
# - version: 7-0.3.53
8+
# - version: 7-0.8.00
99
# - author: Steve A.
10-
# - build: 20220526
10+
# - build: 20241223
1111
#
1212
class FuzzyCity < BaseStrategy
1313
# Creates a new search strategy instance given the parameters.
@@ -23,8 +23,10 @@ class FuzzyCity < BaseStrategy
2323
# the verbose search output on the console (default: false); this will be removed from
2424
# the search terms.
2525
#
26-
def initialize(search_terms = {})
27-
super(GogglesDb::City, search_terms, :for_name, 0.8)
26+
# - <tt>bias</tt>: fuzzy search bias for a match (default: BaseStrategy::DEFAULT_MATCH_BIAS)
27+
#
28+
def initialize(search_terms = {}, bias = BaseStrategy::DEFAULT_MATCH_BIAS)
29+
super(GogglesDb::City, search_terms, :for_name, bias)
2830
end
2931
#-- --------------------------------------------------------------------------
3032
#++

app/strategies/goggles_db/db_finders/fuzzy_meeting.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module DbFinders
55
#
66
# = FuzzyMeeting finder strategy
77
#
8-
# - version: 7-0.4.01
8+
# - version: 7-0.8.00
99
# - author: Steve A.
10-
# - build: 20220823
10+
# - build: 20241223
1111
#
1212
class FuzzyMeeting < BaseStrategy
1313
# Creates a new search strategy instance given the parameters.
@@ -20,8 +20,10 @@ class FuzzyMeeting < BaseStrategy
2020
# the verbose search output on the console (default: false); this will be removed from
2121
# the search terms.
2222
#
23-
def initialize(search_terms = {})
24-
super(GogglesDb::Meeting, search_terms, :for_name, DEFAULT_MATCH_BIAS)
23+
# - <tt>bias</tt>: fuzzy search bias for a match (default: BaseStrategy::DEFAULT_MATCH_BIAS)
24+
#
25+
def initialize(search_terms = {}, bias = BaseStrategy::DEFAULT_MATCH_BIAS)
26+
super(GogglesDb::Meeting, search_terms, :for_name, bias)
2527
end
2628
#-- --------------------------------------------------------------------------
2729
#++

app/strategies/goggles_db/db_finders/fuzzy_pool.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module DbFinders
55
#
66
# = FuzzyPool finder strategy
77
#
8-
# - version: 7-0.4.01
8+
# - version: 7-0.8.00
99
# - author: Steve A.
10-
# - build: 20220823
10+
# - build: 20241223
1111
#
1212
class FuzzyPool < BaseStrategy
1313
# Creates a new search strategy instance given the parameters.
@@ -20,8 +20,10 @@ class FuzzyPool < BaseStrategy
2020
# the verbose search output on the console (default: false); this will be removed from
2121
# the search terms.
2222
#
23-
def initialize(search_terms = {})
24-
super(GogglesDb::SwimmingPool, search_terms, :for_name, DEFAULT_MATCH_BIAS)
23+
# - <tt>bias</tt>: fuzzy search bias for a match (default: BaseStrategy::DEFAULT_MATCH_BIAS)
24+
#
25+
def initialize(search_terms = {}, bias = BaseStrategy::DEFAULT_MATCH_BIAS)
26+
super(GogglesDb::SwimmingPool, search_terms, :for_name, bias)
2527
end
2628
#-- --------------------------------------------------------------------------
2729
#++

app/strategies/goggles_db/db_finders/fuzzy_swimmer.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module DbFinders
55
#
66
# = FuzzySwimmer finder strategy
77
#
8-
# - version: 7-0.3.53
8+
# - version: 7-0.8.00
99
# - author: Steve A.
10-
# - build: 20220526
10+
# - build: 20241223
1111
#
1212
class FuzzySwimmer < BaseStrategy
1313
# Creates a new search strategy instance given the parameters.
@@ -20,9 +20,11 @@ class FuzzySwimmer < BaseStrategy
2020
# the verbose search output on the console (default: false); this will be removed from
2121
# the search terms.
2222
#
23-
def initialize(search_terms = {})
23+
# - <tt>bias</tt>: fuzzy search bias for a match (default: BaseStrategy::DEFAULT_MATCH_BIAS)
24+
#
25+
def initialize(search_terms = {}, bias = BaseStrategy::DEFAULT_MATCH_BIAS)
2426
# Use a less restrictive bias (0.8 allows for just a surname)
25-
super(GogglesDb::Swimmer, search_terms, :for_name, 0.8)
27+
super(GogglesDb::Swimmer, search_terms, :for_name, bias)
2628
end
2729
#-- --------------------------------------------------------------------------
2830
#++

app/strategies/goggles_db/db_finders/fuzzy_team.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module DbFinders
55
#
66
# = FuzzyTeam finder strategy
77
#
8-
# - version: 7-0.4.01
8+
# - version: 7-0.8.00
99
# - author: Steve A.
10-
# - build: 20220823
10+
# - build: 20241223
1111
#
1212
class FuzzyTeam < BaseStrategy
1313
# Creates a new search strategy instance given the parameters.
@@ -20,7 +20,9 @@ class FuzzyTeam < BaseStrategy
2020
# the verbose search output on the console (default: false); this will be removed from
2121
# the search terms.
2222
#
23-
def initialize(search_terms = {})
23+
# - <tt>bias</tt>: fuzzy search bias for a match (default: 0.74)
24+
#
25+
def initialize(search_terms = {}, _bias = 0.74)
2426
# Use a less restrictive bias (0.75 allows for just a partial name)
2527
super(GogglesDb::Team, search_terms, :for_name, 0.74)
2628
end

0 commit comments

Comments
 (0)