sportdb-config 0.5.3 → 0.6.0

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
2
  SHA1:
3
- metadata.gz: 43d84070a1a63efe77220f0be88991956c6696a7
4
- data.tar.gz: 4b3c0a3a728065b648f52083f32eba1ebaeab43f
3
+ metadata.gz: 0c2c01fdd2e8ff942c611f48d710ab0ccd6ddb88
4
+ data.tar.gz: 86bf655cde4e2474bc1ac31448494e5381a73622
5
5
  SHA512:
6
- metadata.gz: 2461e383c70749bfc398de2561a057ab087a1d366644b4cf20d11530c19858d70974e0852b96db71041a6a1f7ebdabb34492a5874785227beea0140911f48f77
7
- data.tar.gz: 72e12603145d651a9a2b6266755d1838d962513be478d3f1dbcfb2025b649a8bf4adcea875cdb9bc9424e95cdcb8511c433493125d90f1e5ce1c7e49dfec9993
6
+ metadata.gz: 0ddb39ee84dd3481384092114e80012b653cd7928c58c47c3f55ad2642d3e8bab2df4cc85f1c14b300d893cc640e4c74e333950cfa9fd1e8d4f02a92223f63d7
7
+ data.tar.gz: fd4e20c0cf5b5bff7ad2c740816e3f97a567dcf0e1ee8d902e4961aa71686e138a46f575fe7538d0121224519d2056342635f2b15f2a55eee7c5c90339f1f0c7
data/Manifest.txt CHANGED
@@ -1,5 +1,6 @@
1
1
  HISTORY.md
2
2
  Manifest.txt
3
+ NOTES.md
3
4
  README.md
4
5
  Rakefile
5
6
  config/leagues/eng.txt
@@ -9,7 +10,6 @@ config/leagues/sco.txt
9
10
  config/world/ar.txt
10
11
  config/world/at.txt
11
12
  config/world/be.txt
12
- config/world/countries.txt
13
13
  config/world/de.txt
14
14
  config/world/eng.txt
15
15
  lib/sportdb/config.rb
data/NOTES.md ADDED
@@ -0,0 +1,8 @@
1
+ # Notes
2
+
3
+ ## Todos
4
+
5
+ - use a different name for sportdb-config
6
+ - use sportdb-boot and SportDb::Boot or
7
+ - use sportdb-conf - why? why not?
8
+ - or sportdb-setup/startup/...
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Hoe.spec 'sportdb-config' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['csvreader', '>= 1.2.4'],
23
+ ['fifa', '>= 0.1.1'],
24
24
  ]
25
25
 
26
26
  self.spec_extras = {
@@ -18,8 +18,7 @@ class Configuration
18
18
  end
19
19
 
20
20
  def build_country_index ## todo/check: rename to setup_country_index or read_country_index - why? why not?
21
- recs = read_csv( "#{SportDb::Boot.data_dir}/world/countries.txt" )
22
- CountryIndex.new( recs )
21
+ CountryIndex.new( Fifa.countries )
23
22
  end
24
23
 
25
24
 
@@ -5,19 +5,8 @@ module SportDb
5
5
 
6
6
  ## built-in countries for (quick starter) auto-add
7
7
 
8
- ##
9
- # note: use our own (internal) country struct for now - why? why not?
10
- # - check that shape/structure/fields/attributes match
11
- # the Country struct in sportdb-text (in SportDb::Struct::Country)
12
- ## and the ActiveRecord model !!!!
13
- class Country
14
- ## note: is read-only/immutable for now - why? why not?
15
- ## add cities (array/list) - why? why not?
16
- attr_reader :key, :name, :fifa
17
- def initialize( key, name, fifa )
18
- @key, @name, @fifa = key, name, fifa
19
- end
20
- end # class Country
8
+ ## note: (re)use the struct from the fifa country gem / library for now
9
+ Country = ::Fifa::Country
21
10
 
22
11
 
23
12
  class CountryIndex
@@ -36,31 +25,23 @@ class CountryIndex
36
25
  recs.each do |rec|
37
26
  ## rec e.g. { key:'af', fifa:'AFG', name:'Afghanistan'}
38
27
 
39
- key = rec[:key]
40
- ## note: remove territory of marker e.g. (UK), (US), etc. from name
41
- ## e.g. England (UK) => England
42
- ## Puerto Rico (US) => Puerto Rico
43
- name = rec[:name].sub( /\([A-Z]{2}\)/, '' ).strip
44
- fifa = rec[:fifa]
45
-
46
- country = Country.new( key, name, fifa )
47
- @countries << country
28
+ @countries << rec
48
29
 
49
30
  ## add codes lookups - key, fifa, ...
50
- if @countries_by_code[ country.key ]
51
- puts "** !! ERROR !! country code (key) >#{country.key}< already exits!!"
31
+ if @countries_by_code[ rec.key ]
32
+ puts "** !! ERROR !! country code (key) >#{rec.key}< already exits!!"
52
33
  exit 1
53
34
  else
54
- @countries_by_code[ country.key ] = country
35
+ @countries_by_code[ rec.key ] = rec
55
36
  end
56
37
 
57
38
  ## add fifa code (only) if different from key
58
- if country.key != country.fifa.downcase
59
- if @countries_by_code[ country.fifa.downcase ]
60
- puts "** !! ERROR !! country code (fifa) >#{country.fifa.downcase}< already exits!!"
39
+ if rec.key != rec.fifa.downcase
40
+ if @countries_by_code[ rec.fifa.downcase ]
41
+ puts "** !! ERROR !! country code (fifa) >#{rec.fifa.downcase}< already exits!!"
61
42
  exit 1
62
43
  else
63
- @countries_by_code[ country.fifa.downcase ] = country
44
+ @countries_by_code[ rec.fifa.downcase ] = rec
64
45
  end
65
46
  end
66
47
  end
@@ -7,8 +7,8 @@ module Boot ## note: use a different module than Config to avoid confusion
7
7
  ## maybe rename later gem itself to sportdb-boot - why? why not?
8
8
 
9
9
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
10
- MINOR = 5
11
- PATCH = 3
10
+ MINOR = 6
11
+ PATCH = 0
12
12
  VERSION = [MAJOR,MINOR,PATCH].join('.')
13
13
 
14
14
  def self.version
@@ -13,6 +13,10 @@ def read_csv( path )
13
13
  CsvHash.read( path, :header_converters => :symbol )
14
14
  end
15
15
 
16
+
17
+ require 'fifa' ## get a list of all fifa countries with (three letter) codes
18
+
19
+
16
20
  ###
17
21
  # our own code
18
22
  require 'sportdb/config/version' # let version always go first
@@ -41,7 +45,7 @@ class Test ## todo/check: works with module too? use a module - why? why not?
41
45
 
42
46
  ####
43
47
  # todo/fix: find a better way to configure shared test datasets - why? why not?
44
- def self.data_dir() @data_dir ||= './datasets'; end
48
+ def self.data_dir() @data_dir ||= './test'; end
45
49
  def self.data_dir=( path ) @data_dir = path; end
46
50
  end
47
51
 
@@ -49,4 +53,5 @@ end # module SportDb
49
53
 
50
54
 
51
55
 
56
+
52
57
  puts SportDb::Boot.banner # say hello
@@ -9,15 +9,6 @@ require 'helper'
9
9
 
10
10
  class TestCountries < MiniTest::Test
11
11
 
12
- def test_read_countries
13
- recs = read_csv( "#{SportDb::Boot.data_dir}/world/countries.txt" )
14
- ## pp recs
15
-
16
- assert_equal [{ key:'af', fifa:'AFG', name:'Afghanistan'},
17
- { key:'al', fifa:'ALB', name:'Albania'}], recs[0..1]
18
- end
19
-
20
-
21
12
  def test_countries
22
13
  ## pp SportDb::Import.config.countries
23
14
 
@@ -31,12 +22,11 @@ class TestCountries < MiniTest::Test
31
22
  assert_equal 'Austria', at.name
32
23
  assert_equal 'AUT', at.fifa
33
24
 
34
- aut = SportDb::Import.config.countries[:aut]
35
- assert_equal 'at', aut.key
36
- assert_equal 'Austria', aut.name
37
- assert_equal 'AUT', aut.fifa
38
-
39
- assert aut == at
25
+ assert at == SportDb::Import.config.countries['AT']
26
+ assert at == SportDb::Import.config.countries['at']
27
+ assert at == SportDb::Import.config.countries['AUT']
28
+ assert at == SportDb::Import.config.countries['aut']
29
+ assert at == SportDb::Import.config.countries[:aut]
40
30
  end
41
31
 
42
32
  end # class TestCountries
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-08 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: csvreader
14
+ name: fifa
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.4
19
+ version: 0.1.1
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: 1.2.4
26
+ version: 0.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +59,7 @@ extensions: []
59
59
  extra_rdoc_files:
60
60
  - HISTORY.md
61
61
  - Manifest.txt
62
+ - NOTES.md
62
63
  - README.md
63
64
  - config/leagues/eng.txt
64
65
  - config/leagues/fr.txt
@@ -67,12 +68,12 @@ extra_rdoc_files:
67
68
  - config/world/ar.txt
68
69
  - config/world/at.txt
69
70
  - config/world/be.txt
70
- - config/world/countries.txt
71
71
  - config/world/de.txt
72
72
  - config/world/eng.txt
73
73
  files:
74
74
  - HISTORY.md
75
75
  - Manifest.txt
76
+ - NOTES.md
76
77
  - README.md
77
78
  - Rakefile
78
79
  - config/leagues/eng.txt
@@ -82,7 +83,6 @@ files:
82
83
  - config/world/ar.txt
83
84
  - config/world/at.txt
84
85
  - config/world/be.txt
85
- - config/world/countries.txt
86
86
  - config/world/de.txt
87
87
  - config/world/eng.txt
88
88
  - lib/sportdb/config.rb
@@ -1,307 +0,0 @@
1
- ##########################
2
- # FIFA country codes
3
- #
4
- # see en.wikipedia.org/wiki/List_of_FIFA_country_codes
5
- # and github.com/openmundi/world.db/blob/master/1-codes/fifa.txt
6
- # and www.rsssf.com/miscellaneous/fifa-codes.html
7
-
8
- ##
9
- # note: all dependencies n territories marked w/
10
- # (UK), (FR), (NZ), (AU), (US), (NL), (DK), (CN) etc.
11
-
12
-
13
- ###
14
- # todo: group by world.db "continents" - south america, africa, etc.
15
-
16
-
17
-
18
- #################
19
- ## 209 (now in 2019 211(!) which two got added ??) regular FIFA members
20
-
21
-
22
- Key, FIFA, Name
23
-
24
- af, AFG, Afghanistan
25
- al, ALB, Albania
26
- dz, ALG, Algeria
27
- as, ASA, American Samoa (US)
28
- ad, AND, Andorra
29
- ao, ANG, Angola
30
- ai, AIA, Anguilla (UK)
31
- ag, ATG, Antigua and Barbuda
32
- ar, ARG, Argentina
33
- am, ARM, Armenia
34
- aw, ARU, Aruba (NL)
35
- au, AUS, Australia
36
- at, AUT, Austria
37
- az, AZE, Azerbaijan
38
-
39
- bs, BAH, Bahamas
40
- bh, BHR, Bahrain
41
- bd, BAN, Bangladesh
42
- bb, BRB, Barbados
43
- by, BLR, Belarus
44
- be, BEL, Belgium
45
- bz, BLZ, Belize
46
- bj, BEN, Benin
47
- bm, BER, Bermuda (UK)
48
- bt, BHU, Bhutan
49
- bo, BOL, Bolivia
50
- ba, BIH, Bosnia and Herzegovina ## or use Bosnia-Herzegovina ?
51
- bw, BOT, Botswana
52
- br, BRA, Brazil
53
- bn, BRU, Brunei
54
- bg, BUL, Bulgaria
55
- bf, BFA, Burkina Faso
56
- bi, BDI, Burundi
57
-
58
- kh, CAM, Cambodia
59
- cm, CMR, Cameroon
60
- ca, CAN, Canada
61
- cv, CPV, Cabo Verde
62
- ky, CAY, Cayman Islands (UK)
63
- cf, CTA, Central African Republic
64
- td, CHA, Chad
65
- cl, CHI, Chile
66
- cn, CHN, China
67
- co, COL, Colombia
68
- km, COM, Comoros
69
- cg, CGO, Congo
70
- cd, COD, Congo DR
71
- ck, COK, Cook Islands (NZ)
72
- cr, CRC, Costa Rica
73
- hr, CRO, Croatia
74
- cu, CUB, Cuba
75
- cw, CUW, Curaçao (NL)
76
- cy, CYP, Cyprus
77
- cz, CZE, Czech Republic
78
- ci, CIV, Côte d'Ivoire # Ivory Coast
79
-
80
- dk, DEN, Denmark
81
- dj, DJI, Djibouti
82
- dm, DMA, Dominica
83
- do, DOM, Dominican Republic
84
-
85
- ec, ECU, Ecuador
86
- eg, EGY, Egypt
87
- eng, ENG, England (UK)
88
- gq, EQG, Equatorial Guinea
89
- er, ERI, Eritrea
90
- ee, EST, Estonia
91
- et, ETH, Ethiopia
92
- es, ESP, Spain
93
-
94
- fo, FRO, Faroe Islands (DK)
95
- fj, FIJ, Fiji
96
- fi, FIN, Finland
97
- fr, FRA, France
98
-
99
- ga, GAB, Gabon
100
- gm, GAM, Gambia
101
- ge, GEO, Georgia
102
- de, GER, Germany
103
- gh, GHA, Ghana
104
- gr, GRE, Greece
105
- gd, GRN, Grenada
106
- gu, GUM, Guam (US)
107
- gt, GUA, Guatemala
108
- gn, GUI, Guinea
109
- gw, GNB, Guinea-Bissau
110
- gy, GUY, Guyana
111
-
112
- ht, HAI, Haiti
113
- hn, HON, Honduras
114
- hk, HKG, Hong Kong (CN)
115
- hu, HUN, Hungary
116
-
117
- is, ISL, Iceland
118
- in, IND, India
119
- id, IDN, Indonesia
120
- ir, IRN, Iran
121
- iq, IRQ, Iraq
122
- il, ISR, Israel
123
- it, ITA, Italy
124
- ie, IRL, Ireland
125
-
126
- jm, JAM, Jamaica
127
- jp, JPN, Japan
128
- jo, JOR, Jordan
129
-
130
- kz, KAZ, Kazakhstan
131
- ke, KEN, Kenya
132
- kw, KUW, Kuwait
133
- kg, KGZ, Kyrgyzstan
134
- sa, KSA, Saudi Arabia
135
- kr, KOR, South Korea
136
-
137
- la, LAO, Laos
138
- lv, LVA, Latvia
139
- lb, LIB, Lebanon
140
- ls, LES, Lesotho
141
- lr, LBR, Liberia
142
- ly, LBY, Libya
143
- li, LIE, Liechtenstein
144
- lt, LTU, Lithuania
145
- lu, LUX, Luxembourg
146
- lc, LCA, Saint Lucia
147
-
148
- mo, MAC, Macao (CN)
149
- mk, MKD, Macedonia
150
- mg, MAD, Madagascar
151
- mw, MWI, Malawi
152
- my, MAS, Malaysia
153
- mv, MDV, Maldives
154
- ml, MLI, Mali
155
- mt, MLT, Malta
156
- mr, MTN, Mauritania
157
- mu, MRI, Mauritius
158
- mx, MEX, Mexico
159
- md, MDA, Moldova
160
- mn, MNG, Mongolia
161
- me, MNE, Montenegro
162
- ms, MSR, Montserrat (UK)
163
- ma, MAR, Morocco
164
- mz, MOZ, Mozambique
165
- mm, MYA, Myanmar
166
-
167
- na, NAM, Namibia
168
- np, NEP, Nepal
169
- nl, NED, Netherlands
170
- nc, NCL, New Caledonia (FR)
171
- nz, NZL, New Zealand
172
- ni, NCA, Nicaragua
173
- ne, NIG, Niger
174
- ng, NGA, Nigeria
175
- nir, NIR, Northern Ireland (UK)
176
- no, NOR, Norway
177
-
178
- om, OMA, Oman
179
-
180
- pk, PAK, Pakistan
181
- ps, PLE, Palestine
182
- pa, PAN, Panama
183
- pg, PNG, Papua New Guinea
184
- py, PAR, Paraguay
185
- pe, PER, Peru
186
- ph, PHI, Philippines
187
- pl, POL, Poland
188
- pt, POR, Portugal
189
- pr, PUR, Puerto Rico (US)
190
- kp, PRK, North Korea
191
-
192
- qa, QAT, Qatar
193
-
194
- ro, ROU, Romania
195
- ru, RUS, Russia
196
- rw, RWA, Rwanda
197
- za, RSA, South Africa
198
-
199
- kn, SKN, Saint Kitts and Nevis
200
- ws, SAM, Samoa
201
- sm, SMR, San Marino
202
- st, STP, São Tomé and Príncipe
203
- sco, SCO, Scotland (UK)
204
- sn, SEN, Senegal
205
- rs, SRB, Serbia
206
- sc, SEY, Seychelles
207
- sl, SLE, Sierra Leone
208
- sg, SIN, Singapore
209
- sk, SVK, Slovakia
210
- si, SVN, Slovenia
211
- sb, SOL, Solomon Islands
212
- so, SOM, Somalia
213
- ss, SSD, South Sudan
214
- lk, SRI, Sri Lanka
215
- sd, SDN, Sudan
216
- sr, SUR, Suriname
217
- sz, SWZ, Swaziland
218
- se, SWE, Sweden
219
- ch, SUI, Switzerland
220
- sy, SYR, Syria
221
- sv, SLV, El Salvador
222
-
223
- pf, TAH, Tahiti (FR) # todo/check: use French Polynesia (FR) as name - why? why not?
224
- tj, TJK, Tajikistan
225
- tz, TAN, Tanzania
226
- th, THA, Thailand
227
- tl, TLS, Timor-Leste
228
- tg, TOG, Togo
229
- to, TGA, Tonga
230
- tt, TRI, Trinidad and Tobago
231
- tn, TUN, Tunisia
232
- tr, TUR, Turkey
233
- tm, TKM, Turkmenistan
234
- tc, TCA, Turks and Caicos Islands (UK)
235
- tw, TPE, Taiwan # Chinese Tapei
236
-
237
- ug, UGA, Uganda
238
- ua, UKR, Ukraine
239
- ae, UAE, United Arab Emirates
240
- us, USA, United States
241
- uy, URU, Uruguay
242
- uz, UZB, Uzbekistan
243
-
244
- vu, VAN, Vanuatu
245
- ve, VEN, Venezuela
246
- vn, VIE, Vietnam
247
- vi, VIR, US Virgin Islands (US) # United States Virgin Islands; Virgin Islands (U.S.)
248
- vc, VIN, Saint Vincent and the Grenadines
249
- vg, VGB, British Virgin Islands (UK)
250
-
251
- wal, WAL, Wales (UK)
252
-
253
- ye, YEM, Yemen
254
-
255
- zm, ZAM, Zambia
256
- zw, ZIM, Zimbabwe
257
-
258
-
259
- ###################
260
- ## Non-FIFA member codes
261
-
262
- bq, BOE, Bonaire # CONCACAF
263
- gf, GYF, French Guiana (FR) # CONCACAF
264
- gp, GPE, Guadeloupe (FR) # CONCACAF
265
- mq, MTQ, Martinique (FR) # CONCACAF
266
- sx, SXM, Sint Maarten (NL) # CONCACAF
267
-
268
- gi, GIB, Gibraltar (UK) # UEFA
269
- xk, KOS, Kosovo # 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
270
-
271
- re, REU, Réunion (FR) # CAF
272
- zan, ZAN, Zanzibar (TZ) # CAF -- note: is a semi-autonomous region of Tanzania
273
-
274
- tv, TUV, Tuvalu # OFC
275
-
276
-
277
- ####################
278
- ## Irregular codes
279
-
280
- mp, NMI, Northern Mariana Islands (US) # AFC
281
-
282
- mf, SMT, Saint Martin (FR) # CONCACAF
283
-
284
- fm, FSM, Micronesia # OFC
285
- ki, KIR, Kiribati # OFC
286
- nu, NIU, Niue (NZ) # OFC
287
- pw, PLW, Palau # OFC
288
-
289
-
290
- #################
291
- # not members
292
- #
293
- # in europe:
294
- # - Great Britain - only all its member e.g. England/Wales/Scotland/Northern Irland
295
-
296
- va, VAT, Vatican City ## no "official" fifa code - listed in "irregular" codes
297
- mc, MCO, Monaco ## no "official" fifa code - listed in "irregular" codes
298
-
299
-
300
- #
301
- # in oceania:
302
- # - Kiribati
303
- # - Marshall Islands
304
- # - Micronesia
305
- # - Nauru
306
- # - Palau
307
- # - Tuvalu