sportdb 1.9.16 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +2 -19
- data/Manifest.txt +1 -137
- data/README.md +2 -21
- data/Rakefile +14 -25
- data/lib/sportdb.rb +9 -260
- data/lib/sportdb/cli/main.rb +5 -14
- data/lib/sportdb/cli/opts.rb +2 -0
- data/lib/sportdb/cli/version.rb +26 -0
- metadata +10 -278
- data/.gemtest +0 -0
- data/config/fixtures/de.yml +0 -46
- data/config/fixtures/en.yml +0 -54
- data/config/fixtures/es.yml +0 -48
- data/config/fixtures/fr.yml +0 -53
- data/config/fixtures/it.yml +0 -55
- data/config/fixtures/pt.yml +0 -46
- data/config/fixtures/ro.yml +0 -55
- data/data/seasons.txt +0 -74
- data/data/setups/all.txt +0 -5
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/deleter.rb +0 -52
- data/lib/sportdb/finders/date.rb +0 -374
- data/lib/sportdb/finders/goals.rb +0 -260
- data/lib/sportdb/finders/scores.rb +0 -122
- data/lib/sportdb/lang.rb +0 -216
- data/lib/sportdb/matcher.rb +0 -31
- data/lib/sportdb/models/assoc.rb +0 -106
- data/lib/sportdb/models/assoc_assoc.rb +0 -15
- data/lib/sportdb/models/badge.rb +0 -14
- data/lib/sportdb/models/event.rb +0 -65
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/forward.rb +0 -55
- data/lib/sportdb/models/game.rb +0 -244
- data/lib/sportdb/models/goal.rb +0 -15
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group.rb +0 -23
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/person.rb +0 -21
- data/lib/sportdb/models/roster.rb +0 -18
- data/lib/sportdb/models/round.rb +0 -22
- data/lib/sportdb/models/season.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/alltime_standing_entry.rb +0 -23
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/event_standing_entry.rb +0 -21
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/stats/group_standing_entry.rb +0 -22
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_comp.rb +0 -64
- data/lib/sportdb/models/utils.rb +0 -78
- data/lib/sportdb/models/world/city.rb +0 -21
- data/lib/sportdb/models/world/continent.rb +0 -20
- data/lib/sportdb/models/world/country.rb +0 -19
- data/lib/sportdb/models/world/region.rb +0 -19
- data/lib/sportdb/patterns.rb +0 -38
- data/lib/sportdb/reader.rb +0 -130
- data/lib/sportdb/reader_file.rb +0 -123
- data/lib/sportdb/reader_zip.rb +0 -165
- data/lib/sportdb/readers/assoc.rb +0 -54
- data/lib/sportdb/readers/event.rb +0 -200
- data/lib/sportdb/readers/game.rb +0 -877
- data/lib/sportdb/readers/ground.rb +0 -53
- data/lib/sportdb/readers/league.rb +0 -54
- data/lib/sportdb/readers/season.rb +0 -83
- data/lib/sportdb/readers/squad_club.rb +0 -201
- data/lib/sportdb/readers/squad_national_team.rb +0 -173
- data/lib/sportdb/readers/team.rb +0 -53
- data/lib/sportdb/schema.rb +0 -373
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
- data/lib/sportdb/utils.rb +0 -89
- data/lib/sportdb/utils_date.rb +0 -26
- data/lib/sportdb/utils_goals.rb +0 -20
- data/lib/sportdb/utils_group.rb +0 -63
- data/lib/sportdb/utils_map.rb +0 -44
- data/lib/sportdb/utils_round.rb +0 -165
- data/lib/sportdb/utils_scores.rb +0 -17
- data/lib/sportdb/utils_teams.rb +0 -43
- data/lib/sportdb/version.rb +0 -22
- data/test/data/at-austria/2013_14/bl.txt +0 -227
- data/test/data/at-austria/2013_14/bl.yml +0 -30
- data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
- data/test/data/at-austria/2013_14/el.txt +0 -4
- data/test/data/at-austria/2013_14/el.yml +0 -25
- data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
- data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
- data/test/data/at-austria/leagues.txt +0 -11
- data/test/data/at-austria/teams.txt +0 -75
- data/test/data/at-austria/teams_2.txt +0 -34
- data/test/data/national-teams/assocs.txt +0 -231
- data/test/data/national-teams/europe/assocs.txt +0 -13
- data/test/data/national-teams/europe/teams.txt +0 -13
- data/test/data/national-teams/north-america/assocs.txt +0 -10
- data/test/data/national-teams/north-america/teams.txt +0 -7
- data/test/data/national-teams/teams.txt +0 -19
- data/test/data/players/europe/at-austria/players.txt +0 -45
- data/test/data/players/europe/de-deutschland/players.txt +0 -41
- data/test/data/players/south-america/br-brazil/players.txt +0 -51
- data/test/data/world-cup/1930/cup.txt +0 -71
- data/test/data/world-cup/1930/cup.yml +0 -23
- data/test/data/world-cup/1930/cup_goals.txt +0 -47
- data/test/data/world-cup/1930/cup_goals.yml +0 -23
- data/test/data/world-cup/1954/cup.txt +0 -90
- data/test/data/world-cup/1954/cup.yml +0 -30
- data/test/data/world-cup/1962/cup.txt +0 -86
- data/test/data/world-cup/1962/cup.yml +0 -32
- data/test/data/world-cup/1974/cup.yml +0 -35
- data/test/data/world-cup/1974/cup_finals.txt +0 -14
- data/test/data/world-cup/1974/cup_i.txt +0 -55
- data/test/data/world-cup/1974/cup_ii.txt +0 -34
- data/test/data/world-cup/2014/cup.txt +0 -5
- data/test/data/world-cup/2014/cup.yml +0 -54
- data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
- data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
- data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
- data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
- data/test/data/world-cup/leagues.txt +0 -5
- data/test/data/world-cup/seasons_1930.txt +0 -4
- data/test/data/world-cup/seasons_1954.txt +0 -4
- data/test/data/world-cup/seasons_1962.txt +0 -4
- data/test/data/world-cup/seasons_1974.txt +0 -5
- data/test/data/world-cup/teams_1930.txt +0 -26
- data/test/data/world-cup/teams_1954.txt +0 -30
- data/test/data/world-cup/teams_1962.txt +0 -29
- data/test/data/world-cup/teams_1974.txt +0 -29
- data/test/helper.rb +0 -120
- data/test/test_assoc_reader.rb +0 -201
- data/test/test_changes.rb +0 -74
- data/test/test_cursor.rb +0 -50
- data/test/test_date.rb +0 -100
- data/test/test_goals.rb +0 -109
- data/test/test_lang.rb +0 -130
- data/test/test_load.rb +0 -61
- data/test/test_reader.rb +0 -88
- data/test/test_reader_from_string.rb +0 -65
- data/test/test_round_auto.rb +0 -370
- data/test/test_round_def.rb +0 -109
- data/test/test_round_header.rb +0 -183
- data/test/test_scores.rb +0 -70
- data/test/test_squad_club_reader.rb +0 -76
- data/test/test_squad_national_team_reader.rb +0 -116
- data/test/test_standings.rb +0 -279
- data/test/test_standings_ii.rb +0 -46
- data/test/test_utils.rb +0 -124
- data/test/test_winner.rb +0 -95
@@ -1,26 +0,0 @@
|
|
1
|
-
#############################
|
2
|
-
# 13 Teams
|
3
|
-
|
4
|
-
## -- South America
|
5
|
-
|
6
|
-
arg, Argentina, ARG, ar
|
7
|
-
bra, Brazil, BRA, br
|
8
|
-
bol, Bolivia, BOL, bo
|
9
|
-
chi, Chile, CHI, cl
|
10
|
-
uru, Uruguay, URU, uy
|
11
|
-
per, Peru, PER, pe
|
12
|
-
par, Paraguay, PAR, py
|
13
|
-
|
14
|
-
|
15
|
-
## -- North and Central America
|
16
|
-
|
17
|
-
mex, Mexico, MEX, mx
|
18
|
-
usa, United States, USA, us
|
19
|
-
|
20
|
-
## -- Europe
|
21
|
-
|
22
|
-
fra, France, FRA, fr
|
23
|
-
yug, Yugoslavia, YUG, rs
|
24
|
-
rou, Romania, ROU, ro
|
25
|
-
bel, Belgium, BEL, be
|
26
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
##########################
|
2
|
-
# 16 Teams
|
3
|
-
|
4
|
-
## -- Asia
|
5
|
-
|
6
|
-
kor, South Korea, KOR, kr
|
7
|
-
|
8
|
-
## -- Europe
|
9
|
-
|
10
|
-
aut, Austria, AUT, at
|
11
|
-
bel, Belgium, BEL, be
|
12
|
-
tch, Czechoslovakia, TCH, cz
|
13
|
-
eng, England, ENG, en
|
14
|
-
fra, France, FRA, fr
|
15
|
-
frg, West Germany, FRG, de
|
16
|
-
hun, Hungary, HUN, hu
|
17
|
-
ita, Italy, ITA, it
|
18
|
-
sco, Scotland, SCO, sc
|
19
|
-
sui, Switzerland, SUI, ch
|
20
|
-
tur, Turkey, TUR, tr
|
21
|
-
yug, Yugoslavia, YUG, rs
|
22
|
-
|
23
|
-
## -- North and Central America
|
24
|
-
|
25
|
-
mex, Mexico, MEX, mx
|
26
|
-
|
27
|
-
## -- South America
|
28
|
-
|
29
|
-
bra, Brazil, BRA, br
|
30
|
-
uru, Uruguay, URU, uy
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#############################
|
2
|
-
# 16 Teams
|
3
|
-
|
4
|
-
## -- South America
|
5
|
-
|
6
|
-
arg, Argentina, ARG, ar
|
7
|
-
bra, Brazil, BRA, br
|
8
|
-
chi, Chile, CHI, cl
|
9
|
-
col, Colombia, COL, co
|
10
|
-
uru, Uruguay, URU, uy
|
11
|
-
|
12
|
-
|
13
|
-
## -- North and Central America
|
14
|
-
|
15
|
-
mex, Mexico, MEX, mx
|
16
|
-
|
17
|
-
## -- Europe
|
18
|
-
|
19
|
-
bul, Bulgaria, BUL, bg
|
20
|
-
tch, Czechoslovakia, TCH, cz
|
21
|
-
eng, England, ENG, en
|
22
|
-
frg, West Germany, FRG, de
|
23
|
-
hun, Hungary, HUN, hu
|
24
|
-
ita, Italy, ITA, it
|
25
|
-
urs, Soviet Union, URS, ru
|
26
|
-
esp, Spain, ESP, es
|
27
|
-
sui, Switzerland, SUI, ch
|
28
|
-
yug, Yugoslavia, YUG, rs
|
29
|
-
|
@@ -1,29 +0,0 @@
|
|
1
|
-
########################
|
2
|
-
# 16 Teams
|
3
|
-
|
4
|
-
# -- Africa
|
5
|
-
zai, Zaire, ZAI, cd
|
6
|
-
|
7
|
-
# -- Asia
|
8
|
-
aus, Australia, AUS, au
|
9
|
-
|
10
|
-
# -- Europe
|
11
|
-
bul, Bulgaria, BUL, bg
|
12
|
-
frg, West Germany, FRG, de
|
13
|
-
gdr, East Germany, GDR, de
|
14
|
-
ita, Italy, ITA, it
|
15
|
-
ned, Netherlands, NED, nl
|
16
|
-
pol, Poland, POL, pl
|
17
|
-
sco, Scotland, SCO, sc
|
18
|
-
swe, Sweden, SWE, se
|
19
|
-
yug, Yugoslavia, YUG, rs
|
20
|
-
|
21
|
-
|
22
|
-
# -- North and Central America
|
23
|
-
hai, Haiti, HAI, ht
|
24
|
-
|
25
|
-
# -- South America
|
26
|
-
arg, Argentina, ARG, ar
|
27
|
-
bra, Brazil, BRA, br
|
28
|
-
chi, Chile, CHI, cl
|
29
|
-
uru, Uruguay, URU, uy
|
data/test/helper.rb
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
|
2
|
-
## $:.unshift(File.dirname(__FILE__))
|
3
|
-
|
4
|
-
## minitest setup
|
5
|
-
|
6
|
-
require 'minitest/autorun'
|
7
|
-
|
8
|
-
|
9
|
-
## our own code
|
10
|
-
|
11
|
-
require 'sportdb'
|
12
|
-
|
13
|
-
|
14
|
-
#####################
|
15
|
-
# Models shortcuts
|
16
|
-
|
17
|
-
Country = WorldDb::Model::Country
|
18
|
-
|
19
|
-
Person = PersonDb::Model::Person
|
20
|
-
|
21
|
-
League = SportDb::Model::League
|
22
|
-
Season = SportDb::Model::Season
|
23
|
-
Event = SportDb::Model::Event
|
24
|
-
Team = SportDb::Model::Team
|
25
|
-
Roster = SportDb::Model::Roster
|
26
|
-
Assoc = SportDb::Model::Assoc
|
27
|
-
AssocAssoc = SportDb::Model::AssocAssoc
|
28
|
-
|
29
|
-
Round = SportDb::Model::Round
|
30
|
-
Group = SportDb::Model::Group
|
31
|
-
Game = SportDb::Model::Game
|
32
|
-
GameCursor = SportDb::Model::GameCursor
|
33
|
-
|
34
|
-
|
35
|
-
EventStanding = SportDb::Model::EventStanding
|
36
|
-
EventStandingEntry = SportDb::Model::EventStandingEntry
|
37
|
-
GroupStanding = SportDb::Model::GroupStanding
|
38
|
-
GroupStandingEntry = SportDb::Model::GroupStandingEntry
|
39
|
-
AlltimeStanding = SportDb::Model::AlltimeStanding
|
40
|
-
AlltimeStandingEntry = SportDb::Model::AlltimeStandingEntry
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
####################
|
45
|
-
# Reader shortcuts
|
46
|
-
|
47
|
-
Reader = SportDb::Reader
|
48
|
-
TeamReader = SportDb::TeamReader
|
49
|
-
AssocReader = SportDb::AssocReader
|
50
|
-
SeasonReader = SportDb::SeasonReader
|
51
|
-
LeagueReader = SportDb::LeagueReader
|
52
|
-
EventReader = SportDb::EventReader
|
53
|
-
GameReader = SportDb::GameReader
|
54
|
-
NationalTeamSquadReader = SportDb::NationalTeamSquadReader
|
55
|
-
ClubSquadReader = SportDb::ClubSquadReader
|
56
|
-
|
57
|
-
## moved to racing.db - remove/delete!!
|
58
|
-
## RaceTeamReader = SportDb::RaceTeamReader
|
59
|
-
|
60
|
-
PersonReader = PersonDb::PersonReader
|
61
|
-
|
62
|
-
######
|
63
|
-
# New Reader ShortCuts
|
64
|
-
|
65
|
-
module TestTeamReader
|
66
|
-
def self.from_file( name, more_attribs={} )
|
67
|
-
TeamReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
module TestClubSquadReader
|
72
|
-
def self.from_file( name, more_attribs={} )
|
73
|
-
ClubSquadReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
module TestNationalTeamSquadReader
|
78
|
-
def self.from_file( name, more_attribs={} )
|
79
|
-
NationalTeamSquadReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
module TestLeagueReader
|
84
|
-
def self.from_file( name, more_attribs={} )
|
85
|
-
LeagueReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
module TestSeasonReader
|
90
|
-
def self.from_file( name )
|
91
|
-
SeasonReader.from_file( "#{SportDb.test_data_path}/#{name}.txt" )
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
module TestEventReader
|
96
|
-
def self.from_file( name )
|
97
|
-
EventReader.from_file( "#{SportDb.test_data_path}/#{name}.yml" )
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
module TestGameReader
|
102
|
-
## NOTE: pass in .yml as path (that is, event config!!!!)
|
103
|
-
def self.from_file( name, more_attribs={} )
|
104
|
-
GameReader.from_file( "#{SportDb.test_data_path}/#{name}.yml", more_attribs )
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
module TestAssocReader
|
109
|
-
def self.from_file( name )
|
110
|
-
AssocReader.from_file( "#{SportDb.test_data_path}/#{name}.txt" )
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
#################################
|
117
|
-
# setup db -> schema / tables
|
118
|
-
|
119
|
-
SportDb.setup_in_memory_db
|
120
|
-
|
data/test/test_assoc_reader.rb
DELETED
@@ -1,201 +0,0 @@
|
|
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 TestAssocReaderXX < MiniTest::Test # note: TestAssocReader alreay defined, thus, add xx
|
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 = TestAssocReader.from_file( 'national-teams/assocs' )
|
83
|
-
reader.read()
|
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 = TestAssocReader.from_file( 'national-teams/north-america/assocs' )
|
128
|
-
reader.read()
|
129
|
-
|
130
|
-
assert_equal 23, Assoc.count
|
131
|
-
|
132
|
-
assert_equal 6+3, fifa.all_assocs.count
|
133
|
-
assert_equal 6, fifa.sub_assocs.count
|
134
|
-
assert_equal 0+3, fifa.national_assocs.count
|
135
|
-
|
136
|
-
assert_equal 3+3, concacaf.all_assocs.count
|
137
|
-
assert_equal 3, concacaf.sub_assocs.count
|
138
|
-
assert_equal 0+3, concacaf.national_assocs.count
|
139
|
-
assert_equal 1, concacaf.parent_assocs.count
|
140
|
-
|
141
|
-
assocusa = Assoc.find_by_key!( 'assocusa' )
|
142
|
-
assert_equal 'United States Soccer Federation', assocusa.title
|
143
|
-
assert_equal 3, assocusa.parent_assocs.count
|
144
|
-
assert_equal 0, assocusa.all_assocs.count
|
145
|
-
assert_equal 0, assocusa.sub_assocs.count
|
146
|
-
assert_equal 0, assocusa.national_assocs.count
|
147
|
-
|
148
|
-
end # method test_assocs
|
149
|
-
|
150
|
-
|
151
|
-
def test_teams
|
152
|
-
assocreader = TestAssocReader.from_file( 'national-teams/assocs' )
|
153
|
-
assocreader.read()
|
154
|
-
|
155
|
-
assert_equal 20, Assoc.count
|
156
|
-
|
157
|
-
## add countries
|
158
|
-
countries = [['mx', 'Mexico', 'MEX'],
|
159
|
-
['us', 'United States', 'USA'],
|
160
|
-
['ca', 'Canada', 'CAN'],
|
161
|
-
['dz', 'Algeria', 'ALG'],
|
162
|
-
['eg', 'Egypt', 'EGY'],
|
163
|
-
['au', 'Australia', 'AUS'],
|
164
|
-
['nz', 'New Zealand', 'NZL'],
|
165
|
-
['ki', 'Kiribati', 'KIR'],
|
166
|
-
['tv', 'Tuvalu', 'TUV']]
|
167
|
-
|
168
|
-
countries.each do |country|
|
169
|
-
Country.create!( key: country[0],
|
170
|
-
name: country[1],
|
171
|
-
code: country[2],
|
172
|
-
pop: 1,
|
173
|
-
area: 1)
|
174
|
-
end
|
175
|
-
|
176
|
-
teamreader = TestTeamReader.from_file( 'national-teams/teams' )
|
177
|
-
teamreader.read()
|
178
|
-
teamreader = TestTeamReader.from_file( 'national-teams/north-america/teams' )
|
179
|
-
teamreader.read()
|
180
|
-
|
181
|
-
assert_equal 9, Team.count
|
182
|
-
|
183
|
-
## fifa = Assoc.find_by_key!( 'fifa' )
|
184
|
-
## assert_equal 7, fifa.teams.count
|
185
|
-
|
186
|
-
## ofc = Assoc.find_by_key!( 'ofc' )
|
187
|
-
## assert_equal 3, ofc.teams.count
|
188
|
-
|
189
|
-
## mex = Team.find_by_key!( 'mex' )
|
190
|
-
## assert_equal 3, mex.assocs.count
|
191
|
-
|
192
|
-
## tuv = Team.find_by_key!( 'tuv' )
|
193
|
-
## assert_equal 1, tuv.assocs.count
|
194
|
-
|
195
|
-
### fix/todo: run teamreader again!! (2nd run)
|
196
|
-
## assert no new assocs (just update existing)
|
197
|
-
|
198
|
-
end # method test_teams
|
199
|
-
|
200
|
-
|
201
|
-
end # class TestAssocReader
|