fifa 2019.11.27
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 +12 -0
- data/NOTES.md +55 -0
- data/README.md +172 -0
- data/Rakefile +30 -0
- data/config/countries.txt +456 -0
- data/lib/fifa.rb +99 -0
- data/lib/fifa/countries.rb +42 -0
- data/lib/fifa/version.rb +27 -0
- data/test/helper.rb +10 -0
- data/test/test_countries.rb +53 -0
- data/test/test_orgs.rb +100 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3e92d74d15ab60d3388465521eca91f02d9249cc
|
4
|
+
data.tar.gz: 6d5dea7f8ac0359d381c8e7610b9fdfb1f070893
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7de9369524701703c7abdc13f5b66111e317c6f4bed788c3524a5223849923c77cea328dee524042ad0d50649caaabaa50ccdf410a7670acb5a1175f01290e6
|
7
|
+
data.tar.gz: b913071e6cb50e05b8739bfb5956ea1949e04c685f821b031864e467e9422fde04a30c02187635be8ce671d94291952f2582bb5abe14fa648cf0b0e2824f2395
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
data/NOTES.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Notes
|
2
|
+
|
3
|
+
|
4
|
+
Use to sync / copy countries:
|
5
|
+
|
6
|
+
```
|
7
|
+
copy config\countries.txt ..\test\world
|
8
|
+
```
|
9
|
+
|
10
|
+
|
11
|
+
## Confederations
|
12
|
+
|
13
|
+
Six confederations and 211 national associations
|
14
|
+
|
15
|
+
Teams which are either members of Fédération Internationale de Football Association (FIFA),
|
16
|
+
the world's football governing body (211 teams),
|
17
|
+
or have membership in a FIFA-affiliated continental confederation without being members of FIFA (12 teams).
|
18
|
+
|
19
|
+
|
20
|
+
Besides its worldwide institutions there are six confederations recognised by FIFA which oversee the game in the different continents and regions of the world. National associations, and not the continental confederations, are members of FIFA.
|
21
|
+
The continental confederations are provided for in FIFA's statutes,
|
22
|
+
and membership of a confederation is a prerequisite to FIFA membership.
|
23
|
+
|
24
|
+
- Asian Football Confederation (AFC; 47 members) (b)
|
25
|
+
- Confederation of African Football (CAF; 56 members)
|
26
|
+
- Confederation of North, Central American and Caribbean Association Football (CONCACAF; 41 members) (c)
|
27
|
+
- Confederación Sudamericana de Fútbol (CONMEBOL; 10 members)
|
28
|
+
- Oceania Football Confederation (OFC; 14 members)(b)
|
29
|
+
- Union of European Football Associations (UEFA; 55 members) (d)
|
30
|
+
|
31
|
+
|
32
|
+
(b) Australia has been a member of the AFC since 2006.
|
33
|
+
|
34
|
+
(c) French Guiana, Guyana and Suriname are CONCACAF members although they are in South America. The French Guiana team is a member of CONCACAF but not of FIFA.
|
35
|
+
|
36
|
+
(d) Teams representing the nations of Armenia, Azerbaijan, Cyprus, Georgia, Israel, Kazakhstan, Russia and Turkey are UEFA members, although the majority or entirety of their territory is outside of continental Europe. Monaco is not member of UEFA or FIFA.
|
37
|
+
|
38
|
+
|
39
|
+
## Links
|
40
|
+
|
41
|
+
- <https://www.fifa.com/associations/>
|
42
|
+
|
43
|
+
The AFC in Asia, CAF in Africa, the Football Confederation (CONCACAF) in North and Central America and the Caribbean, CONMEBOL in South America, UEFA in Europe and the OFC in Oceania...
|
44
|
+
|
45
|
+
AFRICA - ASIA - EUROPE - NORTH, CENTRAL AMERICA AND CARIBBEAN - OCEANIA - SOUTH AMERICA
|
46
|
+
|
47
|
+
- <https://www.fifa.com/associations/association/gib/about> - GIB - Gibraltar
|
48
|
+
- <https://www.fifa.com/associations/association/kvx/about> - KVX - Kosovo
|
49
|
+
|
50
|
+
<!-- break -->
|
51
|
+
|
52
|
+
- <https://www.uefa.com/memberassociations/association=gib> - GIB - Gibraltar
|
53
|
+
- UEFA affiliation: 2013; FIFA affiliation: not affiliated yet (2016 NOT updated!?)
|
54
|
+
- <https://www.uefa.com/memberassociations/association=kos> - KOS - Kosove
|
55
|
+
- UEFA affiliation: 2016; FIFA affiliation: 2016
|
data/README.md
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
# fifa - the world's football countries and codes (incl. non-member countries and irregular codes)
|
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/fifa](https://rubygems.org/gems/fifa)
|
7
|
+
* rdoc :: [rubydoc.info/gems/fifa](http://rubydoc.info/gems/fifa)
|
8
|
+
* forum :: [opensport](http://groups.google.com/group/opensport)
|
9
|
+
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Get and pretty print (pp) all countries
|
14
|
+
|
15
|
+
``` ruby
|
16
|
+
require 'fifa'
|
17
|
+
|
18
|
+
pp Fifa.countries
|
19
|
+
```
|
20
|
+
|
21
|
+
resulting in:
|
22
|
+
|
23
|
+
```
|
24
|
+
[#<Country @fifa="AFG", @key="af", @name="Afghanistan">,
|
25
|
+
#<Country @fifa="ALB", @key="al", @name="Albania">,
|
26
|
+
#<Country @fifa="ALG", @key="dz", @name="Algeria">,
|
27
|
+
#<Country @fifa="ASA", @key="as", @name="American Samoa">,
|
28
|
+
#<Country @fifa="AND", @key="ad", @name="Andorra">,
|
29
|
+
#<Country @fifa="ANG", @key="ao", @name="Angola">,
|
30
|
+
#<Country @fifa="AIA", @key="ai", @name="Anguilla">,
|
31
|
+
#<Country @fifa="ATG", @key="ag", @name="Antigua and Barbuda">,
|
32
|
+
#<Country @fifa="ARG", @key="ar", @name="Argentina">,
|
33
|
+
#<Country @fifa="ARM", @key="am", @name="Armenia">,
|
34
|
+
#<Country @fifa="ARU", @key="aw", @name="Aruba">,
|
35
|
+
#<Country @fifa="AUS", @key="au", @name="Australia">,
|
36
|
+
#<Country @fifa="AUT", @key="at", @name="Austria">,
|
37
|
+
#<Country @fifa="AZE", @key="az", @name="Azerbaijan">,
|
38
|
+
...
|
39
|
+
]
|
40
|
+
```
|
41
|
+
|
42
|
+
Note: If you prefer you can use the all-upcase `FIFA` name as an alias for `Fifa`.
|
43
|
+
|
44
|
+
|
45
|
+
Let's lookup some countries by the fifa (three-letter) code:
|
46
|
+
|
47
|
+
``` ruby
|
48
|
+
eng = Fifa['ENG']
|
49
|
+
# -or-
|
50
|
+
eng = Fifa['eng']
|
51
|
+
eng = Fifa[:eng]
|
52
|
+
|
53
|
+
eng.key #=> "eng"
|
54
|
+
eng.name #=> "England"
|
55
|
+
eng.fifa #=> "ENG"
|
56
|
+
|
57
|
+
|
58
|
+
aut = Fifa['AUT']
|
59
|
+
# -or-
|
60
|
+
aut = Fifa['aut']
|
61
|
+
aut = Fifa[:aut]
|
62
|
+
|
63
|
+
aut.key #=> "at"
|
64
|
+
aut.name #=> "Austria"
|
65
|
+
aut.fifa #=> "AUT"
|
66
|
+
|
67
|
+
...
|
68
|
+
```
|
69
|
+
|
70
|
+
Or get all countries / members by continental confederation:
|
71
|
+
|
72
|
+
- Asian Football Confederation (AFC; 47 members) (a)
|
73
|
+
- Confederation of African Football (CAF; 56 members)
|
74
|
+
- Confederation of North, Central American and Caribbean Association Football (CONCACAF; 41 members) (b)
|
75
|
+
- Confederación Sudamericana de Fútbol (CONMEBOL; 10 members)
|
76
|
+
- Oceania Football Confederation (OFC; 14 members) (a)
|
77
|
+
- Union of European Football Associations (UEFA; 55 members) (c)
|
78
|
+
|
79
|
+
(a) Australia has been a member of the AFC since 2006.
|
80
|
+
|
81
|
+
(b) French Guiana, Guyana and Suriname are CONCACAF members although they are in South America. The French Guiana team is a member of CONCACAF but not of FIFA.
|
82
|
+
|
83
|
+
(c) Teams representing the nations of Armenia, Azerbaijan, Cyprus, Georgia, Israel, Kazakhstan, Russia and Turkey are UEFA members, although the majority or entirety of their territory is outside of continental Europe. Monaco is not member of UEFA or FIFA.
|
84
|
+
|
85
|
+
|
86
|
+
``` ruby
|
87
|
+
Fifa.members( 'FIFA' ).size #=> 211 members -or-
|
88
|
+
Fifa.members( 'World' ).size #=> 211 members
|
89
|
+
|
90
|
+
Fifa.members( 'AFC' ).size #=> 47 members -or-
|
91
|
+
Fifa.members( 'Asia' ).size #=> 47 members
|
92
|
+
|
93
|
+
Fifa.members( 'CAF').size #=> 56 members -or-
|
94
|
+
Fifa.members( 'Africa' ).size #=> 56 members
|
95
|
+
|
96
|
+
Fifa.members( 'CONCACAF').size #=> 41 members -or-
|
97
|
+
Fifa.members( 'North, Central America and Caribbean').size #=> 41 members
|
98
|
+
|
99
|
+
Fifa.members( 'CONMEBOL' ).size #=> 10 members -or-
|
100
|
+
Fifa.members( 'South America' ).size #=> 10 members
|
101
|
+
|
102
|
+
Fifa.members( 'OFC' ).size #=> 14 members -or-
|
103
|
+
Fifa.members( 'Oceania' ).size #=> 14 members
|
104
|
+
|
105
|
+
Fifa.members( 'UEFA' ).size #=> 55 members -or-
|
106
|
+
Fifa.members( 'Europe' ).size #=> 55 members
|
107
|
+
|
108
|
+
...
|
109
|
+
```
|
110
|
+
|
111
|
+
That's it.
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
## What's FIFA¹?
|
116
|
+
|
117
|
+
The World's Football Association / Governing Body
|
118
|
+
uses its own country list and (three-letter²) codes - see
|
119
|
+
the [List of FIFA country codes @ Wikipedia](https://en.wikipedia.org/wiki/List_of_FIFA_country_codes)
|
120
|
+
or the [`countries.txt`](https://github.com/sportdb/sport.db/blob/master/fifa/config/countries.txt) list shipping with this library.
|
121
|
+
|
122
|
+
Trivia - The FIFA member list includes 211 countries (in 2019) while the United Nations (UN)
|
123
|
+
member list only includes 193 countries.
|
124
|
+
For example, for historic reasons the FIFA includes:
|
125
|
+
|
126
|
+
- England › UK (ENG)
|
127
|
+
- Wales › UK (WAL)
|
128
|
+
- Scotland › UK (SCO)
|
129
|
+
- Northern Ireland › UK (NIR)
|
130
|
+
|
131
|
+
but doesn't include the United Kingdom (UK) itself.
|
132
|
+
Or the FIFA includes (non-sovereign) dependent territories or autonomous regions
|
133
|
+
that have their own national team or leagues, for example:
|
134
|
+
|
135
|
+
- Gibraltar › UK (GIB)
|
136
|
+
- Faroe Islands › DK (FRO)
|
137
|
+
- Hong Kong › CN (HKG)
|
138
|
+
- Bermuda › UK (BER)
|
139
|
+
- Puerto Rico › US (PUR)
|
140
|
+
- and others
|
141
|
+
|
142
|
+
|
143
|
+
Note: This library includes non-FIFA member codes and irregular codes
|
144
|
+
from countries in use by regional confederations too, for example:
|
145
|
+
|
146
|
+
- Vatican City (VAT)
|
147
|
+
- Monaco (MCO)
|
148
|
+
- Micronesia (FSM)
|
149
|
+
- Palau (PLW)
|
150
|
+
- Réunion › FR (REU)
|
151
|
+
- Zanzibar › TZ (ZAN)
|
152
|
+
- Saint Martin › FR (SMN)
|
153
|
+
- Sint Maarten › NL (SMA)
|
154
|
+
- and others
|
155
|
+
|
156
|
+
|
157
|
+
¹: [Fédération Internationale de Football Association (FIFA) @ Wikipedia](https://en.wikipedia.org/wiki/FIFA)
|
158
|
+
|
159
|
+
²: Northern Cyprus (TRNC) has a four-letter FIFA country code
|
160
|
+
|
161
|
+
|
162
|
+
## License
|
163
|
+
|
164
|
+
The `fifa` scripts are dedicated to the public domain.
|
165
|
+
Use it as you please with no restrictions whatsoever.
|
166
|
+
|
167
|
+
|
168
|
+
## Questions? Comments?
|
169
|
+
|
170
|
+
Send them along to the
|
171
|
+
[Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
|
172
|
+
Thanks!
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/fifa/version.rb'
|
3
|
+
|
4
|
+
Hoe.spec 'fifa' do
|
5
|
+
|
6
|
+
self.version = Fifa::VERSION
|
7
|
+
|
8
|
+
self.summary = "fifa - the world's football countries and codes (incl. non-member countries and irregular codes)"
|
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-countries', '>= 0.5.1'],
|
24
|
+
]
|
25
|
+
|
26
|
+
self.spec_extras = {
|
27
|
+
required_ruby_version: '>= 2.2.2'
|
28
|
+
}
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,456 @@
|
|
1
|
+
##########################
|
2
|
+
# FIFA country codes
|
3
|
+
#
|
4
|
+
# see en.wikipedia.org/wiki/List_of_FIFA_country_codes
|
5
|
+
# en.wikipedia.org/wiki/List_of_men's_national_association_football_teams
|
6
|
+
#
|
7
|
+
# and github.com/openmundi/world.db/blob/master/1-codes/fifa.txt
|
8
|
+
# and www.rsssf.com/miscellaneous/fifa-codes.html
|
9
|
+
|
10
|
+
##
|
11
|
+
# note: all dependencies n territories marked w/
|
12
|
+
# › UK, FR, NZ, AU, US, NL, DK, CN etc.
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
#################
|
17
|
+
## 211 regular FIFA members (in 2019)
|
18
|
+
##
|
19
|
+
## Key Name, FIFA
|
20
|
+
|
21
|
+
=========================================
|
22
|
+
== Europe
|
23
|
+
# Note: The UEFA member country Kazachstan from Asia is listed in Asia.
|
24
|
+
# Note: The UEFA member country Israel from Asia is listed in Middle East.
|
25
|
+
|
26
|
+
al Albania, ALB, fifa › uefa
|
27
|
+
ad Andorra, AND, fifa › uefa
|
28
|
+
at Austria, AUT, fifa › uefa
|
29
|
+
| Österreich [de]
|
30
|
+
|
31
|
+
|
32
|
+
by Belarus, BLR, fifa › uefa
|
33
|
+
be Belgium, BEL, fifa › uefa
|
34
|
+
ba Bosnia and Herzegovina, BIH, fifa › uefa
|
35
|
+
| Bosnia-Herzegovina | Bosnia | Bosnia-Herz.
|
36
|
+
bg Bulgaria, BUL, fifa › uefa
|
37
|
+
|
38
|
+
hr Croatia, CRO, fifa › uefa
|
39
|
+
| Hrvatska [hr]
|
40
|
+
cy Cyprus, CYP, fifa › uefa
|
41
|
+
cz Czech Republic, CZE, fifa › uefa
|
42
|
+
|
43
|
+
dk Denmark, DEN, fifa › uefa
|
44
|
+
|
45
|
+
ee Estonia, EST, fifa › uefa
|
46
|
+
es Spain, ESP, fifa › uefa
|
47
|
+
| España [es]
|
48
|
+
|
49
|
+
fi Finland, FIN, fifa › uefa
|
50
|
+
fr France, FRA, fifa › uefa
|
51
|
+
|
52
|
+
de Germany, GER, fifa › uefa
|
53
|
+
| Deutschland [de]
|
54
|
+
gr Greece, GRE, fifa › uefa
|
55
|
+
|
56
|
+
hu Hungary, HUN, fifa › uefa
|
57
|
+
|
58
|
+
is Iceland, ISL, fifa › uefa
|
59
|
+
it Italy, ITA, fifa › uefa
|
60
|
+
ie Ireland, IRL, fifa › uefa
|
61
|
+
| Republic of Ireland
|
62
|
+
|
63
|
+
lv Latvia, LVA, fifa › uefa
|
64
|
+
| Latvija
|
65
|
+
li Liechtenstein, LIE, fifa › uefa
|
66
|
+
lt Lithuania, LTU, fifa › uefa
|
67
|
+
lu Luxembourg, LUX, fifa › uefa
|
68
|
+
|
69
|
+
mk North Macedonia, MKD, fifa › uefa
|
70
|
+
| Macedonia
|
71
|
+
mt Malta, MLT, fifa › uefa
|
72
|
+
md Moldova, MDA, fifa › uefa
|
73
|
+
me Montenegro, MNE, fifa › uefa
|
74
|
+
|
75
|
+
nl Netherlands, NED, fifa › uefa
|
76
|
+
no Norway, NOR, fifa › uefa
|
77
|
+
|
78
|
+
pl Poland, POL, fifa › uefa
|
79
|
+
pt Portugal, POR, fifa › uefa
|
80
|
+
|
81
|
+
ro Romania, ROU, fifa › uefa
|
82
|
+
ru Russia, RUS, fifa › uefa
|
83
|
+
|
84
|
+
sm San Marino, SMR, fifa › uefa
|
85
|
+
rs Serbia, SRB, fifa › uefa
|
86
|
+
sk Slovakia, SVK, fifa › uefa
|
87
|
+
si Slovenia, SVN, fifa › uefa
|
88
|
+
se Sweden, SWE, fifa › uefa
|
89
|
+
ch Switzerland, SUI, fifa › uefa
|
90
|
+
| Confoederatio Helvetica
|
91
|
+
|
92
|
+
tr Turkey, TUR, fifa › uefa
|
93
|
+
ua Ukraine, UKR, fifa › uefa
|
94
|
+
|
95
|
+
xk Kosovo, KVX, fifa › uefa # -- note: Kosovo is not listed as an ISO standard country. The unofficial 2 and 3-digit codes are used by the European Commission and others until Kosovo is assigned an ISO code
|
96
|
+
| KOS # note: KOS used by UEFA, KVX by FIFA (use FIFA code for now)
|
97
|
+
|
98
|
+
## south caucasus
|
99
|
+
## - add to middle east?
|
100
|
+
|
101
|
+
am Armenia, ARM, fifa › uefa
|
102
|
+
az Azerbaijan, AZE, fifa › uefa
|
103
|
+
ge Georgia, GEO, fifa › uefa
|
104
|
+
|
105
|
+
|
106
|
+
# Territories & Dependencies
|
107
|
+
fo Faroe Islands › DK, FRO, fifa › uefa
|
108
|
+
gi Gibraltar › UK, GIB, fifa › uefa
|
109
|
+
|
110
|
+
nkr Artsakh › AZ, NKR # note: NOT fifa or uefa member
|
111
|
+
bsq Basque Country › ES, BSQ # note: NOT fifa or uefa member
|
112
|
+
cat Catalonia › ES, CAT # note: NOT fifa or uefa member
|
113
|
+
## fix (use four-letter codes!!)
|
114
|
+
## trnc Northern Cyprus › CY, TRNC # note: NOT fifa or uefa member
|
115
|
+
|
116
|
+
## not members
|
117
|
+
# - Great Britain - only all its member e.g. England/Wales/Scotland/Northern Irland
|
118
|
+
uk Great Britain, GBR # note: NOT fifa or uefa member
|
119
|
+
eng England › UK, ENG, fifa › uefa
|
120
|
+
wal Wales › UK, WAL, fifa › uefa
|
121
|
+
sco Scotland › UK, SCO, fifa › uefa
|
122
|
+
nir Northern Ireland › UK, NIR, fifa › uefa
|
123
|
+
| N. Ireland
|
124
|
+
|
125
|
+
## irregular codes
|
126
|
+
va Vatican City, VAT ## no "official" fifa code - listed in "irregular" codes
|
127
|
+
mc Monaco, MCO ## no "official" fifa code - listed in "irregular" codes
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
========================================
|
132
|
+
== Africa
|
133
|
+
|
134
|
+
### Eastern Africa
|
135
|
+
bi Burundi, BDI, fifa › caf › cecafa
|
136
|
+
dj Djibouti, DJI, fifa › caf › cecafa
|
137
|
+
er Eritrea, ERI, fifa › caf › cecafa
|
138
|
+
et Ethiopia, ETH, fifa › caf › cecafa
|
139
|
+
ke Kenya, KEN, fifa › caf › cecafa
|
140
|
+
rw Rwanda, RWA, fifa › caf › cecafa
|
141
|
+
so Somalia, SOM, fifa › caf › cecafa
|
142
|
+
tz Tanzania, TAN, fifa › caf › cecafa
|
143
|
+
ug Uganda, UGA, fifa › caf › cecafa
|
144
|
+
|
145
|
+
km Comoros, COM, fifa › caf › cosafa
|
146
|
+
mg Madagascar, MAD, fifa › caf › cosafa
|
147
|
+
mw Malawi, MWI, fifa › caf › cosafa
|
148
|
+
mu Mauritius, MRI, fifa › caf › cosafa
|
149
|
+
mz Mozambique, MOZ, fifa › caf › cosafa
|
150
|
+
sc Seychelles, SEY, fifa › caf › cosafa
|
151
|
+
zm Zambia, ZAM, fifa › caf › cosafa
|
152
|
+
zw Zimbabwe, ZIM, fifa › caf › cosafa
|
153
|
+
|
154
|
+
|
155
|
+
### Central Africa
|
156
|
+
ao Angola, ANG, fifa › caf › cosafa
|
157
|
+
cm Cameroon, CMR, fifa › caf › uniffac
|
158
|
+
cf Central African Republic, CTA, fifa › caf › uniffac
|
159
|
+
| C. Afr. Rep.
|
160
|
+
td Chad, CHA, fifa › caf › uniffac
|
161
|
+
cg Congo, CGO, fifa › caf › uniffac
|
162
|
+
| Congo-Brazzaville | Congo-Brazz.
|
163
|
+
cd Congo DR, COD, fifa › caf › uniffac ## use "Congo, DR"
|
164
|
+
| DR Congo | Democratic Republic of the Congo
|
165
|
+
| Congo-Kinshasa | Congo-Kinsh.
|
166
|
+
gq Equatorial Guinea, EQG, fifa › caf › uniffac
|
167
|
+
| Equat. Guinea
|
168
|
+
ga Gabon, GAB, fifa › caf › uniffac
|
169
|
+
st São Tomé and Príncipe, STP, fifa › caf › uniffac
|
170
|
+
| São Tomé e Príncipe | São Tomé/Pr.
|
171
|
+
|
172
|
+
|
173
|
+
### Northern Africa
|
174
|
+
dz Algeria, ALG, fifa › caf › unaf
|
175
|
+
eg Egypt, EGY, fifa › caf › unaf
|
176
|
+
ma Morocco, MAR, fifa › caf › unaf
|
177
|
+
ly Libya, LBY, fifa › caf › unaf
|
178
|
+
tn Tunisia, TUN, fifa › caf › unaf
|
179
|
+
ss South Sudan, SSD, fifa › caf › cecafa
|
180
|
+
sd Sudan, SDN, fifa › caf › cecafa
|
181
|
+
|
182
|
+
|
183
|
+
### Southern Africa
|
184
|
+
za South Africa, RSA, fifa › caf › cosafa
|
185
|
+
bw Botswana, BOT, fifa › caf › cosafa
|
186
|
+
ls Lesotho, LES, fifa › caf › cosafa
|
187
|
+
na Namibia, NAM, fifa › caf › cosafa
|
188
|
+
sz Eswatini, SWZ, fifa › caf › cosafa
|
189
|
+
| Swaziland # officially renamed in 2018 from Swaziland to Eswatini
|
190
|
+
|
191
|
+
|
192
|
+
### Western Africa
|
193
|
+
bj Benin, BEN, fifa › caf › wafu
|
194
|
+
bf Burkina Faso, BFA, fifa › caf › wafu
|
195
|
+
cv Cabo Verde, CPV, fifa › caf › wafu
|
196
|
+
| Cape Verde | Cape Verde Islands
|
197
|
+
ci Côte d'Ivoire, CIV, fifa › caf › wafu
|
198
|
+
| Ivory Coast [en]
|
199
|
+
gm Gambia, GAM, fifa › caf › wafu
|
200
|
+
gh Ghana, GHA, fifa › caf › wafu
|
201
|
+
gn Guinea, GUI, fifa › caf › wafu
|
202
|
+
gw Guinea-Bissau, GNB, fifa › caf › wafu
|
203
|
+
lr Liberia, LBR, fifa › caf › wafu
|
204
|
+
ml Mali, MLI, fifa › caf › wafu
|
205
|
+
mr Mauritania, MTN, fifa › caf › wafu
|
206
|
+
ne Niger, NIG, fifa › caf › wafu
|
207
|
+
ng Nigeria, NGA, fifa › caf › wafu
|
208
|
+
sn Senegal, SEN, fifa › caf › wafu
|
209
|
+
sl Sierra Leone, SLE, fifa › caf › wafu
|
210
|
+
tg Togo, TOG, fifa › caf › wafu
|
211
|
+
|
212
|
+
|
213
|
+
# Territories & Dependencies
|
214
|
+
re Réunion › FR, REU, caf # note: NOT fifa member
|
215
|
+
zan Zanzibar › TZ, ZAN, caf › cecafa # note: NOT fifa member -- is a semi-autonomous region of Tanzania
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
==========================================
|
220
|
+
== Middle East
|
221
|
+
|
222
|
+
### Arabian Peninsula
|
223
|
+
bh Bahrain, BHR, fifa › afc › waff
|
224
|
+
kw Kuwait, KUW, fifa › afc › waff
|
225
|
+
om Oman, OMA, fifa › afc › waff
|
226
|
+
qa Qatar, QAT, fifa › afc › waff
|
227
|
+
sa Saudi Arabia, KSA, fifa › afc › waff
|
228
|
+
ae United Arab Emirates, UAE, fifa › afc › waff
|
229
|
+
| UA Emirates
|
230
|
+
ye Yemen, YEM, fifa › afc › waff
|
231
|
+
|
232
|
+
|
233
|
+
### Fertile Crescent
|
234
|
+
iq Iraq, IRQ, fifa › afc › waff
|
235
|
+
il Israel, ISR, fifa › uefa # note: was formerly a member of AFC (1954–1974); joined UEFA in 1994
|
236
|
+
jo Jordan, JOR, fifa › afc › waff
|
237
|
+
lb Lebanon, LIB, fifa › afc › waff
|
238
|
+
ps Palestine, PLE, fifa › afc › waff
|
239
|
+
| Palestinian Territories
|
240
|
+
sy Syria, SYR, fifa › afc › waff
|
241
|
+
|
242
|
+
|
243
|
+
### Iranian Plateau
|
244
|
+
ir Iran, IRN, fifa › afc › cafa # note: NOT waff member
|
245
|
+
| IR Iran | Islamic Republic of Iran
|
246
|
+
|
247
|
+
|
248
|
+
===============================
|
249
|
+
== Asia
|
250
|
+
# Note: UEFA country kazakhstan is listed here in Asia
|
251
|
+
# Note: Australia is listed in pacific (oceania w/ australia)
|
252
|
+
|
253
|
+
### Central Asia
|
254
|
+
kz Kazakhstan, KAZ, fifa › uefa # note: was formerly a member of AFC (1993–2002)
|
255
|
+
kg Kyrgyzstan, KGZ, fifa › afc › cafa
|
256
|
+
| Kyrgyz Republic
|
257
|
+
tj Tajikistan, TJK, fifa › afc › cafa
|
258
|
+
tm Turkmenistan, TKM, fifa › afc › cafa
|
259
|
+
uz Uzbekistan, UZB, fifa › afc › cafa
|
260
|
+
|
261
|
+
|
262
|
+
### East Asia
|
263
|
+
jp Japan, JPN, fifa › afc › eaff
|
264
|
+
kr South Korea, KOR, fifa › afc › eaff
|
265
|
+
| Korea Republic | Republic of Korea ## use "Korea, Republic"
|
266
|
+
kp North Korea, PRK, fifa › afc › eaff
|
267
|
+
| Korea DPR | Democratic People's Republic of Korea ## use "Korea, DPR"
|
268
|
+
cn China, CHN, fifa › afc › eaff
|
269
|
+
| China PR | People's Republic of China ## use "China, PR"
|
270
|
+
tw Taiwan, TPE, fifa › afc › eaff # was a member of OFC from 1975 to 1989
|
271
|
+
| Chinese Taipei | Republic of China
|
272
|
+
mn Mongolia, MNG, fifa › afc › eaff
|
273
|
+
|
274
|
+
# Territories & dependencies
|
275
|
+
hk Hong Kong › CN, HKG, fifa › afc › eaff
|
276
|
+
mo Macao › CN, MAC, fifa › afc › eaff
|
277
|
+
| Macau
|
278
|
+
|
279
|
+
|
280
|
+
### South Asia
|
281
|
+
af Afghanistan, AFG, fifa › afc › cafa
|
282
|
+
pk Pakistan, PAK, fifa › afc › saff
|
283
|
+
in India, IND, fifa › afc › saff
|
284
|
+
bd Bangladesh, BAN, fifa › afc › saff
|
285
|
+
lk Sri Lanka, SRI, fifa › afc › saff
|
286
|
+
np Nepal, NEP, fifa › afc › saff
|
287
|
+
bt Bhutan, BHU, fifa › afc › saff
|
288
|
+
mv Maldives, MDV, fifa › afc › saff
|
289
|
+
|
290
|
+
|
291
|
+
### Southeast Asia
|
292
|
+
id Indonesia, IDN, fifa › afc › aff
|
293
|
+
my Malaysia, MAS, fifa › afc › aff
|
294
|
+
sg Singapore, SIN, fifa › afc › aff
|
295
|
+
th Thailand, THA, fifa › afc › aff
|
296
|
+
ph Philippines, PHI, fifa › afc › aff
|
297
|
+
vn Vietnam, VIE, fifa › afc › aff
|
298
|
+
bn Brunei, BRU, fifa › afc › aff
|
299
|
+
| Brunei Darussalam
|
300
|
+
mm Myanmar, MYA, fifa › afc › aff
|
301
|
+
kh Cambodia, CAM, fifa › afc › aff
|
302
|
+
tl Timor-Leste, TLS, fifa › afc › aff
|
303
|
+
| East Timor
|
304
|
+
la Laos, LAO, fifa › afc › aff
|
305
|
+
|
306
|
+
|
307
|
+
==============================================
|
308
|
+
== Pacific ## Oceania & Australia
|
309
|
+
|
310
|
+
au Australia, AUS, fifa › afc › aff # formerly a member of OFC (1966–2006)
|
311
|
+
|
312
|
+
### Melanesia
|
313
|
+
pg Papua New Guinea, PNG, fifa › ofc
|
314
|
+
| Papua N.G.
|
315
|
+
fj Fiji, FIJ, fifa › ofc
|
316
|
+
sb Solomon Islands, SOL, fifa › ofc
|
317
|
+
| Solomon Isl.
|
318
|
+
vu Vanuatu, VAN, fifa › ofc
|
319
|
+
|
320
|
+
|
321
|
+
### Micronesia
|
322
|
+
pw Palau, PLW # note: NOT fifa member, NOT ofc member
|
323
|
+
# Listed as associate member of the OFC in 2002 and again in 2006. It is unclear whether Palau is still associated with the confederation
|
324
|
+
fm Micronesia, FSM # note: NOT fifa member, NOT ofc member
|
325
|
+
| Federated States of Micronesia
|
326
|
+
ki Kiribati, KIR, ofc # note: NOT fifa member
|
327
|
+
|
328
|
+
|
329
|
+
### Polynesia
|
330
|
+
nz New Zealand, NZL, fifa › ofc # was formerly a member of AFC (1964–1966)
|
331
|
+
ws Samoa, SAM, fifa › ofc
|
332
|
+
to Tonga, TGA, fifa › ofc
|
333
|
+
tv Tuvalu, TUV, ofc # note: NOT fifa member
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
# Territories & Dependencies
|
338
|
+
|
339
|
+
pf Tahiti › FR, TAH, fifa › ofc # todo/check: use French Polynesia (FR) as name - why? why not?
|
340
|
+
| French Polynesia # note: Tahiti, which is located within the Society Islands, is the most populous island, having close to 69% of the population of French Polynesia as of 2017.
|
341
|
+
nc New Caledonia › FR, NCL, fifa › ofc
|
342
|
+
|
343
|
+
as American Samoa › US, ASA, fifa › ofc
|
344
|
+
| Am. Samoa
|
345
|
+
gu Guam › US, GUM, fifa › afc › eaff
|
346
|
+
mp Northern Mariana Islands › US, NMI, afc › eaff # note: NOT fifa member -- was formerly a member of OFC (2005–2009)
|
347
|
+
|
348
|
+
ck Cook Islands › NZ, COK, fifa › ofc
|
349
|
+
nu Niue › NZ, NIU, ofc # note: NOT fifa member
|
350
|
+
|
351
|
+
|
352
|
+
## More Irregular FIFA codes
|
353
|
+
# - Marshall Islands
|
354
|
+
# - Nauru
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
==================================
|
359
|
+
== North America
|
360
|
+
|
361
|
+
ca Canada, CAN, fifa › concacaf › nafu
|
362
|
+
us United States, USA, fifa › concacaf › nafu
|
363
|
+
mx Mexico, MEX, fifa › concacaf › nafu
|
364
|
+
| México [es]
|
365
|
+
|
366
|
+
# Territories & Dependencies
|
367
|
+
bm Bermuda › UK, BER, fifa › concacaf › cfu
|
368
|
+
gl Greenland › DK, GRL
|
369
|
+
|
370
|
+
|
371
|
+
==================================
|
372
|
+
== Central America
|
373
|
+
|
374
|
+
bz Belize, BLZ, fifa › concacaf › uncaf
|
375
|
+
gt Guatemala, GUA, fifa › concacaf › uncaf
|
376
|
+
cr Costa Rica, CRC, fifa › concacaf › uncaf
|
377
|
+
hn Honduras, HON, fifa › concacaf › uncaf
|
378
|
+
sv El Salvador, SLV, fifa › concacaf › uncaf
|
379
|
+
ni Nicaragua, NCA, fifa › concacaf › uncaf
|
380
|
+
pa Panama, PAN, fifa › concacaf › uncaf
|
381
|
+
| Panamá [es]
|
382
|
+
|
383
|
+
|
384
|
+
===============================================
|
385
|
+
== Caribbean ## Caribbean Islands
|
386
|
+
|
387
|
+
cu Cuba, CUB, fifa › concacaf › cfu
|
388
|
+
jm Jamaica, JAM, fifa › concacaf › cfu
|
389
|
+
do Dominican Republic, DOM, fifa › concacaf › cfu
|
390
|
+
ht Haiti, HAI, fifa › concacaf › cfu
|
391
|
+
|
392
|
+
|
393
|
+
ag Antigua and Barbuda, ATG, fifa › concacaf › cfu
|
394
|
+
| Antigua/Barb.
|
395
|
+
bs Bahamas, BAH, fifa › concacaf › cfu
|
396
|
+
bb Barbados, BRB, fifa › concacaf › cfu
|
397
|
+
dm Dominica, DMA, fifa › concacaf › cfu
|
398
|
+
gd Grenada, GRN, fifa › concacaf › cfu
|
399
|
+
kn Saint Kitts and Nevis, SKN, fifa › concacaf › cfu
|
400
|
+
| St. Kitts/N.
|
401
|
+
lc Saint Lucia, LCA, fifa › concacaf › cfu
|
402
|
+
vc Saint Vincent and the Grenadines, VIN, fifa › concacaf › cfu
|
403
|
+
| St. Vincent/G.
|
404
|
+
tt Trinidad and Tobago, TRI, fifa › concacaf › cfu
|
405
|
+
| Trinidad/Tob.
|
406
|
+
|
407
|
+
# Territories & Dependencies
|
408
|
+
pr Puerto Rico › US, PUR, fifa › concacaf › cfu
|
409
|
+
vi US Virgin Islands › US, VIR, fifa › concacaf › cfu # Virgin Islands (U.S.)
|
410
|
+
| United States Virgin Islands | US Virgin I.
|
411
|
+
|
412
|
+
aw Aruba › NL, ARU, fifa › concacaf › cfu
|
413
|
+
cw Curaçao › NL, CUW, fifa › concacaf › cfu
|
414
|
+
|
415
|
+
ai Anguilla › UK, AIA, fifa › concacaf › cfu
|
416
|
+
ky Cayman Islands › UK, CAY, fifa › concacaf › cfu
|
417
|
+
| Cayman Isl.
|
418
|
+
ms Montserrat › UK, MSR, fifa › concacaf › cfu
|
419
|
+
tc Turks and Caicos Islands › UK, TCA, fifa › concacaf › cfu
|
420
|
+
vg British Virgin Islands › UK, VGB, fifa › concacaf › cfu
|
421
|
+
|
422
|
+
|
423
|
+
## Non-FIFA member codes
|
424
|
+
|
425
|
+
gp Guadeloupe › FR, GLP, concacaf › cfu # note: NOT fifa member
|
426
|
+
## check alternative code GPE for Guadeloupe ???
|
427
|
+
mq Martinique › FR, MTQ, concacaf › cfu # note: NOT fifa member
|
428
|
+
mf Saint Martin › FR, SMN, concacaf › cfu # note: NOT fifa member
|
429
|
+
| Saint Martin (French part)
|
430
|
+
## check alternative code SMT for Saint Martin in use ???
|
431
|
+
sx Sint Maarten › NL, SMA, concacaf › cfu # note: NOT fifa member
|
432
|
+
| Sint Maarten (Dutch part)
|
433
|
+
## check alternative code SXM for Sint Maarten in use ???
|
434
|
+
bq Bonaire › NL, BOE, concacaf › cfu # note: NOT fifa member
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
==================================
|
439
|
+
== South America
|
440
|
+
|
441
|
+
ar Argentina, ARG, fifa › conmebol
|
442
|
+
bo Bolivia, BOL, fifa › conmebol
|
443
|
+
br Brazil, BRA, fifa › conmebol
|
444
|
+
cl Chile, CHI, fifa › conmebol
|
445
|
+
co Colombia, COL, fifa › conmebol
|
446
|
+
ec Ecuador, ECU, fifa › conmebol
|
447
|
+
py Paraguay, PAR, fifa › conmebol
|
448
|
+
pe Peru, PER, fifa › conmebol
|
449
|
+
uy Uruguay, URU, fifa › conmebol
|
450
|
+
ve Venezuela, VEN, fifa › conmebol
|
451
|
+
|
452
|
+
gy Guyana, GUY, fifa › concacaf › cfu
|
453
|
+
sr Suriname, SUR, fifa › concacaf › cfu
|
454
|
+
|
455
|
+
gf French Guiana › FR, GUF, concacaf › cfu # note: NOT fifa member
|
456
|
+
## check alternative code GYF for French Guiana ??
|
data/lib/fifa.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
## 3rd party gems
|
5
|
+
require 'sportdb/countries'
|
6
|
+
|
7
|
+
|
8
|
+
###
|
9
|
+
# our own code
|
10
|
+
require 'fifa/version' # let version always go first
|
11
|
+
require 'fifa/countries'
|
12
|
+
|
13
|
+
|
14
|
+
class Fifa
|
15
|
+
def self.countries() country_index.countries; end ## return all country (struct-like) records
|
16
|
+
def self.[]( key ) country_index[ key ]; end
|
17
|
+
|
18
|
+
|
19
|
+
ALT_ORG_NAMES = {
|
20
|
+
'world' => 'fifa',
|
21
|
+
'europe' => 'uefa', #=> Union of European Football Associations
|
22
|
+
'northamericacentralamericacaribbean' => 'concacaf', #=> Confederation of North, Central American and Caribbean Association Football
|
23
|
+
'northcentralamericacaribbean' => 'concacaf', ## e.g. North & Central America and the Caribbean
|
24
|
+
'northamerica' => 'nafu', # => North American Football Union
|
25
|
+
'centralamerica' => 'uncaf', #=> Unión Centroamericana de Fútbol
|
26
|
+
'caribbean' => 'cfu', #=> Caribbean Football Union
|
27
|
+
'africa' => 'caf', # => Confédération Africaine de Football
|
28
|
+
'eastcentralafrica' => 'cecafa', # => Council for East and Central Africa Football Associations
|
29
|
+
'southernafrica' => 'cosafa', # => Council of Southern Africa Football Associations
|
30
|
+
'westafrica' => 'wafu', # => West African Football Union/Union du Football de l'Ouest Afrique
|
31
|
+
'northafrica' => 'unaf', # => Union of North African Federations
|
32
|
+
'centralafrica' => 'uniffac', # => Union des Fédérations du Football de l'Afrique Centrale
|
33
|
+
'asia' => 'afc', # => Asian Football Confederation
|
34
|
+
'middleeast' => 'waff', # => West Asian Football Federation -- note: excludes Iran and Israel
|
35
|
+
'eastasia' => 'eaff',
|
36
|
+
'centralasia' => 'cafa',
|
37
|
+
'southasia' => 'saff',
|
38
|
+
'southeastasia' => 'aff',
|
39
|
+
'oceania' => 'ofc', # => Oceania Football Confederation
|
40
|
+
'pacific' => 'ofc',
|
41
|
+
'southamerica' => 'conmebol', #=> Confederación Sudamericana de Fútbol
|
42
|
+
}
|
43
|
+
|
44
|
+
def self.members( key=:fifa ) ## default to fifa members
|
45
|
+
key = key.to_s.downcase
|
46
|
+
countries = org_index[ key ]
|
47
|
+
|
48
|
+
if countries.nil? ## (re)try / check with alternative (convenience) org name
|
49
|
+
alt_key = ALT_ORG_NAMES[ normalize_org( key ) ]
|
50
|
+
countries = org_index[ alt_key ] if alt_key
|
51
|
+
end
|
52
|
+
countries
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.normalize_org( name )
|
56
|
+
## remove space, comma, ampersand (&) and words: and, the
|
57
|
+
name.gsub( /[ ,&]|\band\b|\bthe\b/, '' )
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def self.orgs() org_index.keys; end ## return list of known org (keys) e.g. fifa, uefa, etc.
|
62
|
+
|
63
|
+
private
|
64
|
+
def self.country_index
|
65
|
+
@country_index ||= build_country_index
|
66
|
+
@country_index
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.build_country_index
|
70
|
+
recs = SportDb::Import::CountryReader.read( "#{Fifa.data_dir}/countries.txt" )
|
71
|
+
CountryIndex.new( recs )
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def self.org_index
|
76
|
+
@org_index ||= build_org_index ## fifa,uefa,etc.
|
77
|
+
@org_index
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.build_org_index
|
81
|
+
orgs = {}
|
82
|
+
countries.each do |country|
|
83
|
+
## note: assumes all tags are sport / fifa tags for now
|
84
|
+
country.tags.each do |tag|
|
85
|
+
orgs[ tag ] ||= []
|
86
|
+
orgs[ tag ] << country
|
87
|
+
end
|
88
|
+
end
|
89
|
+
orgs
|
90
|
+
end
|
91
|
+
end # class Fifa
|
92
|
+
|
93
|
+
|
94
|
+
## add a convenience upcase alias
|
95
|
+
FIFA = Fifa
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
puts Fifa.banner # say hello
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
class Fifa
|
5
|
+
## built-in countries for (quick starter) auto-add
|
6
|
+
|
7
|
+
class CountryIndex
|
8
|
+
|
9
|
+
def initialize( recs )
|
10
|
+
@countries = {} ## countries by fifa code
|
11
|
+
|
12
|
+
add( recs )
|
13
|
+
end
|
14
|
+
|
15
|
+
def countries ## all country records
|
16
|
+
@countries.values
|
17
|
+
end
|
18
|
+
|
19
|
+
def []( key )
|
20
|
+
key = key.to_s.upcase ## allow symbols (and always upcase e.g. aut to AUT etc.)
|
21
|
+
@countries[ key ]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def add( recs )
|
26
|
+
###########################################
|
27
|
+
## auto-fill countries
|
28
|
+
## pp recs
|
29
|
+
recs.each do |rec|
|
30
|
+
|
31
|
+
## add codes lookups - key, fifa, ...
|
32
|
+
if @countries[ rec.fifa ]
|
33
|
+
puts "** !!! ERROR !!! country (fifa) code >#{rec.fifa}< already exits!!"
|
34
|
+
exit 1
|
35
|
+
else
|
36
|
+
@countries[ rec.fifa ] = rec
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end # method add
|
40
|
+
end # class CountryIndex
|
41
|
+
|
42
|
+
end # class Fifa
|
data/lib/fifa/version.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
## note: use class for now - change to module - possible? - why? why not?
|
5
|
+
|
6
|
+
class Fifa
|
7
|
+
MAJOR = 2019 ## todo: namespace inside version or something - why? why not??
|
8
|
+
MINOR = 11
|
9
|
+
PATCH = 27
|
10
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
11
|
+
|
12
|
+
def self.version
|
13
|
+
VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.banner
|
17
|
+
"fifa/#{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__))) )
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.data_dir ## rename to config_dir - why? why not?
|
25
|
+
"#{root}/config"
|
26
|
+
end
|
27
|
+
end # class Fifa
|
data/test/helper.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_countries.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestCountries < MiniTest::Test
|
11
|
+
|
12
|
+
def test_read_countries
|
13
|
+
recs = SportDb::Import::CountryReader.read( "#{Fifa.data_dir}/countries.txt" )
|
14
|
+
## pp recs
|
15
|
+
|
16
|
+
assert_equal [{ key: 'al', fifa: 'ALB', name: 'Albania', tags: ['fifa','uefa']},
|
17
|
+
{ key: 'ad', fifa: 'AND', name: 'Andorra', tags: ['fifa','uefa']}],
|
18
|
+
recs[0..1].map { |rec| { key: rec.key, fifa: rec.fifa, name: rec.name, tags: rec.tags }}
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def test_countries
|
23
|
+
pp Fifa.countries
|
24
|
+
|
25
|
+
eng = Fifa['ENG']
|
26
|
+
assert_equal eng, Fifa['eng']
|
27
|
+
assert_equal eng, Fifa[:eng]
|
28
|
+
|
29
|
+
assert_equal 'eng', eng.key
|
30
|
+
assert_equal 'England', eng.name
|
31
|
+
assert_equal 'ENG', eng.fifa
|
32
|
+
assert_equal ['fifa','uefa'], eng.tags
|
33
|
+
|
34
|
+
assert_equal 'eng', eng[:key]
|
35
|
+
assert_equal 'England', eng[:name]
|
36
|
+
assert_equal 'ENG', eng[:fifa]
|
37
|
+
|
38
|
+
|
39
|
+
aut = Fifa['AUT']
|
40
|
+
assert_equal aut, Fifa['aut']
|
41
|
+
assert_equal aut, Fifa[:aut]
|
42
|
+
|
43
|
+
assert_equal 'at', aut.key
|
44
|
+
assert_equal 'Austria', aut.name
|
45
|
+
assert_equal 'AUT', aut.fifa
|
46
|
+
assert_equal ['fifa','uefa'], aut.tags
|
47
|
+
|
48
|
+
assert_equal 'at', aut[:key]
|
49
|
+
assert_equal 'Austria', aut[:name]
|
50
|
+
assert_equal 'AUT', aut[:fifa]
|
51
|
+
end
|
52
|
+
|
53
|
+
end # class TestCountries
|
data/test/test_orgs.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_orgs.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestOrgs < MiniTest::Test
|
11
|
+
|
12
|
+
def test_orgs
|
13
|
+
orgs = Fifa.orgs
|
14
|
+
pp orgs
|
15
|
+
|
16
|
+
## print counts
|
17
|
+
puts "#{'%3d' % Fifa.countries.size} countries:"
|
18
|
+
orgs.each do |org|
|
19
|
+
countries = Fifa.members( org )
|
20
|
+
puts "#{'%3d' % countries.size} #{org}"
|
21
|
+
end
|
22
|
+
|
23
|
+
## pp Fifa.members( 'OFC' ).sort_by {|rec| rec.name }
|
24
|
+
|
25
|
+
assert_equal 47, Fifa.members( 'AFC' ).size # => Asian Football Confederation
|
26
|
+
assert_equal 56, Fifa.members( 'CAF' ).size # => Confédération Africaine de Football
|
27
|
+
assert_equal 41, Fifa.members( 'CONCACAF' ).size # => Confederation of North, Central American and Caribbean Association Football
|
28
|
+
assert_equal 10, Fifa.members( 'CONMEBOL' ).size # => Confederación Sudamericana de Fútbol
|
29
|
+
assert_equal 14, Fifa.members( 'OFC' ).size # => Oceania Football Confederation
|
30
|
+
assert_equal 55, Fifa.members( 'UEFA' ).size # => Union of European Football Associations
|
31
|
+
|
32
|
+
assert_equal 3, Fifa.members( 'NAFU' ).size # => North American Football Union
|
33
|
+
assert_equal 7, Fifa.members( 'UNCAF' ).size # => Unión Centroamericana de Fútbol
|
34
|
+
assert_equal 31, Fifa.members( 'CFU' ).size # => Caribbean Football Union
|
35
|
+
|
36
|
+
assert_equal 12, Fifa.members( 'WAFF' ).size # => West Asian Football Federation
|
37
|
+
assert_equal 10, Fifa.members( 'EAFF' ).size # => East Asian Football Federation
|
38
|
+
assert_equal 6, Fifa.members( 'CAFA' ).size # => Central Asian Football Association
|
39
|
+
assert_equal 7, Fifa.members( 'SAFF' ).size # => South Asian Football Federation
|
40
|
+
assert_equal 12, Fifa.members( 'AFF' ).size # => ASEAN Football Federation
|
41
|
+
|
42
|
+
assert_equal 12, Fifa.members( 'CECAFA' ).size # => Council for East and Central Africa Football Associations
|
43
|
+
assert_equal 14, Fifa.members( 'COSAFA' ).size # => Council of Southern Africa Football Associations
|
44
|
+
assert_equal 16, Fifa.members( 'WAFU' ).size # => West African Football Union/Union du Football de l'Ouest Afrique
|
45
|
+
assert_equal 5, Fifa.members( 'UNAF' ).size # => Union of North African Federations
|
46
|
+
assert_equal 8, Fifa.members( 'UNIFFAC' ).size # => Union des Fédérations du Football de l'Afrique Centrale
|
47
|
+
|
48
|
+
assert_equal 211, Fifa.members( 'FIFA' ).size
|
49
|
+
|
50
|
+
|
51
|
+
## print countries NOT members of fifa (but of confederation)
|
52
|
+
puts "non-fifa member codes:"
|
53
|
+
Fifa.countries.each do |country|
|
54
|
+
if country.tags.empty? == false &&
|
55
|
+
country.tags.include?( 'fifa' ) == false
|
56
|
+
puts " #{country.name}, #{country.fifa}, #{country.tags.join(' | ')}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
## print countries NOT members of fifa or any confederation (irregular codes)
|
61
|
+
puts "irregular codes:"
|
62
|
+
Fifa.countries.each do |country|
|
63
|
+
puts " #{country.name}, #{country.fifa}" if country.tags.empty?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def test_alt_names
|
69
|
+
## check normalize org key / name
|
70
|
+
assert_equal 'NorthAmericaCentralAmericaCaribbean', Fifa.normalize_org( 'North America, Central America and the Caribbean' )
|
71
|
+
assert_equal 'NorthCentralAmericaCaribbean', Fifa.normalize_org( 'North and Central America and the Caribbean' )
|
72
|
+
assert_equal 'NorthCentralAmericaCaribbean', Fifa.normalize_org( 'North & Central America & Caribbean' )
|
73
|
+
|
74
|
+
|
75
|
+
assert_equal Fifa.members( 'FIFA' ).size, Fifa.members( 'World' ).size
|
76
|
+
assert_equal Fifa.members( 'UEFA' ).size, Fifa.members( 'Europe' ).size
|
77
|
+
assert_equal Fifa.members( 'CAF' ).size, Fifa.members( 'Africa' ).size
|
78
|
+
assert_equal Fifa.members( 'CECAFA' ).size, Fifa.members( 'East and Central Africa' ).size
|
79
|
+
assert_equal Fifa.members( 'COSAFA' ).size, Fifa.members( 'Southern Africa' ).size
|
80
|
+
assert_equal Fifa.members( 'WAFU' ).size, Fifa.members( 'West Africa' ).size
|
81
|
+
assert_equal Fifa.members( 'UNAF' ).size, Fifa.members( 'North Africa' ).size
|
82
|
+
assert_equal Fifa.members( 'UNIFFAC' ).size, Fifa.members( 'Central Africa' ).size
|
83
|
+
assert_equal Fifa.members( 'CONCACAF' ).size, Fifa.members( 'North America, Central America and the Caribbean' ).size
|
84
|
+
assert_equal Fifa.members( 'CONCACAF' ).size, Fifa.members( 'North and Central America and the Caribbean' ).size
|
85
|
+
assert_equal Fifa.members( 'CONCACAF' ).size, Fifa.members( 'North & Central America & Caribbean' ).size
|
86
|
+
assert_equal Fifa.members( 'NAFU' ).size, Fifa.members( 'North America' ).size
|
87
|
+
assert_equal Fifa.members( 'UNCAF' ).size, Fifa.members( 'Central America' ).size
|
88
|
+
assert_equal Fifa.members( 'CFU' ).size, Fifa.members( 'Caribbean' ).size
|
89
|
+
assert_equal Fifa.members( 'CONMEBOL' ).size, Fifa.members( 'South America' ).size
|
90
|
+
assert_equal Fifa.members( 'AFC' ).size, Fifa.members( 'Asia' ).size
|
91
|
+
assert_equal Fifa.members( 'WAFF' ).size, Fifa.members( 'Middle East' ).size
|
92
|
+
assert_equal Fifa.members( 'EAFF' ).size, Fifa.members( 'East Asia' ).size
|
93
|
+
assert_equal Fifa.members( 'CAFA' ).size, Fifa.members( 'Central Asia' ).size
|
94
|
+
assert_equal Fifa.members( 'SAFF' ).size, Fifa.members( 'South Asia' ).size
|
95
|
+
assert_equal Fifa.members( 'AFF' ).size, Fifa.members( 'Southeast Asia' ).size
|
96
|
+
assert_equal Fifa.members( 'OFC' ).size, Fifa.members( 'Oceania' ).size
|
97
|
+
assert_equal Fifa.members( 'OFC' ).size, Fifa.members( 'Pacific' ).size
|
98
|
+
end
|
99
|
+
|
100
|
+
end # class TestOrgs
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fifa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2019.11.27
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sportdb-countries
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.16'
|
55
|
+
description: fifa - the world's football countries and codes (incl. non-member countries
|
56
|
+
and irregular codes)
|
57
|
+
email: opensport@googlegroups.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files:
|
61
|
+
- CHANGELOG.md
|
62
|
+
- Manifest.txt
|
63
|
+
- NOTES.md
|
64
|
+
- README.md
|
65
|
+
- config/countries.txt
|
66
|
+
files:
|
67
|
+
- CHANGELOG.md
|
68
|
+
- Manifest.txt
|
69
|
+
- NOTES.md
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- config/countries.txt
|
73
|
+
- lib/fifa.rb
|
74
|
+
- lib/fifa/countries.rb
|
75
|
+
- lib/fifa/version.rb
|
76
|
+
- test/helper.rb
|
77
|
+
- test/test_countries.rb
|
78
|
+
- test/test_orgs.rb
|
79
|
+
homepage: https://github.com/sportdb/sport.db
|
80
|
+
licenses:
|
81
|
+
- Public Domain
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options:
|
85
|
+
- "--main"
|
86
|
+
- README.md
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.2.2
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.5.2
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: fifa - the world's football countries and codes (incl. non-member countries
|
105
|
+
and irregular codes)
|
106
|
+
test_files: []
|