sportdb 1.9.16 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +2 -19
  3. data/Manifest.txt +1 -137
  4. data/README.md +2 -21
  5. data/Rakefile +14 -25
  6. data/lib/sportdb.rb +9 -260
  7. data/lib/sportdb/cli/main.rb +5 -14
  8. data/lib/sportdb/cli/opts.rb +2 -0
  9. data/lib/sportdb/cli/version.rb +26 -0
  10. metadata +10 -278
  11. data/.gemtest +0 -0
  12. data/config/fixtures/de.yml +0 -46
  13. data/config/fixtures/en.yml +0 -54
  14. data/config/fixtures/es.yml +0 -48
  15. data/config/fixtures/fr.yml +0 -53
  16. data/config/fixtures/it.yml +0 -55
  17. data/config/fixtures/pt.yml +0 -46
  18. data/config/fixtures/ro.yml +0 -55
  19. data/data/seasons.txt +0 -74
  20. data/data/setups/all.txt +0 -5
  21. data/lib/sportdb/calc.rb +0 -279
  22. data/lib/sportdb/deleter.rb +0 -52
  23. data/lib/sportdb/finders/date.rb +0 -374
  24. data/lib/sportdb/finders/goals.rb +0 -260
  25. data/lib/sportdb/finders/scores.rb +0 -122
  26. data/lib/sportdb/lang.rb +0 -216
  27. data/lib/sportdb/matcher.rb +0 -31
  28. data/lib/sportdb/models/assoc.rb +0 -106
  29. data/lib/sportdb/models/assoc_assoc.rb +0 -15
  30. data/lib/sportdb/models/badge.rb +0 -14
  31. data/lib/sportdb/models/event.rb +0 -65
  32. data/lib/sportdb/models/event_ground.rb +0 -15
  33. data/lib/sportdb/models/event_team.rb +0 -16
  34. data/lib/sportdb/models/forward.rb +0 -55
  35. data/lib/sportdb/models/game.rb +0 -244
  36. data/lib/sportdb/models/goal.rb +0 -15
  37. data/lib/sportdb/models/ground.rb +0 -100
  38. data/lib/sportdb/models/group.rb +0 -23
  39. data/lib/sportdb/models/group_team.rb +0 -14
  40. data/lib/sportdb/models/league.rb +0 -83
  41. data/lib/sportdb/models/person.rb +0 -21
  42. data/lib/sportdb/models/roster.rb +0 -18
  43. data/lib/sportdb/models/round.rb +0 -22
  44. data/lib/sportdb/models/season.rb +0 -14
  45. data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
  46. data/lib/sportdb/models/stats/alltime_standing_entry.rb +0 -23
  47. data/lib/sportdb/models/stats/event_standing.rb +0 -55
  48. data/lib/sportdb/models/stats/event_standing_entry.rb +0 -21
  49. data/lib/sportdb/models/stats/group_standing.rb +0 -50
  50. data/lib/sportdb/models/stats/group_standing_entry.rb +0 -22
  51. data/lib/sportdb/models/team.rb +0 -119
  52. data/lib/sportdb/models/team_comp.rb +0 -64
  53. data/lib/sportdb/models/utils.rb +0 -78
  54. data/lib/sportdb/models/world/city.rb +0 -21
  55. data/lib/sportdb/models/world/continent.rb +0 -20
  56. data/lib/sportdb/models/world/country.rb +0 -19
  57. data/lib/sportdb/models/world/region.rb +0 -19
  58. data/lib/sportdb/patterns.rb +0 -38
  59. data/lib/sportdb/reader.rb +0 -130
  60. data/lib/sportdb/reader_file.rb +0 -123
  61. data/lib/sportdb/reader_zip.rb +0 -165
  62. data/lib/sportdb/readers/assoc.rb +0 -54
  63. data/lib/sportdb/readers/event.rb +0 -200
  64. data/lib/sportdb/readers/game.rb +0 -877
  65. data/lib/sportdb/readers/ground.rb +0 -53
  66. data/lib/sportdb/readers/league.rb +0 -54
  67. data/lib/sportdb/readers/season.rb +0 -83
  68. data/lib/sportdb/readers/squad_club.rb +0 -201
  69. data/lib/sportdb/readers/squad_national_team.rb +0 -173
  70. data/lib/sportdb/readers/team.rb +0 -53
  71. data/lib/sportdb/schema.rb +0 -373
  72. data/lib/sportdb/standings.rb +0 -178
  73. data/lib/sportdb/stats.rb +0 -27
  74. data/lib/sportdb/utils.rb +0 -89
  75. data/lib/sportdb/utils_date.rb +0 -26
  76. data/lib/sportdb/utils_goals.rb +0 -20
  77. data/lib/sportdb/utils_group.rb +0 -63
  78. data/lib/sportdb/utils_map.rb +0 -44
  79. data/lib/sportdb/utils_round.rb +0 -165
  80. data/lib/sportdb/utils_scores.rb +0 -17
  81. data/lib/sportdb/utils_teams.rb +0 -43
  82. data/lib/sportdb/version.rb +0 -22
  83. data/test/data/at-austria/2013_14/bl.txt +0 -227
  84. data/test/data/at-austria/2013_14/bl.yml +0 -30
  85. data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
  86. data/test/data/at-austria/2013_14/el.txt +0 -4
  87. data/test/data/at-austria/2013_14/el.yml +0 -25
  88. data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
  89. data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
  90. data/test/data/at-austria/leagues.txt +0 -11
  91. data/test/data/at-austria/teams.txt +0 -75
  92. data/test/data/at-austria/teams_2.txt +0 -34
  93. data/test/data/national-teams/assocs.txt +0 -231
  94. data/test/data/national-teams/europe/assocs.txt +0 -13
  95. data/test/data/national-teams/europe/teams.txt +0 -13
  96. data/test/data/national-teams/north-america/assocs.txt +0 -10
  97. data/test/data/national-teams/north-america/teams.txt +0 -7
  98. data/test/data/national-teams/teams.txt +0 -19
  99. data/test/data/players/europe/at-austria/players.txt +0 -45
  100. data/test/data/players/europe/de-deutschland/players.txt +0 -41
  101. data/test/data/players/south-america/br-brazil/players.txt +0 -51
  102. data/test/data/world-cup/1930/cup.txt +0 -71
  103. data/test/data/world-cup/1930/cup.yml +0 -23
  104. data/test/data/world-cup/1930/cup_goals.txt +0 -47
  105. data/test/data/world-cup/1930/cup_goals.yml +0 -23
  106. data/test/data/world-cup/1954/cup.txt +0 -90
  107. data/test/data/world-cup/1954/cup.yml +0 -30
  108. data/test/data/world-cup/1962/cup.txt +0 -86
  109. data/test/data/world-cup/1962/cup.yml +0 -32
  110. data/test/data/world-cup/1974/cup.yml +0 -35
  111. data/test/data/world-cup/1974/cup_finals.txt +0 -14
  112. data/test/data/world-cup/1974/cup_i.txt +0 -55
  113. data/test/data/world-cup/1974/cup_ii.txt +0 -34
  114. data/test/data/world-cup/2014/cup.txt +0 -5
  115. data/test/data/world-cup/2014/cup.yml +0 -54
  116. data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
  117. data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
  118. data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
  119. data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
  120. data/test/data/world-cup/leagues.txt +0 -5
  121. data/test/data/world-cup/seasons_1930.txt +0 -4
  122. data/test/data/world-cup/seasons_1954.txt +0 -4
  123. data/test/data/world-cup/seasons_1962.txt +0 -4
  124. data/test/data/world-cup/seasons_1974.txt +0 -5
  125. data/test/data/world-cup/teams_1930.txt +0 -26
  126. data/test/data/world-cup/teams_1954.txt +0 -30
  127. data/test/data/world-cup/teams_1962.txt +0 -29
  128. data/test/data/world-cup/teams_1974.txt +0 -29
  129. data/test/helper.rb +0 -120
  130. data/test/test_assoc_reader.rb +0 -201
  131. data/test/test_changes.rb +0 -74
  132. data/test/test_cursor.rb +0 -50
  133. data/test/test_date.rb +0 -100
  134. data/test/test_goals.rb +0 -109
  135. data/test/test_lang.rb +0 -130
  136. data/test/test_load.rb +0 -61
  137. data/test/test_reader.rb +0 -88
  138. data/test/test_reader_from_string.rb +0 -65
  139. data/test/test_round_auto.rb +0 -370
  140. data/test/test_round_def.rb +0 -109
  141. data/test/test_round_header.rb +0 -183
  142. data/test/test_scores.rb +0 -70
  143. data/test/test_squad_club_reader.rb +0 -76
  144. data/test/test_squad_national_team_reader.rb +0 -116
  145. data/test/test_standings.rb +0 -279
  146. data/test/test_standings_ii.rb +0 -46
  147. data/test/test_utils.rb +0 -124
  148. data/test/test_winner.rb +0 -95
@@ -1,61 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_load.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
-
10
- require 'helper'
11
-
12
- class TestLoad < MiniTest::Test
13
-
14
- def setup
15
- WorldDb.delete!
16
- SportDb.delete!
17
- PersonDb.delete!
18
- SportDb.read_builtin # add 2014 season
19
- end
20
-
21
-
22
- def test_br
23
- br = Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 1, area: 1)
24
- bra = Team.create!( key: 'bra', title: 'Brazil', code: 'BRA', country_id: br.id )
25
-
26
- reader = Reader.new( SportDb.test_data_path )
27
-
28
- ## fix: add to country_matcher - allow players/br-brazil.txt e.g. country encode in file
29
- ## reader.load( 'players/south-america/br-brazil/players' )
30
- ## assert_equal 30, Person.count
31
-
32
- reader.load( 'world-cup/leagues' )
33
- assert_equal 1, League.count
34
- reader.load( 'world-cup/2014/cup' )
35
- assert_equal 1, Event.count
36
-
37
- reader.load( 'world-cup/2014/squads/br-brazil' )
38
- assert_equal 23, Roster.count
39
- end # method test_br
40
-
41
-
42
- def test_de
43
- de = Country.create!( key: 'de', title: 'Germany', code: 'GER', pop: 1, area: 1)
44
- ger = Team.create!( key: 'ger', title: 'Germany', code: 'GER', country_id: de.id )
45
-
46
- reader = Reader.new( SportDb.test_data_path )
47
-
48
- ## reader.load( 'players/europe/de-deutschland/players' )
49
- ## assert_equal 27, Person.count
50
-
51
- reader.load( 'world-cup/leagues' )
52
- assert_equal 1, League.count
53
- reader.load( 'world-cup/2014/cup' )
54
- assert_equal 1, Event.count
55
-
56
- reader.load( 'world-cup/2014/squads/de-deutschland' )
57
- assert_equal 3, Roster.count
58
- end # method test_de
59
-
60
-
61
- end # class TestLoad
@@ -1,88 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_reader.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
-
10
- require 'helper'
11
-
12
- class TestReader < MiniTest::Test
13
-
14
- def setup
15
- WorldDb.delete!
16
- SportDb.delete!
17
- SportDb.read_builtin
18
- end
19
-
20
- def test_bl
21
- at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
22
-
23
- teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
24
- teamreader.read()
25
-
26
- leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
27
- leaguereader.read()
28
-
29
- ## check/fix: is country_id more_attribs needed? why? why not?
30
- gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
31
- gamereader.read()
32
-
33
- bl = Event.find_by_key!( 'at.2013/14' )
34
-
35
- assert_equal 10, bl.teams.count
36
- assert_equal 36, bl.rounds.count
37
- assert_equal 180, bl.games.count # 36x5 = 180
38
- end
39
-
40
-
41
- def test_game_reader
42
- at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
43
-
44
- teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
45
- teamreader.read()
46
- teamreader = TestTeamReader.from_file( 'at-austria/teams_2', country_id: at.id )
47
- teamreader.read()
48
-
49
- austria = Team.find_by_key!( 'austria' )
50
- rapid = Team.find_by_key!( 'rapid' )
51
- sturm = Team.find_by_key!( 'sturm' )
52
-
53
- assert_equal 'FK Austria Wien', austria.title
54
- assert_equal 'SK Rapid Wien', rapid.title
55
- assert_equal 'SK Sturm Graz', sturm.title
56
-
57
- assert_equal 'AUS', austria.code
58
- assert_equal 'RAP', rapid.code
59
- assert_equal 'STU', sturm.code
60
-
61
- leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
62
- leaguereader.read()
63
-
64
- at1 = League.find_by_key!( 'at' )
65
- at2 = League.find_by_key!( 'at.2' )
66
- atcup = League.find_by_key!( 'at.cup' )
67
-
68
- assert_equal 'Österr. Bundesliga', at1.title
69
- assert_equal 'Österr. Erste Liga', at2.title
70
- assert_equal 'ÖFB Cup', atcup.title
71
-
72
- ## check/fix: is country_id more_attribs needed? why? why not?
73
- gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
74
- gamereader.read()
75
- gamereader = TestGameReader.from_file( 'at-austria/2013_14/el', country_id: at.id )
76
- gamereader.read()
77
-
78
- bl = Event.find_by_key!( 'at.2013/14' )
79
- el = Event.find_by_key!( 'at.2.2013/14' )
80
-
81
- assert_equal 10, bl.teams.count
82
- assert_equal 36, bl.rounds.count
83
- assert_equal 180, bl.games.count # 36x5 = 180
84
-
85
- assert_equal 10, el.teams.count
86
- end
87
-
88
- end # class TestReader
@@ -1,65 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_reader_from_string.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
-
10
- require 'helper'
11
-
12
- class TestReaderFromString < MiniTest::Test
13
-
14
- def setup
15
- WorldDb.delete!
16
- SportDb.delete!
17
- SportDb.read_builtin
18
- end
19
-
20
- def test_bl
21
- at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
22
-
23
- teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
24
- teamreader.read()
25
-
26
- leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
27
- leaguereader.read()
28
-
29
- eventreader = TestEventReader.from_file( 'at-austria/2013_14/bl' )
30
- eventreader.read()
31
-
32
- bl = Event.find_by_key!( 'at.2013/14' )
33
-
34
- assert_equal 10, bl.teams.count
35
- assert_equal 0, bl.rounds.count
36
- assert_equal 0, bl.games.count # 36x5 = 180
37
-
38
-
39
- ## fix: use File.readutf8 ??? why?? why not??
40
- bl_txt = File.read( "#{SportDb.test_data_path}/at-austria/2013_14/bl.txt" )
41
- bl_txt_ii = File.read( "#{SportDb.test_data_path}/at-austria/2013_14/bl_ii.txt" )
42
-
43
- text_ary = [bl_txt,bl_txt_ii]
44
-
45
- gamereader = GameReader.from_string( bl, text_ary )
46
- gamereader.read()
47
-
48
- ## fix: add bl.key - allow event_keys too
49
- ## gamereader = GameReader.from_string( bl.key, text_ary )
50
- ## gamereader.read()
51
-
52
-
53
- assert_equal 36, bl.rounds.count
54
- assert_equal 180, bl.games.count # 36x5 = 180
55
-
56
- ## check if is stable (update will not create new matches and rounds) on second pass/rerun
57
- gamereader.read()
58
-
59
- assert_equal 36, bl.rounds.count
60
- assert_equal 180, bl.games.count # 36x5 = 180
61
- end
62
-
63
-
64
- end # class TestReaderFromString
65
-
@@ -1,370 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_round_auto.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
-
10
- require 'helper'
11
-
12
- class TestRoundAuto < MiniTest::Test
13
-
14
- def setup
15
- WorldDb.delete!
16
- SportDb.delete!
17
- ## SportDb.read_builtin
18
-
19
- add_countries
20
- end
21
-
22
- def add_countries
23
- countries = [
24
- ['cd', 'Congo DR', 'COD' ],
25
- ['kr', 'South Korea', 'KOR' ],
26
- ['au', 'Australia', 'AUS' ],
27
-
28
- ['ar', 'Argentina', 'ARG' ],
29
- ['br', 'Brazil', 'BRA' ],
30
- ['bo', 'Bolivia', 'BOL' ],
31
- ['cl', 'Chile', 'CHI' ],
32
- ['co', 'Colombia', 'COL' ],
33
- ['uy', 'Uruguay', 'URU' ],
34
- ['pe', 'Peru', 'PER' ],
35
- ['py', 'Paraguay', 'PAR' ],
36
-
37
- ['mx', 'Mexico', 'MEX' ],
38
- ['us', 'United States', 'USA' ],
39
- ['ht', 'Haiti', 'HAI' ],
40
-
41
- ['at', 'Austria', 'AUT' ],
42
- ['be', 'Belgium', 'BEL' ],
43
- ['fr', 'France', 'FRA' ],
44
- ['rs', 'Serbia', 'SRB' ],
45
- ['ro', 'Romania', 'ROU' ],
46
- ['bg', 'Bulgaria', 'BUL' ],
47
- ['cz', 'Czech Republic', 'CZE' ],
48
- ['en', 'England', 'ENG' ],
49
- ['de', 'Germany', 'GER' ],
50
- ['hu', 'Hungary', 'HUN' ],
51
- ['it', 'Italy', 'ITA' ],
52
- ['ru', 'Russia', 'RUS' ],
53
- ['es', 'Spain', 'ESP' ],
54
- ['ch', 'Switzerland', 'SUI' ],
55
- ['sc', 'Scotland', 'SCO' ],
56
- ['tr', 'Turkey', 'TUR' ],
57
- ['nl', 'Netherlands', 'NED' ],
58
- ['pl', 'Poland', 'POL' ],
59
- ['se', 'Sweden', 'SWE' ],
60
- ]
61
-
62
- countries.each do |country|
63
- key = country[0]
64
- name = country[1]
65
- code = country[2]
66
- Country.create!( key: key, name: name, code: code, pop: 1, area: 1)
67
- end
68
- end
69
-
70
-
71
- def test_world_cup_1974
72
- teamreader = TestTeamReader.from_file( 'world-cup/teams_1974' )
73
- teamreader.read()
74
-
75
- assert_equal 16, Team.count
76
-
77
- seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1974' )
78
- seasonreader.read()
79
-
80
- assert_equal 1, Season.count
81
-
82
- y = Season.find_by_key!( '1974' )
83
- assert_equal '1974', y.title
84
-
85
- leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
86
- leaguereader.read()
87
-
88
- assert_equal 1, League.count
89
-
90
- l = League.find_by_key!( 'world' )
91
- assert_equal 'World Cup', l.title
92
-
93
- gamereader = TestGameReader.from_file( 'world-cup/1974/cup' )
94
- gamereader.read()
95
-
96
- assert_equal 1, Event.count
97
-
98
- w = Event.find_by_key!( 'world.1974' )
99
-
100
- assert_equal 16, w.teams.count
101
- assert_equal 38, w.games.count
102
- assert_equal 12, w.rounds.count
103
-
104
- rounds_exp = [
105
- [1, 'Matchday 1', '1974-06-13', 1], # first group stage
106
- [2, 'Matchday 2', '1974-06-14', 3],
107
- [3, 'Matchday 3', '1974-06-15', 4],
108
- [4, 'Matchday 4', '1974-06-18', 4],
109
- [5, 'Matchday 5', '1974-06-19', 4],
110
- [6, 'Matchday 6', '1974-06-22', 4],
111
- [7, 'Matchday 7', '1974-06-23', 4],
112
- [8, 'Matchday 8', '1974-06-26', 4], # second group stage
113
- [9, 'Matchday 9', '1974-06-30', 4],
114
- [10, 'Matchday 10', '1974-07-03', 4],
115
- [11, 'Match for third place', '1974-07-06', 1], # finals
116
- [12, 'Final', '1974-07-07', 1],
117
- ]
118
-
119
- assert_rounds( rounds_exp )
120
-
121
- #########################
122
- ## 2nd run
123
- ### try update (e.g. read again - should NOT create new rounds/games/teams)
124
- #
125
- # note: update only works if rounds get not deleted or added
126
- # - (adding for updates works only at the end/tail - not at the beginning or inbetween, for example)
127
-
128
- gamereader = TestGameReader.from_file( 'world-cup/1974/cup' )
129
- gamereader.read()
130
-
131
- assert_equal 1, Event.count
132
-
133
- w = Event.find_by_key!( 'world.1974' )
134
-
135
- assert_equal 16, w.teams.count
136
- assert_equal 38, w.games.count
137
- assert_equal 12, w.rounds.count
138
-
139
- assert_rounds( rounds_exp )
140
-
141
- end # method test_world_cup_1974
142
-
143
-
144
- def test_world_cup_1954
145
- teamreader = TestTeamReader.from_file( 'world-cup/teams_1954' )
146
- teamreader.read()
147
-
148
- assert_equal 16, Team.count
149
-
150
- assert_teams( [
151
- [ 'bra', 'Brazil', 'BRA' ],
152
- [ 'uru', 'Uruguay', 'URU' ],
153
- [ 'bel', 'Belgium', 'BEL' ] ] )
154
-
155
- seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1954' )
156
- seasonreader.read()
157
-
158
- assert_equal 1, Season.count
159
-
160
- y = Season.find_by_key!( '1954' )
161
- assert_equal '1954', y.title
162
-
163
-
164
- leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
165
- leaguereader.read()
166
-
167
- assert_equal 1, League.count
168
-
169
- l = League.find_by_key!( 'world' )
170
- assert_equal 'World Cup', l.title
171
-
172
-
173
- gamereader = TestGameReader.from_file( 'world-cup/1954/cup' )
174
- gamereader.read()
175
-
176
- assert_equal 1, Event.count
177
-
178
- w = Event.find_by_key!( 'world.1954' )
179
-
180
- assert_equal 16, w.teams.count
181
- assert_equal 26, w.games.count
182
- assert_equal 10, w.rounds.count
183
-
184
- rounds_exp = [
185
- [1, 'Matchday 1', '1954-06-16', 4],
186
- [2, 'Matchday 2', '1954-06-17', 4],
187
- [3, 'Matchday 3', '1954-06-19', 4],
188
- [4, 'Matchday 4', '1954-06-20', 4],
189
- [5, 'Group-2 Play-off', '1954-06-23', 1],
190
- [6, 'Group-4 Play-off', '1954-06-23', 1],
191
- [7, 'Quarter-finals', '1954-06-26', 4],
192
- [8, 'Semi-finals', '1954-06-30', 2],
193
- [9, 'Third place match', '1954-07-03', 1],
194
- [10, 'Final', '1954-07-04', 1],
195
- ]
196
-
197
- assert_rounds( rounds_exp )
198
-
199
- end # test_world_cup_1954
200
-
201
-
202
- def test_world_cup_1930
203
- teamreader = TestTeamReader.from_file( 'world-cup/teams_1930' )
204
- teamreader.read()
205
-
206
- assert_equal 13, Team.count
207
-
208
- assert_teams( [
209
- [ 'arg', 'Argentina', 'ARG' ],
210
- [ 'bra', 'Brazil', 'BRA' ],
211
- [ 'bel', 'Belgium', 'BEL' ] ] )
212
-
213
- seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1930' )
214
- seasonreader.read()
215
-
216
- assert_equal 1, Season.count
217
-
218
- y = Season.find_by_key!( '1930' )
219
- assert_equal '1930', y.title
220
-
221
-
222
- leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
223
- leaguereader.read()
224
-
225
- assert_equal 1, League.count
226
-
227
- l = League.find_by_key!( 'world' )
228
- assert_equal 'World Cup', l.title
229
-
230
-
231
- gamereader = TestGameReader.from_file( 'world-cup/1930/cup' )
232
- gamereader.read()
233
-
234
- assert_equal 1, Event.count
235
-
236
- w = Event.find_by_key!( 'world.1930' )
237
-
238
- assert_equal 13, w.teams.count
239
- assert_equal 18, w.games.count
240
- assert_equal 12, w.rounds.count
241
-
242
- rounds_exp = [
243
- [1, 'Matchday 1', '1930-07-13', 2],
244
- [2, 'Matchday 2', '1930-07-14', 2],
245
- [3, 'Matchday 3', '1930-07-15', 1],
246
- [4, 'Matchday 4', '1930-07-16', 1],
247
- [5, 'Matchday 5', '1930-07-17', 2],
248
- [6, 'Matchday 6', '1930-07-18', 1],
249
- [7, 'Matchday 7', '1930-07-19', 2],
250
- [8, 'Matchday 8', '1930-07-20', 2],
251
- [9, 'Matchday 9', '1930-07-21', 1],
252
- [10, 'Matchday 10', '1930-07-22', 1],
253
- [11, 'Semi-finals', '1930-07-26', 2],
254
- [12, 'Final' , '1930-07-30', 1],
255
- ]
256
-
257
- assert_rounds( rounds_exp )
258
- end # method test_world_cup_1930
259
-
260
-
261
- def test_world_cup_1962
262
- teamreader = TestTeamReader.from_file( 'world-cup/teams_1962' )
263
- teamreader.read()
264
-
265
- assert_equal 16, Team.count
266
-
267
- assert_teams( [
268
- [ 'arg', 'Argentina', 'ARG' ],
269
- [ 'bra', 'Brazil', 'BRA' ],
270
- [ 'ita', 'Italy', 'ITA' ] ] )
271
-
272
- seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1962' )
273
- seasonreader.read()
274
-
275
- assert_equal 1, Season.count
276
-
277
- y = Season.find_by_key!( '1962' )
278
- assert_equal '1962', y.title
279
-
280
-
281
- leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
282
- leaguereader.read()
283
-
284
- assert_equal 1, League.count
285
-
286
- l = League.find_by_key!( 'world' )
287
- assert_equal 'World Cup', l.title
288
-
289
-
290
- gamereader = TestGameReader.from_file( 'world-cup/1962/cup' )
291
- gamereader.read()
292
-
293
- assert_equal 1, Event.count
294
-
295
- w = Event.find_by_key!( 'world.1962' )
296
-
297
- assert_equal 16, w.teams.count
298
- assert_equal 32, w.games.count
299
- assert_equal 10, w.rounds.count
300
-
301
- rounds_exp = [
302
- [1, 'Matchday 1', '1962-05-30', 4],
303
- [2, 'Matchday 2', '1962-05-31', 4],
304
- [3, 'Matchday 3', '1962-06-02', 4],
305
- [4, 'Matchday 4', '1962-06-03', 4],
306
- [5, 'Matchday 5', '1962-06-06', 4],
307
- [6, 'Matchday 6', '1962-06-07', 4],
308
- [7, 'Quarter-finals', '1962-06-10', 4],
309
- [8, 'Semi-finals', '1962-06-13', 2],
310
- [9, 'Third place match', '1962-06-16', 1],
311
- [10, 'Final' , '1962-06-17', 1],
312
- ]
313
-
314
- assert_rounds( rounds_exp )
315
-
316
- #########################
317
- ## 2nd run
318
- ### try update (e.g. read again - should NOT create new rounds/games/teams)
319
- #
320
- # note: update only works if rounds get not deleted or added
321
- # - (adding for updates works only at the end/tail - not at the beginning or inbetween, for example)
322
-
323
- gamereader = TestGameReader.from_file( 'world-cup/1962/cup' )
324
- gamereader.read()
325
-
326
- assert_equal 1, Event.count
327
-
328
- w = Event.find_by_key!( 'world.1962' )
329
-
330
- assert_equal 16, w.teams.count
331
- assert_equal 32, w.games.count
332
- assert_equal 10, w.rounds.count
333
-
334
- assert_rounds( rounds_exp )
335
-
336
- end # method test_world_cup_1962
337
-
338
- ####
339
- # helpers
340
-
341
- def assert_rounds( rounds_exp )
342
- rounds_exp.each do |round_exp|
343
- round = Round.find_by_pos!( round_exp[0] )
344
-
345
- assert_equal round_exp[1], round.title
346
-
347
- if round_exp[2]
348
- start_at = Date.parse( round_exp[2] )
349
- ## puts "round.start_at.class.name: #{round.start_at.class.name}"
350
- assert_equal start_at, round.start_at ## check works for date?
351
- end
352
-
353
- if round_exp[3]
354
- count = round_exp[3]
355
- assert_equal( count, round.games.count, "round.games.count #{count} != #{round.games.count} - #{round.title}")
356
- end
357
- end
358
- end # method assert_rounds
359
-
360
- def assert_teams( teams_exp )
361
- teams_exp.each do |team_exp|
362
- team = Team.find_by_key!( team_exp[0] )
363
-
364
- assert_equal team_exp[1], team.title
365
- assert_equal team_exp[2], team.code
366
- end
367
- end # method assert_teams
368
-
369
-
370
- end # class TestRoundAuto