sportdb-models 1.18.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +27 -145
- data/Rakefile +4 -5
- data/lib/sportdb/models.rb +93 -160
- data/lib/sportdb/{deleter.rb → models/deleter.rb} +4 -10
- data/lib/sportdb/models/formats.rb +23 -0
- data/lib/sportdb/models/models/assoc.rb +38 -0
- data/lib/sportdb/models/{badge.rb → models/badge.rb} +1 -1
- data/lib/sportdb/models/models/event.rb +55 -0
- data/lib/sportdb/models/{forward.rb → models/forward.rb} +3 -3
- data/lib/sportdb/models/{goal.rb → models/goal.rb} +1 -1
- data/lib/sportdb/models/models/ground.rb +16 -0
- data/lib/sportdb/models/{group.rb → models/group.rb} +10 -7
- data/lib/sportdb/models/models/league.rb +20 -0
- data/lib/sportdb/models/{roster.rb → models/lineup.rb} +3 -4
- data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
- data/lib/sportdb/models/{person.rb → models/person.rb} +0 -0
- data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
- data/lib/sportdb/models/{season.rb → models/season.rb} +2 -1
- data/lib/sportdb/models/{stage.rb → models/stage.rb} +9 -5
- data/lib/sportdb/models/{stats/alltime_standing_entry.rb → models/stats/alltime_standing.rb} +9 -1
- data/lib/sportdb/models/{stats/event_standing_entry.rb → models/stats/event_standing.rb} +11 -1
- data/lib/sportdb/models/{stats/group_standing_entry.rb → models/stats/group_standing.rb} +10 -1
- data/lib/sportdb/models/models/team.rb +56 -0
- data/lib/sportdb/models/{world → models/world}/city.rb +2 -2
- data/lib/sportdb/models/{world → models/world}/continent.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/state.rb +0 -0
- data/lib/sportdb/{schema.rb → models/schema.rb} +165 -100
- data/lib/sportdb/models/stats.rb +23 -0
- data/lib/sportdb/models/utils.rb +24 -24
- data/lib/sportdb/{version.rb → models/version.rb} +12 -5
- data/test/helper.rb +10 -114
- data/test/test_changes.rb +38 -38
- data/test/test_cursor.rb +15 -15
- data/test/test_winner.rb +75 -70
- metadata +29 -161
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/indexers/team.rb +0 -87
- data/lib/sportdb/mapper_teams.rb +0 -24
- 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/event.rb +0 -66
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/stage_team.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_compat.rb +0 -64
- data/lib/sportdb/patterns.rb +0 -37
- data/lib/sportdb/pretty_printer.rb +0 -175
- data/lib/sportdb/reader.rb +0 -132
- data/lib/sportdb/reader_file.rb +0 -131
- data/lib/sportdb/reader_zip.rb +0 -172
- data/lib/sportdb/readers/assoc.rb +0 -54
- data/lib/sportdb/readers/event.rb +0 -253
- data/lib/sportdb/readers/event_meta.rb +0 -133
- data/lib/sportdb/readers/event_table.rb +0 -196
- data/lib/sportdb/readers/game.rb +0 -912
- 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/rsssf_reader.rb +0 -367
- 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 -48
- 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/2014_15/1-bundesliga-ii.txt +0 -158
- data/test/data/at-austria/2014_15/1-bundesliga.yml +0 -18
- data/test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga-v2.yml +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.yml +0 -24
- data/test/data/at-austria/2015_16/cup.yml +0 -77
- data/test/data/at-austria/leagues.txt +0 -11
- data/test/data/at-austria/teams.txt +0 -68
- data/test/data/at-austria/teams_2.txt +0 -21
- data/test/data/csv/de-2013-14--1-bundesliga.txt +0 -307
- data/test/data/de-deutschland/2013-14/1-bundesliga.yml +0 -26
- data/test/data/de-deutschland/leagues.txt +0 -4
- data/test/data/de-deutschland/teams.txt +0 -53
- data/test/data/eng-england/2015-16/1-premierleague-v2.yml +0 -2
- data/test/data/eng-england/2015-16/1-premierleague.yml +0 -5
- 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/rsssf/at-2014-15--1-bundesliga.txt +0 -339
- data/test/data/rsssf/at-2015-16--1-bundesliga.txt +0 -18
- 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/test_assoc_reader.rb +0 -199
- data/test/test_event_meta_reader.rb +0 -47
- data/test/test_event_reader.rb +0 -64
- data/test/test_event_table_reader.rb +0 -57
- data/test/test_goals.rb +0 -107
- data/test/test_indexer_team.rb +0 -34
- data/test/test_load.rb +0 -61
- data/test/test_pp.rb +0 -35
- data/test/test_reader.rb +0 -88
- data/test/test_reader_from_string.rb +0 -63
- 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_rsssf_reader.rb +0 -76
- 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
@@ -1,54 +0,0 @@
|
|
1
|
-
##################################
|
2
|
-
# World Cup 2014 Brazil
|
3
|
-
|
4
|
-
league: world
|
5
|
-
season: 2014
|
6
|
-
start_at: 2014-06-12
|
7
|
-
|
8
|
-
|
9
|
-
######
|
10
|
-
# 32 Teams
|
11
|
-
#
|
12
|
-
# Europe (UEFA): 13 places
|
13
|
-
# Africa (CAF): 5 places
|
14
|
-
# Asia (AFC): 4 places
|
15
|
-
# South America (CONMEBOL) 5 places (+ Brazil qualified automatically as host nation for a total of 5 or 6 places)
|
16
|
-
# North, Central American and Caribbean (CONCACAF): 4 places
|
17
|
-
# Oceania (OFC): 0
|
18
|
-
#
|
19
|
-
# see en.wikipedia.org/wiki/2014_FIFA_World_Cup_qualification
|
20
|
-
|
21
|
-
# teams:
|
22
|
-
#- nga # Nigeria -- Africa (5)
|
23
|
-
#- civ # Côte d'Ivoire
|
24
|
-
#- cmr # Cameroon
|
25
|
-
#- gha # Ghana
|
26
|
-
#- alg # Algeria
|
27
|
-
#- aus # Australia -- Asia (4) includes Australia
|
28
|
-
#- irn # Iran
|
29
|
-
#- jpn # Japan
|
30
|
-
#- kor # South Korea
|
31
|
-
#- crc # Costa Rica -- North, Central American and Caribbean (4)
|
32
|
-
#- usa # United States
|
33
|
-
#- hon # Honduras
|
34
|
-
#- mex # Mexico
|
35
|
-
#- bra # Brazil -- South America (5+1)
|
36
|
-
#- arg # Argentina
|
37
|
-
#- col # Colombia
|
38
|
-
#- chi # Chile
|
39
|
-
#- ecu # Ecuador
|
40
|
-
#- uru # Uruguay
|
41
|
-
#- bel # Belgium -- Europe (13)
|
42
|
-
#- ger # Germany
|
43
|
-
#- ita # Italy
|
44
|
-
#- ned # Netherlands
|
45
|
-
#- sui # Switzerland
|
46
|
-
#- bih # Bosnia and Herzegovina
|
47
|
-
#- rus # Russia
|
48
|
-
#- esp # Spain
|
49
|
-
#- eng # England
|
50
|
-
#- gre # Greece
|
51
|
-
#- cro # Croatia
|
52
|
-
#- por # Portugal
|
53
|
-
#- fra # France
|
54
|
-
|
@@ -1,46 +0,0 @@
|
|
1
|
-
##############################
|
2
|
-
# Brazil - World Cup 2014
|
3
|
-
#
|
4
|
-
# Coaching Staff
|
5
|
-
# - Head Coach: Luiz Felipe Scolari
|
6
|
-
|
7
|
-
|
8
|
-
####################
|
9
|
-
# GK / Goal Keepers
|
10
|
-
|
11
|
-
Jefferson ## Botafogo
|
12
|
-
Julio César ## Toronto F.C
|
13
|
-
Victor ## Atlético-MG
|
14
|
-
|
15
|
-
####################
|
16
|
-
# DF / Defenders
|
17
|
-
|
18
|
-
Dante (Bayern de Munique)
|
19
|
-
David Luiz (Chelsea)
|
20
|
-
Henrique (Napoli)
|
21
|
-
Thiago Silva (Paris Saint-Germain)
|
22
|
-
Daniel Alves (Barcelona)
|
23
|
-
Maicon (Roma)
|
24
|
-
Marcelo (Real Madrid)
|
25
|
-
Maxwell (PSG)
|
26
|
-
|
27
|
-
####################
|
28
|
-
# MF / Midfielders
|
29
|
-
|
30
|
-
Fernandinho (Manchester City)
|
31
|
-
Hernanes (Inter de Milão)
|
32
|
-
Luiz Gustavo (Wolfsburg)
|
33
|
-
Oscar (Chelsea)
|
34
|
-
Paulinho (Tottenham)
|
35
|
-
Ramires (Chelsea)
|
36
|
-
Willian (Chelsea)
|
37
|
-
|
38
|
-
####################
|
39
|
-
# FW / Forwards
|
40
|
-
|
41
|
-
Bernard (Shakhtar)
|
42
|
-
Fred (Fluminense)
|
43
|
-
Hulk (Zenit)
|
44
|
-
Jô (Atlético-MG)
|
45
|
-
Neymar (Barcelona)
|
46
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
#######
|
2
|
-
# note: players NOT in players database; will get auto-created for testing
|
3
|
-
#
|
4
|
-
|
5
|
-
(1) GK Eiji Kawashima ## 56, Standard Liège (BEL)
|
6
|
-
(12) GK Shusaku Nishikawa ## 12, Urawa Red Diamonds (JPN)
|
7
|
-
(23) GK Shūichi Gonda ## 2, F.C. Tokyo (JPN)
|
8
|
-
|
9
|
-
(2) DF Atsuto Uchida ## 67, Schalke 04 (GER)
|
10
|
-
(3) DF Gōtoku Sakai ## 12, VfB Stuttgart (GER)
|
11
|
-
(5) DF Yuto Nagatomo ## 69, Internazionale (ITA)
|
12
|
-
(6) DF Masato Morishige ## 9, F.C. Tokyo (JPN)
|
13
|
-
(15) DF Yasuyuki Konno ## 80, Gamba Osaka (JPN)
|
14
|
-
(19) DF Masahiko Inoha ## 21, Jubilo Iwata (JPN)
|
15
|
-
(21) DF Hiroki Sakai ## 17, Hannover 96 (GER)
|
16
|
-
(22) DF Maya Yoshida ## 40, Southampton (ENG)
|
17
|
-
|
18
|
-
(4) MF Keisuke Honda ## 55, Milan (ITA)
|
19
|
-
(7) MF Yasuhito Endō ## 143, Gamba Osaka (JPN)
|
20
|
-
(8) MF Hiroshi Kiyotake ## 25, 1. FC Nürnberg (GER)
|
21
|
-
(10) MF Shinji Kagawa ## 56, Manchester United (ENG)
|
22
|
-
(14) MF Toshihiro Aoyama ## 5, Sanfrecce Hiroshima (JPN)
|
23
|
-
(16) MF Hotaru Yamaguchi ## 11, Cerezo Osaka (JPN)
|
24
|
-
(17) MF Makoto Hasebe ## 78, 1. FC Nürnberg (GER)
|
25
|
-
|
26
|
-
(9) FW Shinji Okazaki ## 75, Mainz 05 (GER)
|
27
|
-
(11) FW Yoichiro Kakitani ## 11, Cerezo Osaka (JPN)
|
28
|
-
(13) FW Yoshito Ōkubo ## 56, Kawasaki Frontale (JPN)
|
29
|
-
(18) FW Yuya Osako ## 8, 1860 München (GER)
|
30
|
-
(20) FW Manabu Saitō ## 4, Yokohama F. Marinos (JPN)
|
@@ -1,32 +0,0 @@
|
|
1
|
-
#######
|
2
|
-
# note: try without (w/o) jersey number e.g. use - instead of (1) (12) etc.
|
3
|
-
# - players NOT in players database; will get auto-created for testing
|
4
|
-
|
5
|
-
|
6
|
-
- GK Fernando Muslera ## 57, Galatasaray (TUR)
|
7
|
-
- GK Rodrigo Muñoz ## 0, Libertad (PAR)
|
8
|
-
- GK Martín Silva ## 4, Vasco da Gama (BRA)
|
9
|
-
|
10
|
-
- DF Diego Lugano ## 93, West Bromwich Albion (ENG)
|
11
|
-
- DF Diego Godín ## 76, Atlético Madrid (ESP)
|
12
|
-
- DF Sebastián Coates ## 14, Nacional (URU)
|
13
|
-
- DF Jorge Fucile ## 41, Porto (POR)
|
14
|
-
- DF Maxi Pereira ## 89, Benfica (POR)
|
15
|
-
- DF José María Giménez ## 5, Atlético Madrid (ESP)
|
16
|
-
- DF Martín Cáceres ## 56, Juventus (ITA)
|
17
|
-
|
18
|
-
- MF Walter Gargano ## 62, Parma (ITA)
|
19
|
-
- MF Álvaro Pereira ## 56, São Paulo (BRA)
|
20
|
-
- MF Cristian Rodríguez ## 72, Atlético Madrid (ESP)
|
21
|
-
- MF Nicolás Lodeiro ## 26, Botafogo (BRA)
|
22
|
-
- MF Diego Pérez ## 89, Bologna (ITA)
|
23
|
-
- MF Egidio Arévalo Ríos ## 54, Morelia (MEX)
|
24
|
-
- MF Gastón Ramírez ## 28, Southampton (ENG)
|
25
|
-
- MF Álvaro González ## 42, Lazio (ITA)
|
26
|
-
|
27
|
-
- FW Abel Hernández ## 12, Palermo (ITA)
|
28
|
-
- FW Luis Suárez ## 77, Liverpool (ENG)
|
29
|
-
- FW Diego Forlán ## 109, Cerezo Osaka (JPN)
|
30
|
-
- FW Christian Stuani ## 9, Espanyol (ESP)
|
31
|
-
- FW Edinson Cavani ## 61, Paris Saint-Germain (FRA)
|
32
|
-
|
@@ -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/test_assoc_reader.rb
DELETED
@@ -1,199 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_assoc_reader.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestAssocReaderXX < MiniTest::Test # note: TestAssocReader alreay defined, thus, add xx
|
11
|
-
|
12
|
-
def setup
|
13
|
-
WorldDb.delete!
|
14
|
-
SportDb.delete!
|
15
|
-
PersonDb.delete!
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_models
|
19
|
-
assert_equal 0, Assoc.count
|
20
|
-
assert_equal 0, Team.count
|
21
|
-
assert_equal 0, AssocAssoc.count
|
22
|
-
|
23
|
-
uefa = Assoc.create!( key: 'uefa', title: 'UEFA' )
|
24
|
-
assert_equal 1, Assoc.count
|
25
|
-
|
26
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
27
|
-
assocaut = Assoc.create!( key: 'assocaut', title: 'Assoc Austria',
|
28
|
-
national: true, country_id: at.id )
|
29
|
-
|
30
|
-
aut = Team.create!( key: 'aut', title: 'Austria', code: 'AUT',
|
31
|
-
country_id: at.id,
|
32
|
-
assoc_id: assocaut.id )
|
33
|
-
|
34
|
-
assert_equal 1, Team.count
|
35
|
-
assert_equal 'Assoc Austria', aut.assoc.title # team.assoc belongs_to ref
|
36
|
-
assert_equal 'Assoc Austria', at.assoc.title # country.assoc has_one ref
|
37
|
-
|
38
|
-
assert_equal 0, AssocAssoc.count
|
39
|
-
|
40
|
-
AssocAssoc.create!( assoc1_id: uefa.id, assoc2_id: assocaut.id )
|
41
|
-
|
42
|
-
assert_equal 1, AssocAssoc.count
|
43
|
-
assert_equal 1, uefa.member_assoc_assocs.count
|
44
|
-
assert_equal 1, uefa.all_assocs.count
|
45
|
-
assert_equal 0, uefa.sub_assocs.count
|
46
|
-
assert_equal 1, uefa.national_assocs.count
|
47
|
-
assert_equal 0, uefa.parent_assoc_assocs.count
|
48
|
-
assert_equal 0, uefa.parent_assocs.count
|
49
|
-
assert_equal 1, assocaut.parent_assoc_assocs.count
|
50
|
-
assert_equal 1, assocaut.parent_assocs.count
|
51
|
-
assert_equal 0, assocaut.member_assoc_assocs.count
|
52
|
-
assert_equal 0, assocaut.all_assocs.count
|
53
|
-
|
54
|
-
|
55
|
-
it = Country.create!( key: 'it', name: 'Italy', code: 'ITA', pop: 1, area: 1)
|
56
|
-
associta = Assoc.create!( key: 'associta', title: 'Assoc Italy',
|
57
|
-
national: true, country_id: it.id )
|
58
|
-
|
59
|
-
ita = Team.create!( key: 'ita', title: 'Italy', code: 'ITA',
|
60
|
-
country_id: it.id,
|
61
|
-
assoc_id: associta.id )
|
62
|
-
|
63
|
-
assert_equal 2, Team.count
|
64
|
-
assert_equal 'Assoc Italy', ita.assoc.title # team.assoc belongs_to ref
|
65
|
-
assert_equal 'Assoc Italy', it.assoc.title # country.assoc has_one ref
|
66
|
-
|
67
|
-
AssocAssoc.create!( assoc1_id: uefa.id, assoc2_id: associta.id )
|
68
|
-
|
69
|
-
assert_equal 2, AssocAssoc.count
|
70
|
-
assert_equal 2, uefa.member_assoc_assocs.count
|
71
|
-
assert_equal 2, uefa.national_assocs.count
|
72
|
-
assert_equal 0, uefa.sub_assocs.count
|
73
|
-
assert_equal 0, uefa.parent_assoc_assocs.count
|
74
|
-
assert_equal 1, associta.parent_assoc_assocs.count
|
75
|
-
assert_equal 0, associta.member_assoc_assocs.count
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
def test_assocs
|
80
|
-
reader = TestAssocReader.from_file( 'national-teams/assocs' )
|
81
|
-
reader.read()
|
82
|
-
|
83
|
-
assert_equal 20, Assoc.count
|
84
|
-
|
85
|
-
fifa = Assoc.find_by_key!( 'fifa' )
|
86
|
-
|
87
|
-
assert_equal 'Fédération Internationale de Football Association (FIFA)', fifa.title
|
88
|
-
assert_equal 1904, fifa.since
|
89
|
-
assert_equal 'www.fifa.com', fifa.web
|
90
|
-
assert_equal 0, fifa.parent_assoc_assocs.count
|
91
|
-
assert_equal 6, fifa.member_assoc_assocs.count
|
92
|
-
assert_equal 6, fifa.all_assocs.count
|
93
|
-
assert_equal 6, fifa.sub_assocs.count
|
94
|
-
assert_equal 0, fifa.national_assocs.count
|
95
|
-
assert_equal 0, fifa.parent_assocs.count
|
96
|
-
|
97
|
-
uefa = Assoc.find_by_key!( 'uefa' )
|
98
|
-
|
99
|
-
assert_equal 'Union of European Football Associations (UEFA)', uefa.title
|
100
|
-
assert_equal 1954, uefa.since
|
101
|
-
assert_equal 'www.uefa.com', uefa.web
|
102
|
-
assert_equal 1, uefa.parent_assoc_assocs.count
|
103
|
-
assert_equal 0, uefa.member_assoc_assocs.count
|
104
|
-
assert_equal 0, uefa.all_assocs.count
|
105
|
-
assert_equal 0, uefa.sub_assocs.count
|
106
|
-
assert_equal 0, uefa.national_assocs.count
|
107
|
-
assert_equal 1, uefa.parent_assocs.count
|
108
|
-
|
109
|
-
concacaf = Assoc.find_by_key!( 'concacaf' )
|
110
|
-
|
111
|
-
assert_equal 'Confederation of North, Central American and Caribbean Association Football (CONCACAF)', concacaf.title
|
112
|
-
assert_equal 1961, concacaf.since
|
113
|
-
assert_equal 1, concacaf.parent_assoc_assocs.count
|
114
|
-
assert_equal 3, concacaf.member_assoc_assocs.count
|
115
|
-
assert_equal 3, concacaf.all_assocs.count
|
116
|
-
assert_equal 3, concacaf.sub_assocs.count
|
117
|
-
assert_equal 0, concacaf.national_assocs.count
|
118
|
-
assert_equal 1, concacaf.parent_assocs.count
|
119
|
-
|
120
|
-
|
121
|
-
mx = Country.create!( key: 'mx', name: 'Mexico', code: 'MEX', pop: 1, area: 1)
|
122
|
-
ca = Country.create!( key: 'ca', name: 'Canada', code: 'CAN', pop: 1, area: 1)
|
123
|
-
us = Country.create!( key: 'us', name: 'United States', code: 'USA', pop: 1, area: 1)
|
124
|
-
|
125
|
-
reader = TestAssocReader.from_file( 'national-teams/north-america/assocs' )
|
126
|
-
reader.read()
|
127
|
-
|
128
|
-
assert_equal 23, Assoc.count
|
129
|
-
|
130
|
-
assert_equal 6+3, fifa.all_assocs.count
|
131
|
-
assert_equal 6, fifa.sub_assocs.count
|
132
|
-
assert_equal 0+3, fifa.national_assocs.count
|
133
|
-
|
134
|
-
assert_equal 3+3, concacaf.all_assocs.count
|
135
|
-
assert_equal 3, concacaf.sub_assocs.count
|
136
|
-
assert_equal 0+3, concacaf.national_assocs.count
|
137
|
-
assert_equal 1, concacaf.parent_assocs.count
|
138
|
-
|
139
|
-
assocusa = Assoc.find_by_key!( 'assocusa' )
|
140
|
-
assert_equal 'United States Soccer Federation', assocusa.title
|
141
|
-
assert_equal 3, assocusa.parent_assocs.count
|
142
|
-
assert_equal 0, assocusa.all_assocs.count
|
143
|
-
assert_equal 0, assocusa.sub_assocs.count
|
144
|
-
assert_equal 0, assocusa.national_assocs.count
|
145
|
-
|
146
|
-
end # method test_assocs
|
147
|
-
|
148
|
-
|
149
|
-
def test_teams
|
150
|
-
assocreader = TestAssocReader.from_file( 'national-teams/assocs' )
|
151
|
-
assocreader.read()
|
152
|
-
|
153
|
-
assert_equal 20, Assoc.count
|
154
|
-
|
155
|
-
## add countries
|
156
|
-
countries = [['mx', 'Mexico', 'MEX'],
|
157
|
-
['us', 'United States', 'USA'],
|
158
|
-
['ca', 'Canada', 'CAN'],
|
159
|
-
['dz', 'Algeria', 'ALG'],
|
160
|
-
['eg', 'Egypt', 'EGY'],
|
161
|
-
['au', 'Australia', 'AUS'],
|
162
|
-
['nz', 'New Zealand', 'NZL'],
|
163
|
-
['ki', 'Kiribati', 'KIR'],
|
164
|
-
['tv', 'Tuvalu', 'TUV']]
|
165
|
-
|
166
|
-
countries.each do |country|
|
167
|
-
Country.create!( key: country[0],
|
168
|
-
name: country[1],
|
169
|
-
code: country[2],
|
170
|
-
pop: 1,
|
171
|
-
area: 1)
|
172
|
-
end
|
173
|
-
|
174
|
-
teamreader = TestTeamReader.from_file( 'national-teams/teams' )
|
175
|
-
teamreader.read()
|
176
|
-
teamreader = TestTeamReader.from_file( 'national-teams/north-america/teams' )
|
177
|
-
teamreader.read()
|
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
|