footballdb-leagues 2019.11.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Manifest.txt +9 -0
- data/README.md +142 -0
- data/Rakefile +31 -0
- data/config/leagues.txt +521 -0
- data/lib/footballdb/leagues.rb +74 -0
- data/lib/footballdb/leagues/version.rb +29 -0
- data/test/helper.rb +10 -0
- data/test/test_league.rb +34 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ee018bab8c43afb54a90a651374e002fc9cfd969
|
4
|
+
data.tar.gz: 8ebfcd8e03c1499566730b81a3bf07c43a74a375
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6120d39c8abf765d404e26ac0cc972ff0e9c7c1b12bd021a4b21a232df75b2efa8fca02280c0ac60e32dc36ce3dc0cd63fc0b744882db5e7ab71560b66062a57
|
7
|
+
data.tar.gz: 6066eca48426e8ed26e26494c1352a7c939fa3e92fe6507f8fe0cef4d3415a5494fc31f99949aa1b26d16d400b3992636e03a328da1544bac976e0b652971eab
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# footballdb-leagues - the world's top football leagues & cups
|
2
|
+
|
3
|
+
|
4
|
+
* home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
|
5
|
+
* bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
|
6
|
+
* gem :: [rubygems.org/gems/footballdb-leagues](https://rubygems.org/gems/footballdb-leagues)
|
7
|
+
* rdoc :: [rubydoc.info/gems/footballdb-leagues](http://rubydoc.info/gems/footballdb-leagues)
|
8
|
+
* forum :: [opensport](http://groups.google.com/group/opensport)
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Note: This library ships with a built-in copy of the
|
15
|
+
[open (public domain) football.db /leagues datasets](https://github.com/openfootball/leagues)
|
16
|
+
(100+ football leagues & cups from around the world)
|
17
|
+
bundled up into a single [`leagues.txt`](config/leagues.txt) datafile
|
18
|
+
for easy zero-configuration "out-of-the-box" usage.
|
19
|
+
|
20
|
+
|
21
|
+
Get and pretty print (pp) all leagues & cups:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
require 'footballdb/leagues'
|
25
|
+
|
26
|
+
pp League.all
|
27
|
+
```
|
28
|
+
|
29
|
+
resulting in:
|
30
|
+
|
31
|
+
```
|
32
|
+
[#<League @name="English Premier League", @country="England", ...>,
|
33
|
+
#<League @name="English Championship", @country="England", ...>,
|
34
|
+
#<League @name="English League One", @country="England", ...>,
|
35
|
+
#<League @name="English League Two", @country="England", ...>,
|
36
|
+
...
|
37
|
+
]
|
38
|
+
```
|
39
|
+
|
40
|
+
Let's find football leagues in the world
|
41
|
+
with the name `Premier League`:
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
m = League.match( 'Premier League' )
|
45
|
+
m.size # 7 league matches found
|
46
|
+
#=> 7
|
47
|
+
m[0].name; m[0].country
|
48
|
+
#=> "English Premier League", "England"
|
49
|
+
m[1].name; m[1].country
|
50
|
+
#=> "Welsh Premier League", "Wales"
|
51
|
+
m[2].name; m[2].country
|
52
|
+
#=> "Russian Premier League", "Russia"
|
53
|
+
# ...
|
54
|
+
|
55
|
+
m = League.match_by( name: 'Premier League', country: 'eng' )
|
56
|
+
# -or- try more alternative (unique) names
|
57
|
+
m = League.match( 'England Premier League' )
|
58
|
+
m = League.match( 'ENG 1' )
|
59
|
+
m = League.match( 'ENG PL' )
|
60
|
+
m.size # 1 league match found
|
61
|
+
#=> 1
|
62
|
+
m[0].name; m[0].country
|
63
|
+
#=> "English Premier League", "England"
|
64
|
+
|
65
|
+
m = League.match_by( name: 'Premier League', country: 'ru' )
|
66
|
+
# -or- try more alternative (unique) names
|
67
|
+
m = League.match( 'Russia Premier League' )
|
68
|
+
m = League.match( 'RUS 1' )
|
69
|
+
m = League.match( 'RUS PL' )
|
70
|
+
m.size # 1 league match found
|
71
|
+
#=> 1
|
72
|
+
m[0].name; m[0].country
|
73
|
+
#=> "Russian Premier League", "Russia"
|
74
|
+
|
75
|
+
|
76
|
+
# try some more
|
77
|
+
m = League.match( 'Brasileiro Série A' )
|
78
|
+
m[0].name; m[0].country
|
79
|
+
#=> "Brasileiro Série A", "Brazil"
|
80
|
+
|
81
|
+
m = League.match( 'Major League Soccer' )
|
82
|
+
# -or- try more alternative (unique) names
|
83
|
+
m = League.match( 'USA MLS' )
|
84
|
+
m = League.match( 'USA 1' )
|
85
|
+
m[0].name; m[0].country
|
86
|
+
#=> "Major League Soccer", "United States"
|
87
|
+
|
88
|
+
# and so on
|
89
|
+
# ...
|
90
|
+
```
|
91
|
+
|
92
|
+
|
93
|
+
Let's print all names that have duplicate (more than one) matching league:
|
94
|
+
|
95
|
+
``` ruby
|
96
|
+
League.mappings.each do |name, leagues|
|
97
|
+
if leagues.size > 1
|
98
|
+
puts "#{leagues.size} matching leagues for `#{name}`:"
|
99
|
+
leagues.each do |league|
|
100
|
+
puts " - #{league.name}, #{league.country.name} (#{league.country.key})"
|
101
|
+
end
|
102
|
+
puts
|
103
|
+
end
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
resulting in:
|
108
|
+
|
109
|
+
```
|
110
|
+
2 matching leagues for `bundesliga`:
|
111
|
+
- German Bundesliga, Germany (de)
|
112
|
+
- Austrian Bundesliga, Austria (at)
|
113
|
+
|
114
|
+
5 matching leagues for `primeradivisión`:
|
115
|
+
- Primera División, Paraguay (py)
|
116
|
+
- Primera División, Peru (pe)
|
117
|
+
- Primera División, Uruguay (uy)
|
118
|
+
...
|
119
|
+
|
120
|
+
7 matching leagues for `premierleague`:
|
121
|
+
- English Premier League, England (eng)
|
122
|
+
- Welsh Premier League, Wales (wal)
|
123
|
+
- Russian Premier League, Russia (ru)
|
124
|
+
...
|
125
|
+
...
|
126
|
+
```
|
127
|
+
|
128
|
+
That's it.
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
## License
|
133
|
+
|
134
|
+
The `footballdb-leagues` scripts are dedicated to the public domain.
|
135
|
+
Use it as you please with no restrictions whatsoever.
|
136
|
+
|
137
|
+
|
138
|
+
## Questions? Comments?
|
139
|
+
|
140
|
+
Send them along to the
|
141
|
+
[Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
|
142
|
+
Thanks!
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/footballdb/leagues/version.rb'
|
3
|
+
|
4
|
+
Hoe.spec 'footballdb-leagues' do
|
5
|
+
|
6
|
+
self.version = FootballDb::Leagues::VERSION
|
7
|
+
|
8
|
+
self.summary = "footballdb-leagues - the world's top football leagues 'n' cups"
|
9
|
+
self.description = summary
|
10
|
+
|
11
|
+
self.urls = ['https://github.com/sportdb/sport.db']
|
12
|
+
|
13
|
+
self.author = 'Gerald Bauer'
|
14
|
+
self.email = 'opensport@googlegroups.com'
|
15
|
+
|
16
|
+
# switch extension to .markdown for gihub formatting
|
17
|
+
self.readme_file = 'README.md'
|
18
|
+
self.history_file = 'CHANGELOG.md'
|
19
|
+
|
20
|
+
self.licenses = ['Public Domain']
|
21
|
+
|
22
|
+
self.extra_deps = [
|
23
|
+
['sportdb-leagues', '>= 0.2.2'],
|
24
|
+
['fifa', '>= 1.2.1'],
|
25
|
+
]
|
26
|
+
|
27
|
+
self.spec_extras = {
|
28
|
+
required_ruby_version: '>= 2.2.2'
|
29
|
+
}
|
30
|
+
|
31
|
+
end
|
data/config/leagues.txt
ADDED
@@ -0,0 +1,521 @@
|
|
1
|
+
##########################################
|
2
|
+
# auto-generated all-in-one single datafile leagues.txt bundle
|
3
|
+
# on 2019-11-22 10:56:43 +0100 from 8 datafile(s)
|
4
|
+
# please, do NOT edit here; use the source
|
5
|
+
# see https://github.com/openfootball/leagues - updates welcome!
|
6
|
+
|
7
|
+
|
8
|
+
= South Africa =
|
9
|
+
|
10
|
+
1 Premier League
|
11
|
+
| RSA PL | Südafrika Premier League
|
12
|
+
|
13
|
+
= International =
|
14
|
+
|
15
|
+
asia.cl AFC Champions League # afc = asian football confederation ?
|
16
|
+
| AFC CL
|
17
|
+
|
18
|
+
= Japan =
|
19
|
+
|
20
|
+
cup Emperor's Cup # note: national cup (as a rule use cup key for national cup and NOT league cup if both exists)
|
21
|
+
| Japan Emperor Cup
|
22
|
+
| Japan FA Cup
|
23
|
+
|
24
|
+
cup.l J. League Cup # note: league cup (incl. all teams from J. League and 0-2 teams from J2 League)
|
25
|
+
| JPN LC | Japan Nabisco Cup # check - $$$ Nabisco is a sponsor?
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
= Kazakhstan =
|
30
|
+
|
31
|
+
1 Kazakh Premier League A
|
32
|
+
= Costa Rica =
|
33
|
+
|
34
|
+
1 Costa Rica Primera División
|
35
|
+
|
36
|
+
= International =
|
37
|
+
|
38
|
+
cl UEFA Champions League
|
39
|
+
el UEFA Europa League
|
40
|
+
|
41
|
+
|
42
|
+
= Germany =
|
43
|
+
1 Bundesliga
|
44
|
+
| GER BL
|
45
|
+
| German Bundesliga
|
46
|
+
| Deutschland Bundesliga | Deutsche Bundesliga
|
47
|
+
2 2. Bundesliga
|
48
|
+
| Deutschland 2. Bundesliga | Deutsche 2. Bundesliga
|
49
|
+
3 3. Liga
|
50
|
+
| Deutschland 3. Liga | Deutsche 3. Liga
|
51
|
+
|
52
|
+
cup DFB Pokal
|
53
|
+
|
54
|
+
|
55
|
+
= Austria =
|
56
|
+
1 Bundesliga # Each year (July→December/February→May)
|
57
|
+
| AUT BL
|
58
|
+
| Austrian Bundesliga
|
59
|
+
| Österreich Bundesliga | Österr. Bundesliga
|
60
|
+
2 2. Liga # Each year (July→May)
|
61
|
+
| Österreich Zweite Liga
|
62
|
+
| Österr. Erste Liga | Österr. 1. Liga # note: before 2018/19 2. Liga was known as 1. Liga / Erste Liga
|
63
|
+
|
64
|
+
3.o Regionalliga Ost
|
65
|
+
| AUT RLO | Österreich Regionalliga Ost
|
66
|
+
3.m Regionalliga Mitte
|
67
|
+
| AUT RLM | Österreich Regionalliga Mitte
|
68
|
+
3.sbg Regionalliga Salzburg
|
69
|
+
| RL SBG
|
70
|
+
3.t Regionalliga Tirol
|
71
|
+
| RL TIR
|
72
|
+
3.v Eliteliga Vorarlberg
|
73
|
+
| RL VBG
|
74
|
+
|
75
|
+
cup ÖFB Cup
|
76
|
+
| Österreich ÖFB Cup
|
77
|
+
| Austrian Cup
|
78
|
+
|
79
|
+
= Switzerland =
|
80
|
+
1 Super League
|
81
|
+
| SUI SL
|
82
|
+
| Swiss Super League
|
83
|
+
| Schweiz Super League
|
84
|
+
2 Challenge League
|
85
|
+
|
86
|
+
cup Schweizer Cup
|
87
|
+
| SUI P
|
88
|
+
|
89
|
+
|
90
|
+
= England = ## add incl. Wales as country2 or something - why? why not?
|
91
|
+
1 English Premier League
|
92
|
+
| ENG PL | England Premier League | Premier League
|
93
|
+
2 English Championship
|
94
|
+
| ENG CS | England Championship | Championship
|
95
|
+
3 English League One
|
96
|
+
| England League One | League One
|
97
|
+
4 English League Two
|
98
|
+
5 English National League
|
99
|
+
|
100
|
+
cup FA Cup ## use cup.fa as key - why? why not?
|
101
|
+
| ENG FA
|
102
|
+
| England FA Cup
|
103
|
+
cup.l EFL Cup
|
104
|
+
| League Cup | Football League Cup
|
105
|
+
| ENG LC | ENG L
|
106
|
+
| England Liga Cup
|
107
|
+
cup.t EFL Trophy
|
108
|
+
| Football League Trophy | England Football League Trophy
|
109
|
+
| ENG LTR | ENG T
|
110
|
+
|
111
|
+
|
112
|
+
= Scotland =
|
113
|
+
1 Scottish Premiership
|
114
|
+
| SCO PS
|
115
|
+
| Schottland Premiership [de]
|
116
|
+
2 Scottish Championship
|
117
|
+
3 Scottish League One
|
118
|
+
4 Scottish League Two
|
119
|
+
|
120
|
+
cup.l League Cup
|
121
|
+
| SCO LC | Schottland League Cup
|
122
|
+
|
123
|
+
|
124
|
+
= Wales =
|
125
|
+
1 Welsh Premier League
|
126
|
+
| Wales Premier League
|
127
|
+
|
128
|
+
= Northern Ireland =
|
129
|
+
1 Premiership
|
130
|
+
| NIRL 1 # note: FIFA code is NIR !!!
|
131
|
+
| Northern Irish Premiership
|
132
|
+
| Nordirland Premiership
|
133
|
+
|
134
|
+
= Ireland =
|
135
|
+
1 Premier Division
|
136
|
+
| Irish Premier Division A
|
137
|
+
| Irland Premier Division
|
138
|
+
|
139
|
+
|
140
|
+
= Iceland =
|
141
|
+
1 Urvalsdeild
|
142
|
+
| Island Urvalsdeild
|
143
|
+
| Icelandic Premier League
|
144
|
+
|
145
|
+
= Faroe Islands =
|
146
|
+
1 Faroese Premier Division
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
= Spain =
|
151
|
+
1 Primera División
|
152
|
+
| Spanish Liga | La Liga
|
153
|
+
| Spanien Primera Division
|
154
|
+
2 Segunda División
|
155
|
+
| Spanien Segunda Division
|
156
|
+
|
157
|
+
= Portugal =
|
158
|
+
1 Primeira Liga
|
159
|
+
| Portuguese First Division
|
160
|
+
| Portugal Primeira Liga
|
161
|
+
|
162
|
+
cup Taça de Portugal
|
163
|
+
| Portugal Taça de Portugal
|
164
|
+
|
165
|
+
cup.l Taça da Liga # note: League Cup (and NOT National Cup)
|
166
|
+
| POR LC
|
167
|
+
| Portugal Carlsberg Cup [de] ## $$$ Carlsberg is sponsor
|
168
|
+
|
169
|
+
|
170
|
+
= Gibraltar =
|
171
|
+
1 Gibraltarian Premier League A
|
172
|
+
|
173
|
+
= Andorra =
|
174
|
+
1 Andorran Premier Division
|
175
|
+
|
176
|
+
|
177
|
+
= France = ## add incl. Monaco - why? why not?
|
178
|
+
1 Ligue 1
|
179
|
+
| French Ligue 1
|
180
|
+
| Frankreich Ligue 1
|
181
|
+
2 Ligue 2
|
182
|
+
| Frankreich Ligue 2
|
183
|
+
|
184
|
+
cup.l Coupe de la Ligue ## French League Cup
|
185
|
+
| FRA LC | Frankreich Coupe de la Ligue
|
186
|
+
|
187
|
+
|
188
|
+
= Italy =
|
189
|
+
1 Serie A
|
190
|
+
| ITA A
|
191
|
+
| Italian Serie A
|
192
|
+
| Italien Serie A
|
193
|
+
2 Serie B
|
194
|
+
| ITA B | Italien Serie B
|
195
|
+
3.a Serie C (North & Central West) # Group A
|
196
|
+
| ITA C1A | Italien Lega Pro Prima Divisione Girone A
|
197
|
+
3.b Serie C (North & Central East) # Group B
|
198
|
+
| ITA C1B | Italien Lega Pro Prima Divisione Girone B
|
199
|
+
3.c Serie C (South) # Group C
|
200
|
+
| ITA C1C | Italien Lega Pro Prima Divisione Girone C
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
= San Marino =
|
205
|
+
1 San Marinese Championship
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
= Turkey =
|
211
|
+
1 Süper Lig
|
212
|
+
| Turkish Super League
|
213
|
+
| Türkei Süper Lig
|
214
|
+
|
215
|
+
2 1. Lig
|
216
|
+
| Türkei TFF 1. Lig ## todo/check - is TFF the sponsor?
|
217
|
+
|
218
|
+
|
219
|
+
= Greece =
|
220
|
+
1 Greek Super League
|
221
|
+
| Griechenland Super League [de]
|
222
|
+
|
223
|
+
2 Greek Super League 2
|
224
|
+
| Griechenland Super League 2 [de]
|
225
|
+
|
226
|
+
|
227
|
+
= Cyprus =
|
228
|
+
1 Cypriot First Division
|
229
|
+
| Zypern 1. Division [de]
|
230
|
+
|
231
|
+
|
232
|
+
= Malta =
|
233
|
+
1 Maltese Premier League
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
= Denmark =
|
238
|
+
1 Superligaen
|
239
|
+
| Danish Super League
|
240
|
+
| Dänemark Superligaen
|
241
|
+
2 1. Division
|
242
|
+
| Dänemark 1. Division
|
243
|
+
cup Landspokalturneringen
|
244
|
+
| DEN P
|
245
|
+
| Dänemark Landspokalturneringen
|
246
|
+
| DBU Pokalen
|
247
|
+
|
248
|
+
= Norway =
|
249
|
+
1 Tippeligaen
|
250
|
+
| Norwegian Premier Division A | Eliteserien
|
251
|
+
| Norwegen Tippeligaen
|
252
|
+
2 1. Division
|
253
|
+
| Norwegen Adeccoligaen
|
254
|
+
|
255
|
+
cup Norwegian Football Cup
|
256
|
+
| Norwegen Cup [de]
|
257
|
+
|
258
|
+
|
259
|
+
= Sweden =
|
260
|
+
1 Allsvenskan
|
261
|
+
| Swedish First Division
|
262
|
+
| Schweden Allsvenskan
|
263
|
+
2 Superettan
|
264
|
+
| Schweden Superettan
|
265
|
+
cup Cup
|
266
|
+
| Schweden Cup
|
267
|
+
|
268
|
+
= Finland =
|
269
|
+
1 Veikkausliiga
|
270
|
+
| Finnland Veikkausliiga
|
271
|
+
| Finnish First Division
|
272
|
+
2 Ykkonen
|
273
|
+
| Ykkönen | Finnland Ykkonen
|
274
|
+
3 Kakkonen
|
275
|
+
| Finnland Kakkonen
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
= Netherlands =
|
280
|
+
1 Eredivisie
|
281
|
+
| Dutch First Division
|
282
|
+
| NL 1
|
283
|
+
| Niederlande Eredivisie
|
284
|
+
2 Eerste Divisie
|
285
|
+
|
286
|
+
cup Cup
|
287
|
+
| NL CUP | Niederlande KNVB Cup
|
288
|
+
|
289
|
+
|
290
|
+
= Belgium =
|
291
|
+
1 Pro League
|
292
|
+
| Belgian First Division A
|
293
|
+
| Belgian First League
|
294
|
+
| Belgien Pro League
|
295
|
+
| Belgien Eerste Klasse
|
296
|
+
|
297
|
+
2 Belgian First Division B
|
298
|
+
| Belgium Tweede Klasse
|
299
|
+
|
300
|
+
= Luxembourg =
|
301
|
+
1 Luxembourger First Division
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
= Poland =
|
306
|
+
1 Ekstraklasa
|
307
|
+
| Polish First Division
|
308
|
+
| Polen Ekstraklasa
|
309
|
+
2 I Liga
|
310
|
+
| Polen I Liga
|
311
|
+
|
312
|
+
= Hungary =
|
313
|
+
1 Hungarian First League
|
314
|
+
| NB I
|
315
|
+
|
316
|
+
= Czech Republic =
|
317
|
+
1 Czech First League
|
318
|
+
| 1. Liga
|
319
|
+
|
320
|
+
cup Cup
|
321
|
+
| Tschechien Cup
|
322
|
+
|
323
|
+
|
324
|
+
= Slovakia =
|
325
|
+
1 Slovak First League
|
326
|
+
| Slowakei Corgon Liga [de] ## check - Corgon is sponsor?
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
= Slovenia =
|
331
|
+
1 Slovene First League
|
332
|
+
| SLO 1 | Prva Liga # note: FIFA code is SVN !!!
|
333
|
+
cup Slowenien Cup
|
334
|
+
| SLO CUP
|
335
|
+
|
336
|
+
= Croatia =
|
337
|
+
1 1. HNL
|
338
|
+
| Croatian First League
|
339
|
+
| Kroatien 1. HNL
|
340
|
+
|
341
|
+
= Bosnia and Herzegovina =
|
342
|
+
1 Premier Liga
|
343
|
+
| BOS 1
|
344
|
+
| Bosnian-Herzegovinian Premier League
|
345
|
+
| Bosnien Premier Liga
|
346
|
+
|
347
|
+
cup Bosnia and Herzegovina Football Cup
|
348
|
+
| BOS CUP # note: FIFA code is BIH
|
349
|
+
| Bosnien Cup [de]
|
350
|
+
|
351
|
+
= Serbia =
|
352
|
+
1 Serbian Super League
|
353
|
+
| SERB 1 # note: FIFA code is SRB
|
354
|
+
| Serbien Meridijan Superliga ## check - Meridijan is sponsor?
|
355
|
+
|
356
|
+
|
357
|
+
= Kosovo =
|
358
|
+
1 Kosovan Superliga A
|
359
|
+
|
360
|
+
= Albania =
|
361
|
+
1 Albanian Super League
|
362
|
+
|
363
|
+
= Moldova =
|
364
|
+
1 Moldovan First Division
|
365
|
+
|
366
|
+
= Montenegro =
|
367
|
+
1 Montenegrin First League
|
368
|
+
|
369
|
+
= Macedonia =
|
370
|
+
1 Macedonian First League
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
= Romania =
|
375
|
+
1 Liga 1
|
376
|
+
| Romania Liga 1 | Romanian First Division
|
377
|
+
| Rumänien Liga 1
|
378
|
+
2 Liga 2
|
379
|
+
| Rumänien Liga 2
|
380
|
+
|
381
|
+
cup Cup
|
382
|
+
| Rumänien Cup
|
383
|
+
|
384
|
+
|
385
|
+
= Bulgaria =
|
386
|
+
1 Premier League
|
387
|
+
| Bulgarian A League
|
388
|
+
| Bulgarien Premier League
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
= Latvia =
|
393
|
+
1 Latvian First Division
|
394
|
+
|
395
|
+
= Lithuania =
|
396
|
+
1 Lithuanian First Division
|
397
|
+
|
398
|
+
= Estonia =
|
399
|
+
1 Meistriliiga
|
400
|
+
| Estonian First League A
|
401
|
+
| Estland Meistriliiga
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
= Russia =
|
406
|
+
1 Premier League
|
407
|
+
| RUS PL
|
408
|
+
| Russian Premier League
|
409
|
+
| Russland Premier League
|
410
|
+
|
411
|
+
2 1. Division
|
412
|
+
| Russland 1. Division
|
413
|
+
|
414
|
+
cup Russian Cup
|
415
|
+
| Russland Russian Cup
|
416
|
+
|
417
|
+
= Ukraine =
|
418
|
+
1 Premier League
|
419
|
+
| Ukrainian Premier League
|
420
|
+
| Ukraine Premier League
|
421
|
+
cup Cup
|
422
|
+
| Ukraine Cup
|
423
|
+
|
424
|
+
|
425
|
+
= Belarus =
|
426
|
+
1 Belarusian Premier League
|
427
|
+
|
428
|
+
= Armenia =
|
429
|
+
1 Armenian Premier League
|
430
|
+
|
431
|
+
= Azerbaijan =
|
432
|
+
1 Azerbaijani Premier League A
|
433
|
+
|
434
|
+
= Georgia =
|
435
|
+
1 Georgian Premier League A
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
= Israel =
|
442
|
+
1 Winner League
|
443
|
+
| Israeli Premier League
|
444
|
+
| Israel Winner League
|
445
|
+
|
446
|
+
2 National League
|
447
|
+
| Israel National League
|
448
|
+
|
449
|
+
cup League Cup National
|
450
|
+
| ISR LCN | Israel League Cup National
|
451
|
+
|
452
|
+
= International =
|
453
|
+
|
454
|
+
usmx.cup US & Mexican Leagues Cup ## check if clubs include country code?
|
455
|
+
| USMXLC
|
456
|
+
|
457
|
+
|
458
|
+
= United States = ## add incl. Canada - why? why not?
|
459
|
+
1 Major League Soccer ### todo: use mls (and not us.1) as "primary" key - why? why not?
|
460
|
+
| USA MLS | USA Major League Soccer
|
461
|
+
|
462
|
+
cup US Open Cup
|
463
|
+
| USA US Open Cup
|
464
|
+
|
465
|
+
= Australia =
|
466
|
+
cup FFA Cup
|
467
|
+
| Australien FFA Cup
|
468
|
+
|
469
|
+
= International =
|
470
|
+
|
471
|
+
copa.l Copa Libertadores
|
472
|
+
copa.s Copa Sudamericana
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
= Brazil =
|
477
|
+
1 Brasileiro Série A
|
478
|
+
| Brasilien Brasilero Serie A
|
479
|
+
2 Brasileiro Série B
|
480
|
+
| Brasilien Brasilero Serie B
|
481
|
+
|
482
|
+
cup Copa do Brasil
|
483
|
+
| Brasilien Cup | Brazil Cup
|
484
|
+
|
485
|
+
|
486
|
+
= Argentina =
|
487
|
+
1 Primera Division
|
488
|
+
| Argentinien Primera Division
|
489
|
+
cup Cup
|
490
|
+
| Argentinien Cup
|
491
|
+
|
492
|
+
|
493
|
+
= Paraguay =
|
494
|
+
1 Primera Division
|
495
|
+
| Paraguay Primera Division
|
496
|
+
|
497
|
+
= Peru =
|
498
|
+
1 Primera Division
|
499
|
+
| Peru Primera Division
|
500
|
+
|
501
|
+
cup.bic Copa Bicentenario 2019
|
502
|
+
| CP BIC | Peru Copa Bicentenario
|
503
|
+
|
504
|
+
= Colombia =
|
505
|
+
1 Primera A
|
506
|
+
| Categoría Primera A
|
507
|
+
| Kolumbien Primera Liga [de]
|
508
|
+
|
509
|
+
cup Copa Colombia
|
510
|
+
| COL P | COL COP
|
511
|
+
|
512
|
+
|
513
|
+
= Uruguay =
|
514
|
+
1 Primera División
|
515
|
+
| Uruguay Primera Division
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
= Venezuela =
|
520
|
+
1 Primera División
|
521
|
+
| Venezuela Primera Divison
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
###
|
5
|
+
# sport.db gems / libraries
|
6
|
+
require 'fifa'
|
7
|
+
require 'sportdb/leagues'
|
8
|
+
|
9
|
+
|
10
|
+
###
|
11
|
+
# our own code
|
12
|
+
require 'footballdb/leagues/version' # let version always go first
|
13
|
+
|
14
|
+
|
15
|
+
module FootballDb
|
16
|
+
module Import
|
17
|
+
|
18
|
+
## add "fake" configuration for stand-alone usage
|
19
|
+
class Configuration
|
20
|
+
def initialize
|
21
|
+
recs = Fifa.countries
|
22
|
+
@countries = SportDb::Import::CountryIndex.new( recs )
|
23
|
+
end
|
24
|
+
|
25
|
+
def countries() @countries; end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
class League ## todo/check: use a module instead of class - why? why not?
|
32
|
+
def self.leagues() league_index.leagues; end ## return all leagues (struct-like) records
|
33
|
+
def self.all() leagues; end ## use ActiveRecord-like alias for leagues
|
34
|
+
|
35
|
+
def self.mappings() league_index.mappings; end
|
36
|
+
|
37
|
+
def self.match( name ) league_index.match( name ); end
|
38
|
+
def self.match_by( name:, country: ) league_index.match_by( name: name, country: country ); end
|
39
|
+
|
40
|
+
|
41
|
+
def self.league_index
|
42
|
+
@league_index ||= build_league_index
|
43
|
+
@league_index
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def self.build_league_index
|
48
|
+
if defined?( SportDb::Import::Configuration )
|
49
|
+
# assume running "inside" sportdb - (re)use sportdb configuration
|
50
|
+
else
|
51
|
+
# assume running "stand-alone" - setup configuration for countries / country mapping
|
52
|
+
config = Configuration.new
|
53
|
+
SportDb::Import::LeagueReader.config = config
|
54
|
+
SportDb::Import::LeagueIndex.config = config
|
55
|
+
end
|
56
|
+
|
57
|
+
recs = SportDb::Import::LeagueReader.read( "#{FootballDb::Leagues.data_dir}/leagues.txt" )
|
58
|
+
league_index = SportDb::Import::LeagueIndex.new
|
59
|
+
league_index.add( recs )
|
60
|
+
league_index
|
61
|
+
end
|
62
|
+
end # class League
|
63
|
+
|
64
|
+
end # module Import
|
65
|
+
end # module FootballDb
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
### add top-level (global) convenience alias
|
70
|
+
League = FootballDb::Import::League
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
puts FootballDb::Leagues.banner # say hello
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
module FootballDb
|
5
|
+
module Leagues
|
6
|
+
|
7
|
+
MAJOR = 2019 ## todo: namespace inside version or something - why? why not??
|
8
|
+
MINOR = 11
|
9
|
+
PATCH = 22
|
10
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
11
|
+
|
12
|
+
def self.version
|
13
|
+
VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.banner
|
17
|
+
"footballdb-leagues/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.root
|
21
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.data_dir ## rename to config_dir - why? why not?
|
25
|
+
"#{root}/config"
|
26
|
+
end
|
27
|
+
|
28
|
+
end # module Leagues
|
29
|
+
end # module FootballDb
|
data/test/helper.rb
ADDED
data/test/test_league.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_league.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestLeague < MiniTest::Test
|
11
|
+
|
12
|
+
def test_match
|
13
|
+
m = League.match( 'English Premier League' )
|
14
|
+
assert_equal 'English Premier League', m[0].name
|
15
|
+
assert_equal 'eng.1', m[0].key
|
16
|
+
assert_equal 'England', m[0].country.name
|
17
|
+
|
18
|
+
m = League.match( 'ENG PL' )
|
19
|
+
assert_equal 'English Premier League', m[0].name
|
20
|
+
assert_equal 'eng.1', m[0].key
|
21
|
+
assert_equal 'England', m[0].country.name
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_match_by
|
25
|
+
m = League.match( 'Premier League' )
|
26
|
+
assert m.size > 1 ## more than one match expected
|
27
|
+
|
28
|
+
m = League.match_by( name: 'Premier League', country: 'eng' )
|
29
|
+
assert_equal 'English Premier League', m[0].name
|
30
|
+
assert_equal 'eng.1', m[0].key
|
31
|
+
assert_equal 'England', m[0].country.name
|
32
|
+
end
|
33
|
+
|
34
|
+
end # class TestLeague
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: footballdb-leagues
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2019.11.22
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sportdb-leagues
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fifa
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hoe
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.16'
|
69
|
+
description: footballdb-leagues - the world's top football leagues 'n' cups
|
70
|
+
email: opensport@googlegroups.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files:
|
74
|
+
- CHANGELOG.md
|
75
|
+
- Manifest.txt
|
76
|
+
- README.md
|
77
|
+
- config/leagues.txt
|
78
|
+
files:
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Manifest.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- config/leagues.txt
|
84
|
+
- lib/footballdb/leagues.rb
|
85
|
+
- lib/footballdb/leagues/version.rb
|
86
|
+
- test/helper.rb
|
87
|
+
- test/test_league.rb
|
88
|
+
homepage: https://github.com/sportdb/sport.db
|
89
|
+
licenses:
|
90
|
+
- Public Domain
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options:
|
94
|
+
- "--main"
|
95
|
+
- README.md
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.2.2
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.5.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: footballdb-leagues - the world's top football leagues 'n' cups
|
114
|
+
test_files: []
|