sportdb-config 0.3.4 → 0.3.5

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
  SHA1:
3
- metadata.gz: 8e732ec27a048790023945b81ee4bfb641b511df
4
- data.tar.gz: c54dc64a1b019accb8337e1ef80d252338c8416c
3
+ metadata.gz: b96366c57a674d8504918759864f3b2d77242ab1
4
+ data.tar.gz: 867a992ef3dd1b31b5e360e0b2b80b123a2abff3
5
5
  SHA512:
6
- metadata.gz: d73d9aafbd977d57be80e230de8c9bb8d0090fe816ee235df9854e8d4f6877e1df863b74e1a22ff80ed360534141c46e7e1b23f1c219ebd418d3cf7d9c87d7f9
7
- data.tar.gz: 730cf120ff994ac024b462e164faf2aba875e3f3e29ee72d73e4594706cbe088253050f85b9557e78881061c923cea30b12ee278a9de5b38b2fbffe0152eb830
6
+ metadata.gz: 0c5197829655457ac0b38a8d995e611804f3e385cf25b78f0a4c4e83c68fececfed3d16c4b51201c6f4f0d8f29f9189e629dc20a30a602f4f534c46bc6eaf2ea
7
+ data.tar.gz: 676a5a68e7827b9c34c7d9b07ed9d5ab7894bff4514841f98fbf989c29049f17d44968b3032bbf3a00bc273f7917a572460f632b6aea4e6b404385cdd10bde89
data/Manifest.txt CHANGED
@@ -2,25 +2,27 @@ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- config/geos/eng.txt
6
5
  config/leagues/eng.txt
7
6
  config/leagues/fr.txt
8
7
  config/leagues/gr.txt
9
8
  config/leagues/sco.txt
9
+ config/world/countries.txt
10
+ config/world/eng.txt
10
11
  lib/sportdb/config.rb
12
+ lib/sportdb/config/club_reader.rb
13
+ lib/sportdb/config/clubs.rb
11
14
  lib/sportdb/config/config.rb
12
15
  lib/sportdb/config/countries.rb
13
16
  lib/sportdb/config/league.rb
14
17
  lib/sportdb/config/league_reader.rb
15
18
  lib/sportdb/config/league_utils.rb
16
19
  lib/sportdb/config/season_utils.rb
17
- lib/sportdb/config/team_reader.rb
18
20
  lib/sportdb/config/version.rb
19
21
  test/helper.rb
22
+ test/test_club_reader.rb
20
23
  test/test_clubs.rb
21
24
  test/test_config.rb
22
25
  test/test_countries.rb
23
26
  test/test_league_reader.rb
24
27
  test/test_league_utils.rb
25
28
  test/test_season_utils.rb
26
- test/test_team_reader.rb
data/Rakefile CHANGED
@@ -19,6 +19,10 @@ Hoe.spec 'sportdb-config' do
19
19
 
20
20
  self.licenses = ['Public Domain']
21
21
 
22
+ self.extra_deps = [
23
+ ['csvreader', '>= 1.2.4'],
24
+ ]
25
+
22
26
  self.spec_extras = {
23
27
  :required_ruby_version => '>= 2.2.2'
24
28
  }
@@ -0,0 +1,307 @@
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
File without changes
@@ -5,31 +5,7 @@ module SportDb
5
5
  module Import
6
6
 
7
7
 
8
- class TeamReader
9
-
10
- ##
11
- # note: use our own (internal) team struct for now - why? why not?
12
- # - check that shape/structure/fields/attributes match
13
- # the Team struct in sportdb-text (in SportDb::Struct::Team) !!!!
14
- class Team
15
- ## todo: use just names for alt_names - why? why not?
16
- attr_accessor :name, :alt_names, :year, :ground, :city
17
-
18
- ## more attribs - todo/fix - also add "upstream" to struct & model!!!!!
19
- attr_accessor :district, :geos, :year_end, :country
20
-
21
- def historic?() @year_end ? true : false; end
22
- alias_method :past?, :historic?
23
-
24
-
25
- def initialize
26
- @alt_names = []
27
- end
28
-
29
-
30
-
31
- end # class Team
32
-
8
+ class ClubReader
33
9
 
34
10
 
35
11
  def self.read( path ) ## use - rename to read_file or from_file etc. - why? why not?
@@ -89,12 +65,13 @@ def self.parse( txt )
89
65
  ## quick hack: if level is 1 assume country for now
90
66
  ## and extract country code e.g.
91
67
  ## Austria (at) => at
68
+ ## todo/fix: allow code only e.g. at or aut without enclosing () too - why? why not?
92
69
  if heading_level == 1
93
- if heading =~ /\(([a-z]{2,3})\)/
70
+ if heading =~ /\(([a-z]{2,3})\)/i ## note allow (at) or (AUT) too
94
71
  country_code = $1
95
72
 
96
73
  ## check country code - MUST exist for now!!!!
97
- country = SportDb::Import.config.countries[ country_code.to_sym ]
74
+ country = SportDb::Import.config.countries[ country_code ]
98
75
  if country.nil?
99
76
  puts "!!! error [team reader] - unknown country with code >#{country_code}< - sorry - add country to config to fix"
100
77
  exit 1
@@ -150,7 +127,7 @@ def self.parse( txt )
150
127
  else
151
128
  values = line.split( ',' )
152
129
 
153
- rec = Team.new
130
+ rec = Club.new
154
131
  value = values.shift ## get first item
155
132
  ## strip and squish (white)spaces
156
133
  # e.g. New York FC (2011-) => New York FC (2011-)
@@ -231,7 +208,7 @@ def self.parse( txt )
231
208
 
232
209
  ## 1) add country if present
233
210
  if headings.size > 0 && headings[0]
234
- country = SportDb::Import.config.countries[ headings[0].to_sym ]
211
+ country = SportDb::Import.config.countries[ headings[0] ]
235
212
  rec.country = country
236
213
  else
237
214
  ## make it an error - why? why not?
@@ -292,7 +269,7 @@ def self.split_geo( str )
292
269
  geos
293
270
  end
294
271
 
295
- end # class TeamReader
272
+ end # class ClubReader
296
273
 
297
274
 
298
275
  end ## module Import
@@ -0,0 +1,126 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDb
4
+ module Import
5
+
6
+ ##
7
+ # note: use our own (internal) club struct for now - why? why not?
8
+ # - check that shape/structure/fields/attributes match
9
+ # the Team struct in sportdb-text (in SportDb::Struct::Team) !!!!
10
+ class Club
11
+ ## todo: use just names for alt_names - why? why not?
12
+ attr_accessor :name, :alt_names, :year, :ground, :city
13
+
14
+ ## more attribs - todo/fix - also add "upstream" to struct & model!!!!!
15
+ attr_accessor :district, :geos, :year_end, :country
16
+
17
+ def historic?() @year_end ? true : false; end
18
+ alias_method :past?, :historic?
19
+
20
+ def initialize
21
+ @alt_names = []
22
+ end
23
+ end # class Club
24
+
25
+
26
+
27
+ class ClubIndex
28
+
29
+ def initialize
30
+ @clubs = {} ## clubs (indexed) by canonical name
31
+ @clubs_by_name = {}
32
+ @errors = []
33
+ end
34
+
35
+ attr_reader :errors
36
+ def errors?() @errors.empty? == false; end
37
+
38
+
39
+ def add( rec_or_recs ) ## add club record / alt_names
40
+ recs = rec_or_recs.is_a?( Array ) ? rec_or_recs : [rec_or_recs] ## wrap (single) rec in array
41
+
42
+ recs.each do |rec|
43
+ ## puts "adding:"
44
+ ## pp rec
45
+ ### step 1) add canonical name
46
+ old_rec = @clubs[ rec.name ]
47
+ if old_rec
48
+ puts "** !!! ERROR !!! - (canonical) name conflict - duplicate - >#{rec.name}< will overwrite >#{old_rec.name}<:"
49
+ pp old_rec
50
+ pp rec
51
+ exit 1
52
+ else
53
+ @clubs[ rec.name ] = rec
54
+ end
55
+
56
+ ## step 2) add all names (canonical name + alt names)
57
+ names = [rec.name] + rec.alt_names
58
+
59
+ ## check for duplicates - simple check for now - fix/improve
60
+ ## todo/fix: (auto)remove duplicates - why? why not?
61
+ count = names.size
62
+ count_uniq = names.uniq.size
63
+ if count != count_uniq
64
+ puts "** !!! ERROR !!! - #{count-count_uniq} duplicate name(s):"
65
+ pp rec
66
+ exit 1
67
+ end
68
+
69
+ names.each_with_index do |name,i|
70
+ alt_recs = @clubs_by_name[ name ]
71
+ if alt_recs
72
+ msg = "** !!! WARN !!! - name conflict/duplicate - >#{name}< will overwrite >#{alt_recs[0].name}, #{alt_recs[0].country.name}< with >#{rec.name}, #{rec.country.name}<"
73
+ puts msg
74
+ @errors << msg
75
+ alt_recs << rec
76
+ else
77
+ @clubs_by_name[ name ] = [rec]
78
+ end
79
+ end
80
+ end
81
+ end # method add
82
+
83
+
84
+ def []( name ) ## lookup by canoncial name only
85
+ @clubs[ name ]
86
+ end
87
+
88
+ def match( name )
89
+ ## todo/check: return empty array if no match!!! and NOT nil (add || []) - why? why not?
90
+ @clubs_by_name[ name ]
91
+ end
92
+
93
+
94
+ def match_by( name:, country: )
95
+ ## note: match must for now always include name
96
+ m = match( name )
97
+ if m ## filter by country
98
+ ## note: country assumes / allows the country key or fifa code for now
99
+ country_rec = SportDb::Import.config.countries[ country ]
100
+ if country_rec.nil?
101
+ puts "** !!! ERROR !!! - unknown country >#{country}< - no match found, sorry - add to world/countries.txt in config"
102
+ exit 1
103
+ end
104
+
105
+ m = m.select { |club| club.country.key == country_rec.key }
106
+ m = nil if m.empty? ## note: reset to nil if no more matches
107
+ end
108
+ m
109
+ end
110
+
111
+
112
+
113
+ def dump_duplicates # debug helper - report duplicate club name records
114
+ @clubs_by_name.each do |name, clubs|
115
+ if clubs.size > 1
116
+ puts "#{clubs.size} duplicates for >#{name}<:"
117
+ pp clubs
118
+ end
119
+ end
120
+ end
121
+
122
+ end # class ClubIndex
123
+
124
+
125
+ end # module Import
126
+ end # module SportDb
@@ -6,41 +6,36 @@ module SportDb
6
6
 
7
7
  class Configuration
8
8
 
9
-
10
- def team_mappings ## todo/fix: rename to clubs_mappings - why? why not?
11
- read_teams() if @team_mappings.nil?
12
- @team_mappings
9
+ ## todo/check: rename to country_mappings/index - why? why not?
10
+ ## or countries_by_code or countries_by_key
11
+ def countries
12
+ @countries ||= build_country_index
13
+ @countries
13
14
  end
14
15
 
15
- def teams ## todo/fix: rename to clubs - why? why not?
16
- read_teams() if @teams.nil?
17
- @teams
16
+ def build_country_index ## todo/check: rename to setup_country_index or read_country_index - why? why not?
17
+ recs = read_csv( "#{SportDb::Boot.data_dir}/world/countries.txt" )
18
+ CountryIndex.new( recs )
18
19
  end
19
20
 
20
- def leagues
21
- read_leagues() if @leagues.nil?
22
- @leagues
23
- end
24
21
 
25
22
 
23
+ def clubs
24
+ @clubs ||= build_club_index
25
+ @clubs
26
+ end
27
+
26
28
  ####
27
29
  # todo/fix: find a better way to configure club / team datasets
28
30
  attr_accessor :clubs_dir
29
31
  def clubs_dir() @clubs_dir ||= './clubs'; end
30
32
 
31
33
 
32
- CLUBS_REGEX1 = %r{ (?:^|/) # beginning (^) or beginning of path (/)
33
- (?<country>[a-z]{1,3})\.clubs\.txt$
34
- }x
35
-
36
- CLUBS_REGEX2 = %r{ (?:^|/) # beginning (^) or beginning of path (/)
37
- (?<country>[a-z]{2,3})-[^/]+?
38
- /clubs\.txt$
34
+ CLUBS_REGEX = %r{ (?:^|/) # beginning (^) or beginning of path (/)
35
+ (?:[a-z]{1,3}\.)? # optional country code/key e.g. eng.clubs.txt
36
+ clubs\.txt$
39
37
  }x
40
38
 
41
- CLUBS_REGEX = Regexp.union( CLUBS_REGEX1, CLUBS_REGEX2 )
42
-
43
-
44
39
  def find_clubs_datafiles( path )
45
40
  datafiles = [] ## note: [country, path] pairs for now
46
41
 
@@ -48,106 +43,15 @@ class Configuration
48
43
  candidates = Dir.glob( "#{path}/**/*.txt" )
49
44
  pp candidates
50
45
  candidates.each do |candidate|
51
- m = CLUBS_REGEX.match( candidate )
52
- if m
53
- datafiles << [m[:country], candidate]
54
- end
46
+ datafiles << candidate if CLUBS_REGEX.match( candidate )
55
47
  end
56
48
 
57
49
  pp datafiles
58
50
  datafiles
59
51
  end
60
52
 
61
- =begin
62
- CLUBS_DATAFILES = { ## path by country to clubs.txt
63
- de: 'europe/de-deutschland',
64
- fr: 'europe/fr-france',
65
- mc: 'europe/mc-monaco',
66
- es: 'europe/es-espana',
67
- it: 'europe/it-italy',
68
- pt: 'europe/pt-portugal',
69
- nl: 'europe/nl-netherlands',
70
- be: 'europe/be-belgium',
71
- tr: 'europe/tr-turkey',
72
- gr: 'europe/gr-greece',
73
- eng: 'europe/eng-england',
74
- wal: 'europe/wal-wales',
75
- sco: 'europe/sco-scotland',
76
- nir: 'europe/nir-northern-ireland',
77
- at: 'europe/at-austria',
78
- al: 'europe/al-albania',
79
- bg: 'europe/bg-bulgaria',
80
- by: 'europe/by-belarus',
81
- ch: 'europe/ch-confoederatio-helvetica',
82
- cy: 'europe/cy-cyprus',
83
- cz: 'europe/cz-czech-republic',
84
- dk: 'europe/dk-denmark',
85
- fi: 'europe/fi-finland',
86
- ge: 'europe/ge-georgia',
87
- hr: 'europe/hr-croatia',
88
- hu: 'europe/hu-hungary',
89
- ie: 'europe/ie-ireland',
90
- is: 'europe/is-iceland',
91
- lu: 'europe/lu-luxembourg',
92
- md: 'europe/md-moldova',
93
- mt: 'europe/mt-malta',
94
- no: 'europe/no-norway',
95
- pl: 'europe/pl-poland',
96
- ro: 'europe/ro-romania',
97
- rs: 'europe/rs-serbia',
98
- ru: 'europe/ru-russia',
99
- se: 'europe/se-sweden',
100
- si: 'europe/si-slovenia',
101
- sk: 'europe/sk-slovakia',
102
- ua: 'europe/ua-ukraine',
103
- mx: 'north-america/mx-mexico',
104
- us: 'north-america/us-united-states',
105
- ca: 'north-america/ca-canada',
106
- ar: 'south-america/ar-argentina',
107
- br: 'south-america/br-brazil',
108
- jp: 'asia/jp-japan',
109
- cn: 'asia/cn-china' }
110
- =end
111
-
112
-
113
-
114
- class ClubsHash ## todo/check: use (rename to) ClubsMapping(s) - why? why not?
115
- def initialize
116
- @h = {}
117
- @errors = []
118
- end
119
-
120
- attr_reader :errors
121
- def errors?() @errors.empty? == false; end
122
-
123
- def add( rec ) ## add club record / alt_names
124
- rec.alt_names.each do |alt_name|
125
- alt_recs = @h[ alt_name ]
126
- if alt_recs
127
- msg = "** !!! WARN !!! - alt name conflict/duplicate - >#{alt_name}< will overwrite >#{alt_recs[0].name}, #{alt_recs[0].country.name}< with >#{rec.name}, #{rec.country.name}<"
128
- puts msg
129
- @errors << msg
130
- alt_recs << rec
131
- else
132
- @h[ alt_name ] = [rec]
133
- end
134
- end
135
- end
136
53
 
137
- def fetch( alt_name ) @h[alt_name]; end
138
- def []( alt_name ) ## quick fix: for now returns first name; use fetch for recs array for now!!!
139
- ## keep "compatible" with old code for now
140
- alt_recs = @h[ alt_name ]
141
- if alt_recs
142
- alt_recs[0].name ## use canonical name of first match for now
143
- else
144
- nil # nothing found
145
- end
146
- end
147
- end # class ClubHash
148
-
149
-
150
- def read_teams ## todo/fix: rename to read_clubs - why? why not?
54
+ def build_club_index
151
55
  ## unify team names; team (builtin/known/shared) name mappings
152
56
  ## cleanup team names - use local ("native") name with umlaut etc.
153
57
  recs = []
@@ -159,61 +63,32 @@ class Configuration
159
63
  ## check that name and alt_names for a club are all unique (not duplicates)
160
64
  datafiles = find_clubs_datafiles( clubs_dir )
161
65
  datafiles.each do |datafile|
162
- country = datafile[0] ## country code e.g. eng, at, de, etc.
163
- path = datafile[1]
164
- recs += TeamReader.read( path )
66
+ recs += ClubReader.read( datafile )
165
67
  end
166
68
 
167
- ############################
168
- ## add team mappings
169
- ## alt names to canonical pretty (recommended unique) name
170
- @team_mappings = ClubsHash.new
171
- recs.each { |rec| @team_mappings.add( rec ) }
172
-
173
- ###
174
- ## reverse hash for lookup/list of "official / registered(?)"
175
- ## pretty recommended canonical unique (long form)
176
- ## team names
177
-
178
- @teams = {}
179
- recs.each do |rec|
180
- old_rec = @teams[ rec.name ]
181
- if old_rec
182
- puts "** !!! ERROR !!! - (canonical) name conflict - duplicate - >#{rec.name}< will overwrite >#{old_rec.name}<:"
183
- pp old_rec
184
- pp rec
185
- exit 1
186
- else
187
- @teams[ rec.name ] = rec
188
-
189
- ## note: check if there's an alternative name registered
190
- ## for the canonical name
191
- ## todo/fix: find a better scheme for (alt) name mapping - why? why not?
192
- ## allow alt names same as canonical names if not is the same club/record - why? why not?
193
- alt_recs = @team_mappings.fetch( rec.name )
194
- if alt_recs
195
- puts "** !!! ERROR !!! - (canonical) name conflict - >#{rec.name}< registered already as alternative name mapping:"
196
- pp alt_recs
197
-
198
- ## note: exit now only if it's the same club (that has alt name that is the canonical name)
199
- exit 1 if alt_recs.include?(rec)
200
- end
201
- end
202
- end
203
69
 
204
- if @team_mappings.errors?
70
+ clubs = ClubIndex.new
71
+ clubs.add( recs )
72
+
73
+ if clubs.errors?
205
74
  puts ""
206
75
  puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
207
- puts " #{@team_mappings.errors.size} errors:"
208
- pp @team_mappings.errors
76
+ puts " #{clubs.errors.size} errors:"
77
+ pp clubs.errors
209
78
  ## exit 1
210
79
  end
211
80
 
212
- self ## return self for chaining
213
- end
81
+ clubs
82
+ end # method build_club_index
83
+
214
84
 
215
85
 
216
86
 
87
+ def leagues
88
+ read_leagues() if @leagues.nil?
89
+ @leagues
90
+ end
91
+
217
92
  def read_leagues
218
93
  #####
219
94
  # add / read-in leagues config
@@ -3,154 +3,75 @@
3
3
  module SportDb
4
4
  module Import
5
5
 
6
- class Configuration
7
-
8
- ## built-in countries for (quick starter) auto-add
9
- COUNTRIES = { ## rename to AUTO or BUILTIN_COUNTRIES or QUICK_COUNTRIES - why? why not?
10
- ## british isles
11
- eng: ['England', 'ENG'], ## title/name, code
12
- sco: ['Scotland', 'SCO'],
13
- ie: ['Ireland', 'IRL'],
14
- wal: ['Wales', 'WAL'],
15
- nir: ['Northern Ireland', 'NIR'],
16
-
17
- ## central europe
18
- at: ['Austria', 'AUT'],
19
- de: ['Germany', 'GER'], ## use fifa code or iso? - using fifa for now
20
- ch: ['Switzerland', 'SUI'],
21
- li: ['Liechtenstein', 'LIE'],
22
- pl: ['Poland', 'POL'],
23
- cz: ['Czech Republic', 'CZE'],
24
- sk: ['Slovakia', 'SVK'],
25
- hu: ['Hungary', 'HUN'],
26
- si: ['Slovenia', 'SVN'],
27
-
28
- ## western europe
29
- be: ['Belgium', 'BEL'],
30
- nl: ['Netherlands', 'NED'],
31
- lu: ['Luxembourg', 'LUX'],
32
- fr: ['France', 'FRA'],
33
- mc: ['Monaco', 'MCO'],
34
- es: ['Spain', 'ESP'],
35
- ad: ['Andorra', 'AND'],
36
-
37
- ## northern europe / skandinavia
38
- dk: ['Denmark', 'DEN'],
39
- fi: ['Finland', 'FIN'],
40
- no: ['Norway', 'NOR'],
41
- se: ['Sweden', 'SWE'],
42
-
43
- ## eastern europe
44
- ro: ['Romania', 'ROU'],
45
- ru: ['Russia', 'RUS'],
46
- al: ['Albania', 'ALB'],
47
- am: ['Armenia', 'ARM'],
48
- az: ['Azerbaijan', 'AZE'],
49
- ba: ['Bosnia and Herzegovina', 'BIH'],
50
- bg: ['Bulgaria', 'BUL'],
51
- by: ['Belarus', 'BLR'],
52
-
53
- ## more european
54
- cy: ['Cyprus', 'CYP'],
55
- is: ['Iceland', 'ISL'],
56
- fo: ['Faroe Islands', 'FRO'],
57
- ge: ['Georgia', 'GEO'],
58
- gi: ['Gibraltar', 'GIB'],
59
- gr: ['Greece', 'GRE'],
60
- hr: ['Croatia', 'CRO'],
61
- it: ['Italy', 'ITA'],
62
- sm: ['San Marino', 'SMR'],
63
- ee: ['Estonia', 'EST'],
64
- lt: ['Lithuania', 'LTU'],
65
- lv: ['Latvija', 'LVA'],
66
- md: ['Moldova', 'MDA'],
67
- me: ['Montenegro', 'MNE'],
68
- mk: ['Macedonia', 'MKD'],
69
- mt: ['Malta', 'MLT'],
70
- pt: ['Portugal', 'POR'],
71
- rs: ['Serbia', 'SRB'],
72
- tr: ['Turkey', 'TUR'],
73
- ua: ['Ukraine', 'UKR'],
74
-
75
-
76
- ## north america
77
- us: ['United States', 'USA'],
78
- mx: ['Mexico', 'MEX'],
79
- ca: ['Canada', 'CAN'],
80
-
81
- ## caribbean
82
- ht: ['Haiti', 'HAI'],
83
- pr: ['Puerto Rico', 'PUR'],
84
- tt: ['Trinidad and Tobago', 'TRI'],
85
-
86
- ## central america
87
- cr: ['Costa Rica', 'CRC'],
88
- gt: ['Guatemala', 'GUA'],
89
- hn: ['Honduras', 'HON'],
90
- ni: ['Nicaragua', 'NCA'],
91
- pa: ['Panama', 'PAN'],
92
- sv: ['El Salvador', 'SLV'],
93
-
94
-
95
- ## south america
96
- ar: ['Argentina', 'ARG'],
97
- br: ['Brazil', 'BRA'],
98
- bo: ['Bolivia', 'BOL'],
99
- cl: ['Chile', 'CHI'],
100
- co: ['Colombia', 'COL'],
101
- ec: ['Ecuador', 'ECU'],
102
- gy: ['Guyana', 'GUY'],
103
- pe: ['Peru', 'PER'],
104
- py: ['Paraguay', 'PAR'],
105
- uy: ['Uruguay', 'URU'],
106
- ve: ['Venezuela', 'VEN'],
107
-
108
- ## middle east
109
- il: ['Israel', 'ISR'],
6
+ ## built-in countries for (quick starter) auto-add
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
110
21
 
111
- ## asia
112
- cn: ['China', 'CHN'],
113
- jp: ['Japan', 'JPN'],
114
- kz: ['Kazakhstan', 'KAZ'],
115
- kr: ['South Korea', 'KOR'],
116
22
 
117
- ## africa
118
- eg: ['Egypt', 'EGY'],
119
- ma: ['Morocco', 'MAR'],
23
+ class CountryIndex
120
24
 
121
- ## pacific
122
- au: ['Australia', 'AUS'],
123
- nz: ['New Zealand', 'NZL'],
124
- }
25
+ def initialize( recs )
26
+ @countries = []
27
+ @countries_by_code = {}
125
28
 
29
+ add( recs )
30
+ end
126
31
 
127
- ##
128
- # note: use our own (internal) country struct for now - why? why not?
129
- # - check that shape/structure/fields/attributes match
130
- # the Country struct in sportdb-text (in SportDb::Struct::Country)
131
- ## and the ActiveRecord model !!!!
132
- class Country
133
- ## note: is read-only/immutable for now - why? why not?
134
- ## add cities (array/list) - why? why not?
135
- attr_reader :key, :name, :code
136
- def initialize( key, name, code )
137
- @key, @name, @code = key, name, code
32
+ def add( recs )
33
+ ###########################################
34
+ ## auto-fill countries
35
+ ## pp recs
36
+ recs.each do |rec|
37
+ ## rec e.g. { key:'af', fifa:'AFG', name:'Afghanistan'}
38
+
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
48
+
49
+ ## add codes lookups - key, fifa, ...
50
+ if @countries_by_code[ country.key ]
51
+ puts "** !! ERROR !! country code (key) >#{country.key}< already exits!!"
52
+ exit 1
53
+ else
54
+ @countries_by_code[ country.key ] = country
55
+ end
56
+
57
+ ## 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!!"
61
+ exit 1
62
+ else
63
+ @countries_by_code[ country.fifa.downcase ] = country
64
+ end
65
+ end
138
66
  end
139
- end # class Country
67
+ end # method initialize
140
68
 
141
- ## todo/check: rename to country_mappings - why? why not?
142
- ## or countries_by_code or countries_by_key
143
- def countries
144
- ## note: convertcountry data to "proper" struct
145
- @countries ||= COUNTRIES.each.reduce({}) do |h,(key,value)|
146
- ## note: convert key (e.g. :eng to string e.g. 'eng')
147
- h[key] = Country.new( key.to_s, value[0], value[1] )
148
- h
149
- end
150
- @countries
69
+ def []( key )
70
+ key = key.to_s.downcase ## allow symbols (and always downcase e.g. AUT to aut etc.)
71
+ @countries_by_code[ key ]
151
72
  end
73
+ end # class CountryIndex
74
+
152
75
 
153
- end # class Configuration
154
76
  end # module Import
155
77
  end # module SportDb
156
-
@@ -8,7 +8,7 @@ module Boot ## note: use a different module than Config to avoid confusion
8
8
 
9
9
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
10
10
  MINOR = 3
11
- PATCH = 4
11
+ PATCH = 5
12
12
  VERSION = [MAJOR,MINOR,PATCH].join('.')
13
13
 
14
14
  def self.version
@@ -28,9 +28,5 @@ module Boot ## note: use a different module than Config to avoid confusion
28
28
  end
29
29
 
30
30
 
31
- # def self.test_data_dir
32
- # "#{root}/test/data"
33
- # end
34
-
35
31
  end # module Boot
36
32
  end # module SportDb
@@ -6,6 +6,12 @@ require 'date'
6
6
  require 'fileutils'
7
7
 
8
8
 
9
+ ## 3rd party gems
10
+ require 'csvreader'
11
+
12
+ def read_csv( path )
13
+ CsvHash.read( path, :header_converters => :symbol )
14
+ end
9
15
 
10
16
  ###
11
17
  # our own code
@@ -15,9 +21,10 @@ require 'sportdb/config/season_utils'
15
21
  require 'sportdb/config/league_utils'
16
22
  require 'sportdb/config/league'
17
23
  require 'sportdb/config/league_reader'
18
- require 'sportdb/config/team_reader'
19
24
 
20
25
  require 'sportdb/config/countries'
26
+ require 'sportdb/config/clubs'
27
+ require 'sportdb/config/club_reader'
21
28
  require 'sportdb/config/config'
22
29
 
23
30
 
@@ -2,15 +2,15 @@
2
2
 
3
3
  ###
4
4
  # to run use
5
- # ruby -I ./lib -I ./test test/test_team_reader.rb
5
+ # ruby -I ./lib -I ./test test/test_club_reader.rb
6
6
 
7
7
 
8
8
  require 'helper'
9
9
 
10
- class TestTeamReader < MiniTest::Test
10
+ class TestClubReader < MiniTest::Test
11
11
 
12
12
  def test_parse_at
13
- recs = SportDb::Import::TeamReader.parse( <<TXT )
13
+ recs = SportDb::Import::ClubReader.parse( <<TXT )
14
14
  ==================================
15
15
  = Austria (at)
16
16
 
@@ -29,7 +29,7 @@ TXT
29
29
  end
30
30
 
31
31
  def test_parse_us
32
- recs = SportDb::Import::TeamReader.parse( <<TXT )
32
+ recs = SportDb::Import::ClubReader.parse( <<TXT )
33
33
  ==================================================
34
34
  = United States (us)
35
35
 
@@ -59,7 +59,7 @@ TXT
59
59
 
60
60
 
61
61
  def test_parse_years
62
- recs = SportDb::Import::TeamReader.parse( <<TXT )
62
+ recs = SportDb::Import::ClubReader.parse( <<TXT )
63
63
  = United States (us)
64
64
  FC Dallas (1996-), Frisco › Texas
65
65
  Miami Fusion (1998-2001), Fort Lauderdale › Florida
@@ -84,7 +84,7 @@ TXT
84
84
  end
85
85
 
86
86
  def test_parse_geos
87
- recs = SportDb::Import::TeamReader.parse( <<TXT )
87
+ recs = SportDb::Import::ClubReader.parse( <<TXT )
88
88
  = England (eng)
89
89
  == Greater London
90
90
 
@@ -123,7 +123,7 @@ TXT
123
123
 
124
124
 
125
125
  def test_parse_headings
126
- recs = SportDb::Import::TeamReader.parse( <<TXT )
126
+ recs = SportDb::Import::ClubReader.parse( <<TXT )
127
127
  ==============
128
128
  ====
129
129
  ===========
@@ -147,4 +147,4 @@ TXT
147
147
  assert_equal 0, recs.size
148
148
  end
149
149
 
150
- end # class TestTeamReader
150
+ end # class TestClubReader
data/test/test_clubs.rb CHANGED
@@ -9,28 +9,45 @@ require 'helper'
9
9
 
10
10
  class TestClubs < MiniTest::Test
11
11
 
12
+ def test_clubs
13
+ ## todo/check: move config.clubs_dir to test/helper for global setting - why? why not?
14
+ SportDb::Import.config.clubs_dir = '../../../openfootball/clubs'
12
15
 
13
- def match1( txt ) SportDb::Import::Configuration::CLUBS_REGEX1.match( txt ); end
14
- def match2( txt ) SportDb::Import::Configuration::CLUBS_REGEX2.match( txt ); end
16
+ pp SportDb::Import.config.clubs.errors
15
17
 
16
- def test_find_clubs
17
- m = match1( 'de.clubs.txt' )
18
- assert_equal 'de', m[:country]
18
+ SportDb::Import.config.clubs.dump_duplicates
19
19
 
20
- m = match1( 'deutschland/de.clubs.txt' )
21
- assert_equal 'de', m[:country]
20
+ m = SportDb::Import.config.clubs.match( 'Rapid Wien' )
21
+ assert_equal 'SK Rapid Wien', m[0].name
22
+ assert_equal 'Austria', m[0].country.name
23
+ assert_equal 'Wien', m[0].city
22
24
 
23
- m = match2( 'europe/de-deutschland/clubs.txt' )
24
- assert_equal 'de', m[:country]
25
+ c = SportDb::Import.config.clubs[ 'SK Rapid Wien' ] ## check canoncial name match (only)
26
+ assert_equal 'SK Rapid Wien', c.name
27
+ assert_equal 'Austria', c.country.name
28
+ assert_equal 'Wien', c.city
25
29
 
26
- m = match2( 'de-deutschland/clubs.txt' )
27
- assert_equal 'de', m[:country]
28
30
 
31
+ m = SportDb::Import.config.clubs.match( 'Arsenal' )
32
+ assert_equal 3, m.size
29
33
 
30
- assert match1( 'clubs.txt' ) == nil
31
- assert match2( 'clubs.txt' ) == nil
32
- assert match1( 'deutschland/clubs.txt' ) == nil
33
- assert match2( 'deutschland/clubs.txt' ) == nil
34
+ m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'eng' )
35
+ assert_equal 1, m.size
36
+ assert_equal 'Arsenal FC', m[0].name
37
+ assert_equal 'England', m[0].country.name
38
+ assert_equal 'London', m[0].city
39
+
40
+ m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ar' )
41
+ assert_equal 1, m.size
42
+ assert_equal 'Arsenal de Sarandí', m[0].name
43
+ assert_equal 'Argentina', m[0].country.name
44
+ assert_equal 'Sarandí', m[0].city
45
+
46
+ m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ru' )
47
+ assert_equal 1, m.size
48
+ assert_equal 'Arsenal Tula', m[0].name
49
+ assert_equal 'Russia', m[0].country.name
50
+ assert_equal 'Tula', m[0].city
34
51
  end
35
52
 
36
53
  end # class TestClubs
data/test/test_config.rb CHANGED
@@ -9,12 +9,15 @@ require 'helper'
9
9
 
10
10
  class TestConfig < MiniTest::Test
11
11
 
12
- def test_clubs
13
- SportDb::Import.config.clubs_dir = '../../../openfootball/clubs'
14
-
15
- SportDb::Import.config.teams
16
-
17
- assert true ## assume ok if we get here
18
- end # method test_clubs
12
+ def match( txt ) SportDb::Import::Configuration::CLUBS_REGEX.match( txt ); end
13
+
14
+ def test_find_clubs
15
+ assert match( 'de.clubs.txt' )
16
+ assert match( 'deutschland/de.clubs.txt' )
17
+ assert match( 'europe/de-deutschland/clubs.txt' )
18
+ assert match( 'de-deutschland/clubs.txt' )
19
+ assert match( 'clubs.txt' )
20
+ assert match( 'deutschland/clubs.txt' )
21
+ end
19
22
 
20
23
  end # class TestConfig
@@ -9,18 +9,34 @@ 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
+
12
21
  def test_countries
13
- pp SportDb::Import.config.countries
22
+ ## pp SportDb::Import.config.countries
14
23
 
15
24
  eng = SportDb::Import.config.countries[:eng]
16
25
  assert_equal 'eng', eng.key
17
26
  assert_equal 'England', eng.name
18
- assert_equal 'ENG', eng.code
27
+ assert_equal 'ENG', eng.fifa
19
28
 
20
29
  at = SportDb::Import.config.countries[:at]
21
30
  assert_equal 'at', at.key
22
31
  assert_equal 'Austria', at.name
23
- assert_equal 'AUT', at.code
32
+ assert_equal 'AUT', at.fifa
33
+
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
24
40
  end
25
41
 
26
42
  end # class TestCountries
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
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-07-21 00:00:00.000000000 Z
11
+ date: 2019-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: csvreader
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.4
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rdoc
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -46,38 +60,41 @@ extra_rdoc_files:
46
60
  - HISTORY.md
47
61
  - Manifest.txt
48
62
  - README.md
49
- - config/geos/eng.txt
50
63
  - config/leagues/eng.txt
51
64
  - config/leagues/fr.txt
52
65
  - config/leagues/gr.txt
53
66
  - config/leagues/sco.txt
67
+ - config/world/countries.txt
68
+ - config/world/eng.txt
54
69
  files:
55
70
  - HISTORY.md
56
71
  - Manifest.txt
57
72
  - README.md
58
73
  - Rakefile
59
- - config/geos/eng.txt
60
74
  - config/leagues/eng.txt
61
75
  - config/leagues/fr.txt
62
76
  - config/leagues/gr.txt
63
77
  - config/leagues/sco.txt
78
+ - config/world/countries.txt
79
+ - config/world/eng.txt
64
80
  - lib/sportdb/config.rb
81
+ - lib/sportdb/config/club_reader.rb
82
+ - lib/sportdb/config/clubs.rb
65
83
  - lib/sportdb/config/config.rb
66
84
  - lib/sportdb/config/countries.rb
67
85
  - lib/sportdb/config/league.rb
68
86
  - lib/sportdb/config/league_reader.rb
69
87
  - lib/sportdb/config/league_utils.rb
70
88
  - lib/sportdb/config/season_utils.rb
71
- - lib/sportdb/config/team_reader.rb
72
89
  - lib/sportdb/config/version.rb
73
90
  - test/helper.rb
91
+ - test/test_club_reader.rb
74
92
  - test/test_clubs.rb
75
93
  - test/test_config.rb
76
94
  - test/test_countries.rb
77
95
  - test/test_league_reader.rb
78
96
  - test/test_league_utils.rb
79
97
  - test/test_season_utils.rb
80
- - test/test_team_reader.rb
81
98
  homepage: https://github.com/sportdb/sport.db
82
99
  licenses:
83
100
  - Public Domain