sportdb-config 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/lib/sportdb/config/config.rb +72 -32
- data/lib/sportdb/config/countries.rb +78 -122
- data/lib/sportdb/config/team_reader.rb +2 -1
- data/lib/sportdb/config/version.rb +1 -1
- data/test/test_clubs.rb +36 -0
- data/test/test_config.rb +2 -29
- data/test/test_team_reader.rb +6 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e732ec27a048790023945b81ee4bfb641b511df
|
4
|
+
data.tar.gz: c54dc64a1b019accb8337e1ef80d252338c8416c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d73d9aafbd977d57be80e230de8c9bb8d0090fe816ee235df9854e8d4f6877e1df863b74e1a22ff80ed360534141c46e7e1b23f1c219ebd418d3cf7d9c87d7f9
|
7
|
+
data.tar.gz: 730cf120ff994ac024b462e164faf2aba875e3f3e29ee72d73e4594706cbe088253050f85b9557e78881061c923cea30b12ee278a9de5b38b2fbffe0152eb830
|
data/Manifest.txt
CHANGED
@@ -6,16 +6,13 @@ module SportDb
|
|
6
6
|
|
7
7
|
class Configuration
|
8
8
|
|
9
|
-
def initialize
|
10
|
-
@errors = [] ## make parsing errors "global" for now
|
11
|
-
end
|
12
9
|
|
13
|
-
def team_mappings
|
10
|
+
def team_mappings ## todo/fix: rename to clubs_mappings - why? why not?
|
14
11
|
read_teams() if @team_mappings.nil?
|
15
12
|
@team_mappings
|
16
13
|
end
|
17
14
|
|
18
|
-
def teams
|
15
|
+
def teams ## todo/fix: rename to clubs - why? why not?
|
19
16
|
read_teams() if @teams.nil?
|
20
17
|
@teams
|
21
18
|
end
|
@@ -29,12 +26,9 @@ class Configuration
|
|
29
26
|
####
|
30
27
|
# todo/fix: find a better way to configure club / team datasets
|
31
28
|
attr_accessor :clubs_dir
|
32
|
-
attr_accessor :errors
|
33
|
-
|
34
29
|
def clubs_dir() @clubs_dir ||= './clubs'; end
|
35
30
|
|
36
31
|
|
37
|
-
|
38
32
|
CLUBS_REGEX1 = %r{ (?:^|/) # beginning (^) or beginning of path (/)
|
39
33
|
(?<country>[a-z]{1,3})\.clubs\.txt$
|
40
34
|
}x
|
@@ -116,13 +110,53 @@ class Configuration
|
|
116
110
|
=end
|
117
111
|
|
118
112
|
|
119
|
-
|
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
|
+
|
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?
|
120
151
|
## unify team names; team (builtin/known/shared) name mappings
|
121
152
|
## cleanup team names - use local ("native") name with umlaut etc.
|
122
153
|
recs = []
|
123
|
-
@errors = [] ## reset errors
|
124
154
|
|
125
155
|
## todo/fix: pass along / use country code too
|
156
|
+
## note: country code no longer needed in path (is now expected as heading inside the file)
|
157
|
+
|
158
|
+
## todo/fix: add to teamreader
|
159
|
+
## check that name and alt_names for a club are all unique (not duplicates)
|
126
160
|
datafiles = find_clubs_datafiles( clubs_dir )
|
127
161
|
datafiles.each do |datafile|
|
128
162
|
country = datafile[0] ## country code e.g. eng, at, de, etc.
|
@@ -133,40 +167,45 @@ class Configuration
|
|
133
167
|
############################
|
134
168
|
## add team mappings
|
135
169
|
## alt names to canonical pretty (recommended unique) name
|
136
|
-
@team_mappings =
|
137
|
-
|
138
|
-
recs.each do |rec|
|
139
|
-
rec.alt_names.each do |alt_name|
|
140
|
-
name = @team_mappings[ alt_name ]
|
141
|
-
if name ## todo/fix: add better warn about duplicates (if key exits) ???????
|
142
|
-
msg = "** !!! WARN !!! - alt name conflict/duplicate - >#{alt_name}< will overwrite >#{name}< with >#{rec.name}<"
|
143
|
-
puts msg
|
144
|
-
@errors << msg
|
145
|
-
else
|
146
|
-
@team_mappings[ alt_name ] = rec.name
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
170
|
+
@team_mappings = ClubsHash.new
|
171
|
+
recs.each { |rec| @team_mappings.add( rec ) }
|
150
172
|
|
151
173
|
###
|
152
174
|
## reverse hash for lookup/list of "official / registered(?)"
|
153
175
|
## pretty recommended canonical unique (long form)
|
154
176
|
## team names
|
155
177
|
|
156
|
-
|
157
|
-
##
|
158
|
-
## todo/fix: move to new TeamConfig class (for reuse) !!!!!!
|
159
|
-
## todo/fix: add check for duplicates/conflicts too!!!
|
160
178
|
@teams = {}
|
161
179
|
recs.each do |rec|
|
162
|
-
@teams[ rec.name ]
|
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
|
163
202
|
end
|
164
203
|
|
165
|
-
if @errors
|
204
|
+
if @team_mappings.errors?
|
166
205
|
puts ""
|
167
206
|
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
168
|
-
puts " #{@errors.size} errors:"
|
169
|
-
pp @errors
|
207
|
+
puts " #{@team_mappings.errors.size} errors:"
|
208
|
+
pp @team_mappings.errors
|
170
209
|
## exit 1
|
171
210
|
end
|
172
211
|
|
@@ -174,6 +213,7 @@ class Configuration
|
|
174
213
|
end
|
175
214
|
|
176
215
|
|
216
|
+
|
177
217
|
def read_leagues
|
178
218
|
#####
|
179
219
|
# add / read-in leagues config
|
@@ -8,24 +8,34 @@ class Configuration
|
|
8
8
|
## built-in countries for (quick starter) auto-add
|
9
9
|
COUNTRIES = { ## rename to AUTO or BUILTIN_COUNTRIES or QUICK_COUNTRIES - why? why not?
|
10
10
|
## british isles
|
11
|
-
eng: ['England',
|
12
|
-
sco: ['Scotland',
|
13
|
-
ie: ['Ireland',
|
11
|
+
eng: ['England', 'ENG'], ## title/name, code
|
12
|
+
sco: ['Scotland', 'SCO'],
|
13
|
+
ie: ['Ireland', 'IRL'],
|
14
|
+
wal: ['Wales', 'WAL'],
|
15
|
+
nir: ['Northern Ireland', 'NIR'],
|
14
16
|
|
15
17
|
## central europe
|
16
18
|
at: ['Austria', 'AUT'],
|
17
19
|
de: ['Germany', 'GER'], ## use fifa code or iso? - using fifa for now
|
18
|
-
ch: ['Switzerland', '
|
20
|
+
ch: ['Switzerland', 'SUI'],
|
21
|
+
li: ['Liechtenstein', 'LIE'],
|
19
22
|
pl: ['Poland', 'POL'],
|
23
|
+
cz: ['Czech Republic', 'CZE'],
|
24
|
+
sk: ['Slovakia', 'SVK'],
|
25
|
+
hu: ['Hungary', 'HUN'],
|
26
|
+
si: ['Slovenia', 'SVN'],
|
20
27
|
|
21
28
|
## western europe
|
29
|
+
be: ['Belgium', 'BEL'],
|
30
|
+
nl: ['Netherlands', 'NED'],
|
31
|
+
lu: ['Luxembourg', 'LUX'],
|
22
32
|
fr: ['France', 'FRA'],
|
33
|
+
mc: ['Monaco', 'MCO'],
|
23
34
|
es: ['Spain', 'ESP'],
|
24
|
-
|
25
|
-
nl: ['Netherlands', '' ],
|
35
|
+
ad: ['Andorra', 'AND'],
|
26
36
|
|
27
37
|
## northern europe / skandinavia
|
28
|
-
dk: ['Denmark', '
|
38
|
+
dk: ['Denmark', 'DEN'],
|
29
39
|
fi: ['Finland', 'FIN'],
|
30
40
|
no: ['Norway', 'NOR'],
|
31
41
|
se: ['Sweden', 'SWE'],
|
@@ -33,141 +43,86 @@ class Configuration
|
|
33
43
|
## eastern europe
|
34
44
|
ro: ['Romania', 'ROU'],
|
35
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
|
+
|
36
75
|
|
37
76
|
## north america
|
38
77
|
us: ['United States', 'USA'],
|
39
78
|
mx: ['Mexico', 'MEX'],
|
79
|
+
ca: ['Canada', 'CAN'],
|
40
80
|
|
41
81
|
## caribbean
|
42
|
-
ht: ['Haiti', ''],
|
43
|
-
pr: ['Puerto Rico', ''],
|
44
|
-
tt: ['Trinidad and Tobago', ''],
|
82
|
+
ht: ['Haiti', 'HAI'],
|
83
|
+
pr: ['Puerto Rico', 'PUR'],
|
84
|
+
tt: ['Trinidad and Tobago', 'TRI'],
|
45
85
|
|
46
86
|
## central america
|
47
|
-
cr: ['Costa Rica', ''],
|
48
|
-
gt: ['Guatemala', ''],
|
49
|
-
hn: ['Honduras', ''],
|
50
|
-
ni: ['Nicaragua', ''],
|
51
|
-
pa: ['Panama', ''],
|
52
|
-
sv: ['El Salvador', ''],
|
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
|
+
|
53
94
|
|
54
95
|
## south america
|
55
96
|
ar: ['Argentina', 'ARG'],
|
56
97
|
br: ['Brazil', 'BRA'],
|
57
|
-
bo: ['Bolivia', ''],
|
58
|
-
cl: ['Chile', ''],
|
59
|
-
co: ['Colombia', ''],
|
60
|
-
ec: ['Ecuador', ''],
|
61
|
-
gy: ['Guyana', ''],
|
62
|
-
pe: ['Peru', ''],
|
63
|
-
py: ['Paraguay', ''],
|
64
|
-
uy: ['Uruguay', ''],
|
65
|
-
ve: ['Venezuela', ''],
|
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'],
|
66
110
|
|
67
111
|
## asia
|
68
112
|
cn: ['China', 'CHN'],
|
69
113
|
jp: ['Japan', 'JPN'],
|
70
|
-
kz: ['Kazakhstan', ''
|
71
|
-
kr: ['South Korea', ''
|
114
|
+
kz: ['Kazakhstan', 'KAZ'],
|
115
|
+
kr: ['South Korea', 'KOR'],
|
72
116
|
|
73
117
|
## africa
|
74
|
-
eg: ['Egypt', ''],
|
75
|
-
ma: ['Morocco', ''],
|
118
|
+
eg: ['Egypt', 'EGY'],
|
119
|
+
ma: ['Morocco', 'MAR'],
|
120
|
+
|
121
|
+
## pacific
|
122
|
+
au: ['Australia', 'AUS'],
|
123
|
+
nz: ['New Zealand', 'NZL'],
|
76
124
|
}
|
77
125
|
|
78
|
-
## add more countries - see/check datasets !!
|
79
|
-
=begin
|
80
|
-
[["eg", "../../../openfootball/clubs/africa/egypt/eg.clubs.txt"],
|
81
|
-
["ma", "../../../openfootball/clubs/africa/morocco/ma.clubs.txt"],
|
82
|
-
["cn", "../../../openfootball/clubs/asia/china/cn.clubs.txt"],
|
83
|
-
["jp", "../../../openfootball/clubs/asia/japan/jp.clubs.txt"],
|
84
|
-
["kz", "../../../openfootball/clubs/asia/kazakhstan/kz.clubs.txt"],
|
85
|
-
["kr", "../../../openfootball/clubs/asia/south-korea/kr.clubs.txt"],
|
86
|
-
["ht", "../../../openfootball/clubs/caribbean/haiti/ht.clubs.txt"],
|
87
|
-
["pr", "../../../openfootball/clubs/caribbean/puerto-rico/pr.clubs.txt"],
|
88
|
-
["tt",
|
89
|
-
"../../../openfootball/clubs/caribbean/trinidad-n-tobago/tt.clubs.txt"],
|
90
|
-
["cr", "../../../openfootball/clubs/central-america/costa-rica/cr.clubs.txt"],
|
91
|
-
["gt", "../../../openfootball/clubs/central-america/guatemala/gt.clubs.txt"],
|
92
|
-
["hn", "../../../openfootball/clubs/central-america/hn-honduras/clubs.txt"],
|
93
|
-
["ni", "../../../openfootball/clubs/central-america/ni-nicaragua/clubs.txt"],
|
94
|
-
["pa", "../../../openfootball/clubs/central-america/pa-panama/clubs.txt"],
|
95
|
-
["sv",
|
96
|
-
"../../../openfootball/clubs/central-america/sv-el-salvador/clubs.txt"],
|
97
|
-
["ad", "../../../openfootball/clubs/europe/ad-andorra/clubs.txt"],
|
98
|
-
["al", "../../../openfootball/clubs/europe/al-albania/clubs.txt"],
|
99
|
-
["am", "../../../openfootball/clubs/europe/am-armenia/clubs.txt"],
|
100
|
-
["at", "../../../openfootball/clubs/europe/at-austria/clubs.txt"],
|
101
|
-
["az", "../../../openfootball/clubs/europe/az-azerbaijan/clubs.txt"],
|
102
|
-
["ba",
|
103
|
-
"../../../openfootball/clubs/europe/ba-bosnia-n-herzegovina/clubs.txt"],
|
104
|
-
["be", "../../../openfootball/clubs/europe/be-belgium/clubs.txt"],
|
105
|
-
["bg", "../../../openfootball/clubs/europe/bg-bulgaria/clubs.txt"],
|
106
|
-
["by", "../../../openfootball/clubs/europe/by-belarus/clubs.txt"],
|
107
|
-
["ch",
|
108
|
-
"../../../openfootball/clubs/europe/ch-confoederatio-helvetica/clubs.txt"],
|
109
|
-
["cy", "../../../openfootball/clubs/europe/cy-cyprus/clubs.txt"],
|
110
|
-
["cz", "../../../openfootball/clubs/europe/cz-czech-republic/clubs.txt"],
|
111
|
-
["de", "../../../openfootball/clubs/europe/de-deutschland/clubs.txt"],
|
112
|
-
["dk", "../../../openfootball/clubs/europe/dk-denmark/clubs.txt"],
|
113
|
-
["ee", "../../../openfootball/clubs/europe/ee-estonia/clubs.txt"],
|
114
|
-
["eng", "../../../openfootball/clubs/europe/eng-england/clubs.txt"],
|
115
|
-
["es", "../../../openfootball/clubs/europe/es-espana/clubs.txt"],
|
116
|
-
["fi", "../../../openfootball/clubs/europe/fi-finland/clubs.txt"],
|
117
|
-
["fo", "../../../openfootball/clubs/europe/fo-faroe-islands/clubs.txt"],
|
118
|
-
["fr", "../../../openfootball/clubs/europe/fr-france/clubs.txt"],
|
119
|
-
["ge", "../../../openfootball/clubs/europe/ge-georgia/clubs.txt"],
|
120
|
-
["gi", "../../../openfootball/clubs/europe/gi-gibraltar/clubs.txt"],
|
121
|
-
["gr", "../../../openfootball/clubs/europe/gr-greece/clubs.txt"],
|
122
|
-
["hr", "../../../openfootball/clubs/europe/hr-croatia/clubs.txt"],
|
123
|
-
["hu", "../../../openfootball/clubs/europe/hu-hungary/clubs.txt"],
|
124
|
-
["ie", "../../../openfootball/clubs/europe/ie-ireland/clubs.txt"],
|
125
|
-
["is", "../../../openfootball/clubs/europe/is-iceland/clubs.txt"],
|
126
|
-
["it", "../../../openfootball/clubs/europe/it-italy/clubs.txt"],
|
127
|
-
["li", "../../../openfootball/clubs/europe/li-liechtenstein/clubs.txt"],
|
128
|
-
["lt", "../../../openfootball/clubs/europe/lt-lithuania/clubs.txt"],
|
129
|
-
["lu", "../../../openfootball/clubs/europe/lu-luxembourg/clubs.txt"],
|
130
|
-
["lv", "../../../openfootball/clubs/europe/lv-latvija/clubs.txt"],
|
131
|
-
["mc", "../../../openfootball/clubs/europe/mc-monaco/clubs.txt"],
|
132
|
-
["md", "../../../openfootball/clubs/europe/md-moldova/clubs.txt"],
|
133
|
-
["me", "../../../openfootball/clubs/europe/me-montenegro/clubs.txt"],
|
134
|
-
["mk", "../../../openfootball/clubs/europe/mk-macedonia/clubs.txt"],
|
135
|
-
["mt", "../../../openfootball/clubs/europe/mt-malta/clubs.txt"],
|
136
|
-
["nir", "../../../openfootball/clubs/europe/nir-northern-ireland/clubs.txt"],
|
137
|
-
["nl", "../../../openfootball/clubs/europe/nl-netherlands/clubs.txt"],
|
138
|
-
["no", "../../../openfootball/clubs/europe/no-norway/clubs.txt"],
|
139
|
-
["pl", "../../../openfootball/clubs/europe/pl-poland/clubs.txt"],
|
140
|
-
["pt", "../../../openfootball/clubs/europe/pt-portugal/clubs.txt"],
|
141
|
-
["ro", "../../../openfootball/clubs/europe/ro-romania/clubs.txt"],
|
142
|
-
["rs", "../../../openfootball/clubs/europe/rs-serbia/clubs.txt"],
|
143
|
-
["ru", "../../../openfootball/clubs/europe/ru-russia/clubs.txt"],
|
144
|
-
["sco", "../../../openfootball/clubs/europe/sco-scotland/clubs.txt"],
|
145
|
-
["se", "../../../openfootball/clubs/europe/se-sweden/clubs.txt"],
|
146
|
-
["si", "../../../openfootball/clubs/europe/si-slovenia/clubs.txt"],
|
147
|
-
["sk", "../../../openfootball/clubs/europe/sk-slovakia/clubs.txt"],
|
148
|
-
["sm", "../../../openfootball/clubs/europe/sm-san-marino/clubs.txt"],
|
149
|
-
["tr", "../../../openfootball/clubs/europe/tr-turkey/clubs.txt"],
|
150
|
-
["ua", "../../../openfootball/clubs/europe/ua-ukraine/clubs.txt"],
|
151
|
-
["wal", "../../../openfootball/clubs/europe/wal-wales/clubs.txt"],
|
152
|
-
["il", "../../../openfootball/clubs/middle-east/il-israel/clubs.txt"],
|
153
|
-
["ca", "../../../openfootball/clubs/north-america/ca-canada/clubs.txt"],
|
154
|
-
["mx", "../../../openfootball/clubs/north-america/mx-mexico/clubs.txt"],
|
155
|
-
["us",
|
156
|
-
"../../../openfootball/clubs/north-america/us-united-states/clubs.txt"],
|
157
|
-
["au", "../../../openfootball/clubs/pacific/australia/au.clubs.txt"],
|
158
|
-
["nz", "../../../openfootball/clubs/pacific/new-zealand/nz.clubs.txt"],
|
159
|
-
["ar", "../../../openfootball/clubs/south-america/argentina/ar.clubs.txt"],
|
160
|
-
["bo", "../../../openfootball/clubs/south-america/bolivia/bo.clubs.txt"],
|
161
|
-
["br", "../../../openfootball/clubs/south-america/brazil/br.clubs.txt"],
|
162
|
-
["cl", "../../../openfootball/clubs/south-america/chile/cl.clubs.txt"],
|
163
|
-
["co", "../../../openfootball/clubs/south-america/co-colombia/clubs.txt"],
|
164
|
-
["ec", "../../../openfootball/clubs/south-america/ec-ecuador/clubs.txt"],
|
165
|
-
["gy", "../../../openfootball/clubs/south-america/gy-guyana/clubs.txt"],
|
166
|
-
["pe", "../../../openfootball/clubs/south-america/pe-peru/clubs.txt"],
|
167
|
-
["py", "../../../openfootball/clubs/south-america/py-paraguay/clubs.txt"],
|
168
|
-
["uy", "../../../openfootball/clubs/south-america/uy-uruguay/clubs.txt"],
|
169
|
-
["ve", "../../../openfootball/clubs/south-america/ve-venezuela/clubs.txt"]]
|
170
|
-
=end
|
171
126
|
|
172
127
|
##
|
173
128
|
# note: use our own (internal) country struct for now - why? why not?
|
@@ -198,3 +153,4 @@ class Configuration
|
|
198
153
|
end # class Configuration
|
199
154
|
end # module Import
|
200
155
|
end # module SportDb
|
156
|
+
|
@@ -235,7 +235,8 @@ def self.parse( txt )
|
|
235
235
|
rec.country = country
|
236
236
|
else
|
237
237
|
## make it an error - why? why not?
|
238
|
-
puts "!!!
|
238
|
+
puts "!!! error - country missing in headings hierarchy - sorry - add to quicklist"
|
239
|
+
exit 1
|
239
240
|
end
|
240
241
|
|
241
242
|
## 2) check geo tree with headings hierarchy
|
data/test/test_clubs.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_clubs.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestClubs < MiniTest::Test
|
11
|
+
|
12
|
+
|
13
|
+
def match1( txt ) SportDb::Import::Configuration::CLUBS_REGEX1.match( txt ); end
|
14
|
+
def match2( txt ) SportDb::Import::Configuration::CLUBS_REGEX2.match( txt ); end
|
15
|
+
|
16
|
+
def test_find_clubs
|
17
|
+
m = match1( 'de.clubs.txt' )
|
18
|
+
assert_equal 'de', m[:country]
|
19
|
+
|
20
|
+
m = match1( 'deutschland/de.clubs.txt' )
|
21
|
+
assert_equal 'de', m[:country]
|
22
|
+
|
23
|
+
m = match2( 'europe/de-deutschland/clubs.txt' )
|
24
|
+
assert_equal 'de', m[:country]
|
25
|
+
|
26
|
+
m = match2( 'de-deutschland/clubs.txt' )
|
27
|
+
assert_equal 'de', m[:country]
|
28
|
+
|
29
|
+
|
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
|
+
end
|
35
|
+
|
36
|
+
end # class TestClubs
|
data/test/test_config.rb
CHANGED
@@ -9,39 +9,12 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestConfig < MiniTest::Test
|
11
11
|
|
12
|
-
|
13
|
-
def match1( txt ) SportDb::Import::Configuration::CLUBS_REGEX1.match( txt ); end
|
14
|
-
def match2( txt ) SportDb::Import::Configuration::CLUBS_REGEX2.match( txt ); end
|
15
|
-
|
16
|
-
def test_find_clubs
|
17
|
-
m = match1( 'de.clubs.txt' )
|
18
|
-
assert_equal 'de', m[:country]
|
19
|
-
|
20
|
-
m = match1( 'deutschland/de.clubs.txt' )
|
21
|
-
assert_equal 'de', m[:country]
|
22
|
-
|
23
|
-
m = match2( 'europe/de-deutschland/clubs.txt' )
|
24
|
-
assert_equal 'de', m[:country]
|
25
|
-
|
26
|
-
m = match2( 'de-deutschland/clubs.txt' )
|
27
|
-
assert_equal 'de', m[:country]
|
28
|
-
|
29
|
-
|
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
|
-
end
|
35
|
-
|
36
|
-
|
37
12
|
def test_clubs
|
38
13
|
SportDb::Import.config.clubs_dir = '../../../openfootball/clubs'
|
39
14
|
|
40
|
-
|
41
|
-
|
42
|
-
pp SportDb::Import.config.errors
|
15
|
+
SportDb::Import.config.teams
|
43
16
|
|
44
17
|
assert true ## assume ok if we get here
|
45
|
-
end # method
|
18
|
+
end # method test_clubs
|
46
19
|
|
47
20
|
end # class TestConfig
|
data/test/test_team_reader.rb
CHANGED
@@ -105,17 +105,20 @@ TXT
|
|
105
105
|
assert_equal 'London', recs[0].city
|
106
106
|
assert_equal 'Fulham', recs[0].district
|
107
107
|
assert_equal ['Greater London'], recs[0].geos
|
108
|
-
assert_equal '
|
108
|
+
assert_equal 'England', recs[0].country.name
|
109
|
+
assert_equal 'eng', recs[0].country.key
|
109
110
|
|
110
111
|
assert_equal 'London', recs[1].city
|
111
112
|
assert_equal 'Charlton', recs[1].district
|
112
113
|
assert_equal ['Greater London'], recs[1].geos
|
113
|
-
assert_equal '
|
114
|
+
assert_equal 'England', recs[1].country.name
|
115
|
+
assert_equal 'eng', recs[1].country.key
|
114
116
|
|
115
117
|
assert_equal 'Hamburg', recs[2].city
|
116
118
|
assert_equal 'St. Pauli', recs[2].district
|
117
119
|
assert_equal ['Hamburg'], recs[2].geos
|
118
|
-
assert_equal '
|
120
|
+
assert_equal 'Germany', recs[2].country.name
|
121
|
+
assert_equal 'de', recs[2].country.key
|
119
122
|
end
|
120
123
|
|
121
124
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
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-
|
11
|
+
date: 2019-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/sportdb/config/team_reader.rb
|
72
72
|
- lib/sportdb/config/version.rb
|
73
73
|
- test/helper.rb
|
74
|
+
- test/test_clubs.rb
|
74
75
|
- test/test_config.rb
|
75
76
|
- test/test_countries.rb
|
76
77
|
- test/test_league_reader.rb
|