sportdb 1.8.28 → 1.8.29

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,9 +16,10 @@ module SportDb
16
16
  puts " #{Roster.count} rosters (person+team+event recs)"
17
17
  puts " #{Goal.count} goals (person+game recs)"
18
18
 
19
+ puts " #{Assoc.count} assocs|orgs"
19
20
  puts " #{Ground.count} grounds|stadiums"
20
21
  end
21
-
22
+
22
23
  ## fix/chek:
23
24
  # move to Prop gem / reuse code from Prop gem
24
25
  def props
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.28'
3
+ VERSION = '1.8.29'
4
4
  end
5
5
 
6
6
 
@@ -0,0 +1,231 @@
1
+
2
+ [fifa]
3
+ Fédération Internationale de Football Association (FIFA), 1904
4
+ World
5
+ www.fifa.com
6
+ en.wikipedia: FIFA
7
+ # Zürich, Switzerland
8
+ # 209 members
9
+ # see www.fifa.com/aboutfifa/organisation/associations.html
10
+
11
+ # note: 13 teams are members or associate members
12
+ # of one of the FIFA affiliated continental confederations,
13
+ # but who are not members of FIFA
14
+ # - Northern Mariana Islands (Asia)
15
+ # - Réunion (Africa)
16
+ # - Zanzibar (Africa)
17
+ # - French Guiana (Southamerica /CONCACAF)
18
+ # - Bonaire (Caribbean / CONCACAF)
19
+ # - Guadeloupe (Caribbean / CONCACAF)
20
+ # - Martinique (Caribbean / CONCACAF)
21
+ # - Saint-Martin (Caribbean / CONCACAF)
22
+ # - Sint Maarten (Caribbean / CONCACAF)
23
+ # - Kiribati (Pacific)
24
+ # - Niue (Pacific)
25
+ # - Tuvalu (Pacific)
26
+ # - Gibraltar (Europe)
27
+
28
+
29
+ # note: 7 unaffiliated sovereign states (not fifa or confederation)
30
+ # - Federated States of Micronesia
31
+ # - Nauru
32
+ # - Palau
33
+ # - Marshall Islands (only state w/ no national football team)
34
+ # - United Kingdom (only for olympics otherwise england, walles,etc.)
35
+ # - Monaco
36
+ # - Vatican City
37
+
38
+
39
+ ## assume all upcase is Abbreviation
40
+ ## assume all downcase w/ only [a-z] (if not last entry) is parent assoc (e.g. fifa)
41
+
42
+
43
+ [uefa]
44
+ Union of European Football Associations (UEFA), 1954
45
+ Europe
46
+ www.uefa.com
47
+ en.wikipedia:UEFA
48
+ fifa
49
+ # note: last tag list entry ( e.g. fifa or fifa|uefa etc. assumed as parent assocs - find better style? use header line for all? use [uefa/fifa] ?
50
+ # Nyon, Switzerland
51
+ # 54 members
52
+
53
+ # note: incl. Israel, Kazakhstan (from Asia)
54
+
55
+
56
+ [conmebol]
57
+ Confederación Sudamericana de Fútbol (CONMEBOL), 1916
58
+ South America
59
+ www.conmebol.com
60
+ en.wikipedia:CONMEBOL
61
+ fifa
62
+ # Asunción, Paraguay (Luque)
63
+ # 10 members
64
+
65
+
66
+ [concacaf]
67
+ Confederation of North\, Central American and Caribbean Association Football (CONCACAF), 1961
68
+ North America\, Central America & Caribbean Islands
69
+ www.concacaf.com
70
+ en.wikipedia:CONCACAF
71
+ fifa
72
+ # Miami, Florida, United States
73
+ # 41 members
74
+ # - 31 from the Caribbean
75
+ # - 7 from Central America
76
+ # - 3 from North America
77
+
78
+ # note: incl. French Guiana, Guyana and Suriname members (from South America)
79
+
80
+
81
+ [caf]
82
+ Confédération Africaine de Football (CAF), 1957
83
+ Africa
84
+ www.cafonline.com
85
+ en.wikipedia:Confederation_of_African_Football
86
+ fifa
87
+ # Cairo, Egypt (6th of October City)
88
+ # 56 members
89
+
90
+ [afc]
91
+ Asian Football Confederation (AFC), 1954
92
+ Asia # incl. Middle East, Australia
93
+ www.the-afc.com
94
+ en.wikipedia:Asian_Football_Confederation
95
+ fifa
96
+ # Kuala Lumpur, Malaysia
97
+ # 46+1 members
98
+
99
+ # note: incl. Australia member since 2006 (from Pacific/Oceania)
100
+
101
+
102
+ [ofc]
103
+ Oceania Football Confederation (OFC), 1966
104
+ Pacific # Oceania
105
+ www.oceaniafootball.com
106
+ en.wikipedia:Oceania_Football_Confederation
107
+ fifa
108
+ # Auckland, New Zealand
109
+ # 14 members (11 full)
110
+
111
+
112
+ ############################
113
+ # more sub confederations
114
+
115
+
116
+ #####
117
+ # CONCACAF - 3 regions
118
+
119
+ [nafu]
120
+ North American Football Union (NAFU) / North American Zone
121
+ # 3 members
122
+ en.wikipedia:North_American_Football_Union
123
+ concacaf
124
+ # note: has no org structure (just "informal"); no longer any competions
125
+
126
+ [uncaf]
127
+ Unión Centroamericana de Fútbol (UNCAF) / Central American Zone
128
+ www.uncafut.com
129
+ en.wikipedia:Central_American_Football_Union
130
+ concacaf
131
+ # 7 members
132
+
133
+ [cfu]
134
+ Caribbean Football Union (CFU) / Caribbean Zone
135
+ www.cfufootball.org
136
+ en.wikipedia:Caribbean_Football_Union
137
+ concacaf
138
+ # 31 members
139
+
140
+ #########
141
+ # CAF (Africa) - 5 regions
142
+
143
+ [cecafa]
144
+ Council for East and Central Africa Football Associations (CECAFA)
145
+ Eastern Africa
146
+ www.cecafafootball.org
147
+ en.wikipedia:Council_for_East_and_Central_Africa_Football_Associations
148
+ # 12 members
149
+ # East Africa and some nations of Central Africa
150
+
151
+
152
+ [cosafa]
153
+ Council of Southern Africa Football Associations (COSAFA)
154
+ Southern Africa
155
+ www.cosafa.com
156
+ en.wikipedia:Council_of_Southern_Africa_Football_Associations
157
+ # 14 members
158
+ # Southern Africa plus island states off the coast of Southern Africa
159
+
160
+ [wafu]
161
+ West African Football Union (WAFU)
162
+ Western Africa
163
+ en.wikipedia:West_Africa_Football_Union
164
+ # Zone A - 9 members
165
+ # Zone B - 7 members
166
+
167
+
168
+ [unaf]
169
+ Union of North African Federations (UNAF)
170
+ Northern Africa
171
+ en.wikipedia:Union_of_North_African_Football_Federations
172
+ # Tunis, Tunisia
173
+ # 5 members
174
+
175
+
176
+ [uniffac]
177
+ Union des Fédérations du Football de l'Afrique Centrale (UNIFFAC)
178
+ Central Africa
179
+ en.wikipedia:Central_African_Football_Federations'_Union
180
+ # 8 members
181
+
182
+ ############
183
+ # AFC / Asia
184
+ #
185
+ # - AFC is subdivided into four sub-federations
186
+
187
+ [waff]
188
+ West Asian Football Federation (WAFF), 2001
189
+ West Asia (Middle East)
190
+ www.the-waff.com
191
+ en.wikipedia:West_Asian_Football_Federation
192
+ # 13 members
193
+ # represents nations at the western extremity of the continent
194
+
195
+ [eaff]
196
+ East Asian Football Federation (EAFF), 2002
197
+ East Asia
198
+ www.eaff.com
199
+ en.wikipedia:East_Asian_Football_Federation
200
+ # Tokyo, Japan
201
+ # 10 members
202
+ # represents nations in Northeast Asia, plus Guam and Northern Mariana Islands
203
+
204
+ [csaff]
205
+ Central and South Asian Football Federation (CSAFF)
206
+ Central and South Asia
207
+ en.wikipedia:Central_and_South_Asian_Football_Federation
208
+ # 12 members
209
+ # represents nations in Central Asia and South Asia
210
+
211
+ [aff]
212
+ Association of South East Asian Nations Football Federation (AFF), 1984
213
+ Southeast Asia & Australia
214
+ www.aseanfootball.org
215
+ en.wikipedia:ASEAN_Football_Federation
216
+ # Petaling Jaya, Selangor, Malaysia
217
+ # 12 members
218
+ # represents nations in Southeast Asia, plus Australia
219
+
220
+
221
+ #######################
222
+ # inter-continental
223
+
224
+ [uafa]
225
+ Union of Arab Football Associations (UAFA), 1974
226
+ Arab League / League of Arab States
227
+ www.uafaonline.com
228
+ en.wikipedia:Union_of_Arab_Football_Associations
229
+ # Riyadh, Saudi Arabia
230
+ # 22 members
231
+ # AFC members (asia/middle east) + CAF (africa) members
@@ -0,0 +1,13 @@
1
+ #######################
2
+ # Europe
3
+
4
+ assocaut, Österreichischer Fußball-Bund, at, fifa|uefa ## Austria
5
+ assocbel, Koninklijke Belgische Voetbalbond, be, fifa|uefa ## Belgium
6
+ assoccyp, Cyprus Football Association, cy, fifa|uefa ## Cyprus
7
+ assocger, Deutscher Fußball-Bund, de, fifa|uefa ## Germany
8
+ assocest, Eesti Jalgpalli Liit, ee, fifa|uefa ## Estonia
9
+ assocesp, Real Federación Española de Fútbol, es, fifa|uefa ## Spain
10
+ assocfin, Suomen Palloliitto, fi, fifa|uefa ## Finland
11
+ assocfra, Fédération Française de Football, fr, fifa|uefa ## France
12
+ associrl, Football Association of Ireland, ie, fifa|uefa ## Ireland
13
+ associta, Federazione Italiana Giuoco Calcio, it, fifa|uefa ## Italy
@@ -0,0 +1,13 @@
1
+ #######################
2
+ # Europe
3
+
4
+ aut, Austria, AUT, at
5
+ bel, Belgium, BEL, be
6
+ cyp, Cyprus, CYP, cy
7
+ ger, Germany, GER, de
8
+ est, Estonia, EST, ee
9
+ esp, Spain, ESP, es
10
+ fin, Finland, FIN, fi
11
+ fra, France, FRA, fr
12
+ irl, Ireland, IRL, ie
13
+ ita, Italy, ITA, it
@@ -0,0 +1,10 @@
1
+ ####################
2
+ # North America
3
+
4
+ # CONCACAF / NAFU (North American Football Union)
5
+ # - 3 members (North American Zone)
6
+
7
+ assocmex, Federación Mexicana de Fútbol Asociación, mx, fifa|concacaf|nafu ## Mexico
8
+ assocusa, United States Soccer Federation, us, fifa|concacaf|nafu ## United States
9
+ assoccan, Canadian Soccer Association, ca, fifa|concacaf|nafu ## Canada
10
+
@@ -0,0 +1,7 @@
1
+ ####################
2
+ # North America
3
+ # - CONCACAF / NAFU (North American Football Union)
4
+
5
+ mex, Mexico, MEX, mx
6
+ usa, United States, USA, us
7
+ can, Canada, CAN, ca
@@ -0,0 +1,19 @@
1
+
2
+ ########################
3
+ # Africa
4
+ # - CAF (Africa) - 5 regions
5
+ # - UNAF (Union of North African Football Federations)
6
+
7
+ alg, Algeria, ALG, dz
8
+ egy, Egypt, EGY, eg
9
+
10
+ ###############################
11
+ # Oceania w/ Australia
12
+
13
+ aus, Australia, AUS, au
14
+ nzl, New Zealand, NZL, nz
15
+
16
+ # not FIFA members
17
+
18
+ kir, Kiribati, KIR, ki
19
+ tuv, Tuvalu, TUV, tv
@@ -19,11 +19,13 @@ Country = WorldDb::Model::Country
19
19
 
20
20
  Person = PersonDb::Model::Person
21
21
 
22
- League = SportDb::Model::League
23
- Season = SportDb::Model::Season
24
- Event = SportDb::Model::Event
25
- Team = SportDb::Model::Team
26
- Roster = SportDb::Model::Roster
22
+ League = SportDb::Model::League
23
+ Season = SportDb::Model::Season
24
+ Event = SportDb::Model::Event
25
+ Team = SportDb::Model::Team
26
+ Roster = SportDb::Model::Roster
27
+ Assoc = SportDb::Model::Assoc
28
+ AssocAssoc = SportDb::Model::AssocAssoc
27
29
 
28
30
  Round = SportDb::Model::Round
29
31
  Group = SportDb::Model::Group
@@ -45,6 +47,7 @@ AlltimeStandingEntry = SportDb::Model::AlltimeStandingEntry
45
47
 
46
48
  Reader = SportDb::Reader
47
49
  TeamReader = SportDb::TeamReader
50
+ AssocReader = SportDb::AssocReader
48
51
  SeasonReader = SportDb::SeasonReader
49
52
  LeagueReader = SportDb::LeagueReader
50
53
  GameReader = SportDb::GameReader
@@ -0,0 +1,199 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_assoc_reader.rb
6
+ # or better
7
+ # rake -I ./lib test
8
+
9
+
10
+ require 'helper'
11
+
12
+ class TestAssocReader < MiniTest::Unit::TestCase
13
+
14
+ def setup
15
+ WorldDb.delete!
16
+ SportDb.delete!
17
+ PersonDb.delete!
18
+ end
19
+
20
+ def test_models
21
+ assert_equal 0, Assoc.count
22
+ assert_equal 0, Team.count
23
+ assert_equal 0, AssocAssoc.count
24
+
25
+ uefa = Assoc.create!( key: 'uefa', title: 'UEFA' )
26
+ assert_equal 1, Assoc.count
27
+
28
+ at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
29
+ assocaut = Assoc.create!( key: 'assocaut', title: 'Assoc Austria',
30
+ national: true, country_id: at.id )
31
+
32
+ aut = Team.create!( key: 'aut', title: 'Austria', code: 'AUT',
33
+ country_id: at.id,
34
+ assoc_id: assocaut.id )
35
+
36
+ assert_equal 1, Team.count
37
+ assert_equal 'Assoc Austria', aut.assoc.title # team.assoc belongs_to ref
38
+ assert_equal 'Assoc Austria', at.assoc.title # country.assoc has_one ref
39
+
40
+ assert_equal 0, AssocAssoc.count
41
+
42
+ AssocAssoc.create!( assoc1_id: uefa.id, assoc2_id: assocaut.id )
43
+
44
+ assert_equal 1, AssocAssoc.count
45
+ assert_equal 1, uefa.member_assoc_assocs.count
46
+ assert_equal 1, uefa.all_assocs.count
47
+ assert_equal 0, uefa.sub_assocs.count
48
+ assert_equal 1, uefa.national_assocs.count
49
+ assert_equal 0, uefa.parent_assoc_assocs.count
50
+ assert_equal 0, uefa.parent_assocs.count
51
+ assert_equal 1, assocaut.parent_assoc_assocs.count
52
+ assert_equal 1, assocaut.parent_assocs.count
53
+ assert_equal 0, assocaut.member_assoc_assocs.count
54
+ assert_equal 0, assocaut.all_assocs.count
55
+
56
+
57
+ it = Country.create!( key: 'it', name: 'Italy', code: 'ITA', pop: 1, area: 1)
58
+ associta = Assoc.create!( key: 'associta', title: 'Assoc Italy',
59
+ national: true, country_id: it.id )
60
+
61
+ ita = Team.create!( key: 'ita', title: 'Italy', code: 'ITA',
62
+ country_id: it.id,
63
+ assoc_id: associta.id )
64
+
65
+ assert_equal 2, Team.count
66
+ assert_equal 'Assoc Italy', ita.assoc.title # team.assoc belongs_to ref
67
+ assert_equal 'Assoc Italy', it.assoc.title # country.assoc has_one ref
68
+
69
+ AssocAssoc.create!( assoc1_id: uefa.id, assoc2_id: associta.id )
70
+
71
+ assert_equal 2, AssocAssoc.count
72
+ assert_equal 2, uefa.member_assoc_assocs.count
73
+ assert_equal 2, uefa.national_assocs.count
74
+ assert_equal 0, uefa.sub_assocs.count
75
+ assert_equal 0, uefa.parent_assoc_assocs.count
76
+ assert_equal 1, associta.parent_assoc_assocs.count
77
+ assert_equal 0, associta.member_assoc_assocs.count
78
+ end
79
+
80
+
81
+ def test_assocs
82
+ reader = AssocReader.new( SportDb.test_data_path )
83
+ reader.read( 'national-teams/assocs' )
84
+
85
+ assert_equal 20, Assoc.count
86
+
87
+ fifa = Assoc.find_by_key!( 'fifa' )
88
+
89
+ assert_equal 'Fédération Internationale de Football Association (FIFA)', fifa.title
90
+ assert_equal 1904, fifa.since
91
+ assert_equal 'www.fifa.com', fifa.web
92
+ assert_equal 0, fifa.parent_assoc_assocs.count
93
+ assert_equal 6, fifa.member_assoc_assocs.count
94
+ assert_equal 6, fifa.all_assocs.count
95
+ assert_equal 6, fifa.sub_assocs.count
96
+ assert_equal 0, fifa.national_assocs.count
97
+ assert_equal 0, fifa.parent_assocs.count
98
+
99
+ uefa = Assoc.find_by_key!( 'uefa' )
100
+
101
+ assert_equal 'Union of European Football Associations (UEFA)', uefa.title
102
+ assert_equal 1954, uefa.since
103
+ assert_equal 'www.uefa.com', uefa.web
104
+ assert_equal 1, uefa.parent_assoc_assocs.count
105
+ assert_equal 0, uefa.member_assoc_assocs.count
106
+ assert_equal 0, uefa.all_assocs.count
107
+ assert_equal 0, uefa.sub_assocs.count
108
+ assert_equal 0, uefa.national_assocs.count
109
+ assert_equal 1, uefa.parent_assocs.count
110
+
111
+ concacaf = Assoc.find_by_key!( 'concacaf' )
112
+
113
+ assert_equal 'Confederation of North, Central American and Caribbean Association Football (CONCACAF)', concacaf.title
114
+ assert_equal 1961, concacaf.since
115
+ assert_equal 1, concacaf.parent_assoc_assocs.count
116
+ assert_equal 3, concacaf.member_assoc_assocs.count
117
+ assert_equal 3, concacaf.all_assocs.count
118
+ assert_equal 3, concacaf.sub_assocs.count
119
+ assert_equal 0, concacaf.national_assocs.count
120
+ assert_equal 1, concacaf.parent_assocs.count
121
+
122
+
123
+ mx = Country.create!( key: 'mx', name: 'Mexico', code: 'MEX', pop: 1, area: 1)
124
+ ca = Country.create!( key: 'ca', name: 'Canada', code: 'CAN', pop: 1, area: 1)
125
+ us = Country.create!( key: 'us', name: 'United States', code: 'USA', pop: 1, area: 1)
126
+
127
+ reader.read( 'national-teams/north-america/assocs' )
128
+
129
+ assert_equal 23, Assoc.count
130
+
131
+ assert_equal 6+3, fifa.all_assocs.count
132
+ assert_equal 6, fifa.sub_assocs.count
133
+ assert_equal 0+3, fifa.national_assocs.count
134
+
135
+ assert_equal 3+3, concacaf.all_assocs.count
136
+ assert_equal 3, concacaf.sub_assocs.count
137
+ assert_equal 0+3, concacaf.national_assocs.count
138
+ assert_equal 1, concacaf.parent_assocs.count
139
+
140
+ assocusa = Assoc.find_by_key!( 'assocusa' )
141
+ assert_equal 'United States Soccer Federation', assocusa.title
142
+ assert_equal 3, assocusa.parent_assocs.count
143
+ assert_equal 0, assocusa.all_assocs.count
144
+ assert_equal 0, assocusa.sub_assocs.count
145
+ assert_equal 0, assocusa.national_assocs.count
146
+
147
+ end # method test_assocs
148
+
149
+
150
+ def test_teams
151
+ assocreader = AssocReader.new( SportDb.test_data_path )
152
+ assocreader.read( 'national-teams/assocs' )
153
+
154
+ assert_equal 20, Assoc.count
155
+
156
+ ## add countries
157
+ countries = [['mx', 'Mexico', 'MEX'],
158
+ ['us', 'United States', 'USA'],
159
+ ['ca', 'Canada', 'CAN'],
160
+ ['dz', 'Algeria', 'ALG'],
161
+ ['eg', 'Egypt', 'EGY'],
162
+ ['au', 'Australia', 'AUS'],
163
+ ['nz', 'New Zealand', 'NZL'],
164
+ ['ki', 'Kiribati', 'KIR'],
165
+ ['tv', 'Tuvalu', 'TUV']]
166
+
167
+ countries.each do |country|
168
+ Country.create!( key: country[0],
169
+ name: country[1],
170
+ code: country[2],
171
+ pop: 1,
172
+ area: 1)
173
+ end
174
+
175
+ teamreader = TeamReader.new( SportDb.test_data_path )
176
+ teamreader.read( 'national-teams/teams' )
177
+ teamreader.read( 'national-teams/north-america/teams' )
178
+
179
+ assert_equal 9, Team.count
180
+
181
+ ## fifa = Assoc.find_by_key!( 'fifa' )
182
+ ## assert_equal 7, fifa.teams.count
183
+
184
+ ## ofc = Assoc.find_by_key!( 'ofc' )
185
+ ## assert_equal 3, ofc.teams.count
186
+
187
+ ## mex = Team.find_by_key!( 'mex' )
188
+ ## assert_equal 3, mex.assocs.count
189
+
190
+ ## tuv = Team.find_by_key!( 'tuv' )
191
+ ## assert_equal 1, tuv.assocs.count
192
+
193
+ ### fix/todo: run teamreader again!! (2nd run)
194
+ ## assert no new assocs (just update existing)
195
+
196
+ end # method test_teams
197
+
198
+
199
+ end # class TestAssocReader