fifa 2024.9.22 → 2024.9.24

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
2
  SHA256:
3
- metadata.gz: b3bf43bacb89e178a5c836edc7b9654ae23e8ddc440e8ce2fd215295387d7f8b
4
- data.tar.gz: 3dc3ee724c145640ddc5ba6a992cb751a290e38bdb78f6abcd0fa3c52fb4dbbd
3
+ metadata.gz: 1616a8e1385d8ece752e63a5fc1a44ff0f2ee9d4f6ab40d0774f151fa544025e
4
+ data.tar.gz: f4b8e17cce0e1a9a353520f6726a071ac0fb33dbd1c95490e323c56e4c3b366f
5
5
  SHA512:
6
- metadata.gz: 30e3ec97c2d6b12edd84be1345d1acd90e3c7da87390296110dd51df502432811e57a6f2e4e6d8e672f736ab2eee7765fa09bd86e8a54105ca313e56732e91bb
7
- data.tar.gz: 21cbba46ec38f6f94bcdcceaad86d86c060f8ff3afacf838032ffb0c636411b882be579eced74e8ed95d41483c27b3600040b3a30ec94330b85920c959602b57
6
+ metadata.gz: ff004e8985804a8ac8f6b51e3db0f40acd4bf00593fb19f5ea58e02d32fca3be8664dd3aa500c8553f49a59299791affd3c6d300d8b90a924f84c06540ae2187
7
+ data.tar.gz: 49831c5e0da0491506a54f7c9064ee0f5aecf9651bb75ea93ea4b2e4ae1707f053c6c3d3d79f1f58599b92d3f51c1bfad8853941cce2140a3412906bf7b11011
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 2024.9.22
1
+ ### 2024.9.24
2
2
 
3
3
  ### 0.0.1 / 2019-08-12
4
4
 
data/README.md CHANGED
@@ -128,7 +128,7 @@ That's it.
128
128
  The World's Football Association / Governing Body
129
129
  uses its own country list and (three-letter²) codes - see
130
130
  the [List of FIFA country codes @ Wikipedia](https://en.wikipedia.org/wiki/List_of_FIFA_country_codes)
131
- or the [built-in country datafiles (in .txt)](https://github.com/sportdb/football.db/blob/master/fifa/config) shipping with this library.
131
+ or the [built-in country datafiles (in .txt)](https://github.com/sportdb/fifa/blob/master/config) shipping with this library.
132
132
 
133
133
 
134
134
 
data/Rakefile CHANGED
@@ -21,6 +21,7 @@ Hoe.spec 'fifa' do
21
21
 
22
22
  self.extra_deps = [
23
23
  ['sportdb-structs', '>= 0.4.0'],
24
+ ['alphabets'],
24
25
  ]
25
26
 
26
27
  self.spec_extras = {
@@ -77,8 +77,14 @@ ch Switzerland, SUI, fifa › uefa
77
77
  tr Turkey, TUR, fifa › uefa
78
78
  ua Ukraine, UKR, fifa › uefa
79
79
 
80
- xk Kosovo, KVX, fifa uefa # -- note: Kosovo is not listed as an ISO standard country. The unofficial 2 and 3-digit codes are used by the European Commission and others until Kosovo is assigned an ISO code
81
- | KOS # note: KOS used by UEFA, KVX by FIFA (use FIFA code for now)
80
+ ## old kosovo version
81
+ # -- note: Kosovo is not listed as an ISO standard country. The unofficial 2 and 3-digit codes are used by the European Commission and others until Kosovo is assigned an ISO code
82
+ # note: KOS used by UEFA, KVX by FIFA (use FIFA code for now)
83
+ # xk Kosovo, KVX, fifa › uefa
84
+ # | KOS
85
+
86
+ kos Kosovo, KOS, fifa › uefa
87
+ | kvx | xk
82
88
 
83
89
  ## south caucasus
84
90
  ## - add to middle east?
@@ -17,6 +17,7 @@ class CountryIndex
17
17
  def initialize( recs=nil )
18
18
  @countries = []
19
19
  @by_code = {} ## countries by codes (fifa, internet, etc)
20
+ @by_name = {} ## normalized name
20
21
  @orgs = OrgIndex.new
21
22
 
22
23
  add( recs ) if recs
@@ -38,11 +39,25 @@ class CountryIndex
38
39
 
39
40
 
40
41
  def find( q )
41
- key = q.to_s.downcase ## allow symbols (and always downcase e.g. AUT to aut etc.)
42
+ ## todo/fix - add find by name (find_by_name_and_code) - why? why not?
43
+ find_by_code( q )
44
+ end
45
+
46
+ def find_by_code( code )
47
+ key = code.to_s.downcase ## allow symbols (and always downcase e.g. AUT to aut etc.)
42
48
  @by_code[ key ]
43
49
  end
44
- alias_method :[], :find
50
+ alias_method :[], :find_by_code
51
+
52
+ def find_by_name( name )
53
+ key = normalize( unaccent( name.to_s ))
54
+ @by_name[ key ]
55
+ end
56
+
57
+
45
58
 
59
+ include SportDb::NameHelper
60
+ ## strip_year, strip_lang, normalize etc.
46
61
 
47
62
 
48
63
  def add( recs )
@@ -55,15 +70,36 @@ class CountryIndex
55
70
 
56
71
  def _add( recs )
57
72
  recs.each do |rec|
58
- key = rec.code.downcase ## add codes lookups - key, fifa, ...
73
+ ## step 1 - add code lookups - key, fifa, ...
74
+ ## todo/fix - add two-letter keys and alt keys - why? why not?
75
+ key = rec.code.downcase
59
76
  if @by_code[ key ]
60
77
  puts "** !!! ERROR !!! country code (fifa) >#{rec.code}< already exits!!"
61
78
  exit 1
62
79
  else
63
80
  @by_code[ key ] = rec
64
81
  end
82
+
83
+
84
+ ## step 2 - add name lookups
85
+ keys = [ normalize( unaccent( strip_year( rec.name ))) ]
86
+
87
+ rec.alt_names.each do |name|
88
+ keys << normalize( unaccent( strip_year(strip_lang(name)) ))
89
+ end
90
+ ## note - allow duplicates only if same country
91
+ ## e.g Panama, Panamá
92
+ keys = keys.uniq
93
+
94
+ keys.each do |key|
95
+ if @by_name[ key ]
96
+ puts "** !!! ERROR country (norm) name >#{key}< already exits"
97
+ exit 1
98
+ else
99
+ @by_name[ key ] = rec
100
+ end
101
+ end
65
102
  end
66
103
  end # method add
67
104
  end # class CountryIndex
68
-
69
- end # class Module
105
+ end # module Fifa
data/lib/fifa/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  module Fifa
3
3
  MAJOR = 2024 ## todo: namespace inside version or something - why? why not??
4
4
  MINOR = 9
5
- PATCH = 22
5
+ PATCH = 24
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/fifa.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  ## 3rd party gems
2
2
  require 'sportdb/structs' ## pull-in Sports::Country
3
+ require 'alphabets'
3
4
 
4
5
 
5
6
  ###
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fifa
3
3
  version: !ruby/object:Gem::Version
4
- version: 2024.9.22
4
+ version: 2024.9.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-22 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-structs
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: alphabets
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rdoc
29
43
  requirement: !ruby/object:Gem::Requirement