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,109 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_round_def.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
-
10
- require 'helper'
11
-
12
- class TestRoundDef < MiniTest::Test
13
-
14
-
15
- def test_round_en
16
- SportDb.lang.lang = 'en'
17
-
18
- data = [
19
- [ 'Matchday 1 | Thu Jun/12',
20
- { pos:1,
21
- title: 'Matchday 1',
22
- ko: false,
23
- start_at: Date.new( 2014, 6, 12 ) }],
24
- [ 'Matchday 1 | 12 June',
25
- { pos:1,
26
- title: 'Matchday 1',
27
- ko: false,
28
- start_at: Date.new( 2014, 6, 12 ) }],
29
- [ 'Matchday 1 | 13 July',
30
- { pos:1,
31
- title: 'Matchday 1',
32
- ko: false,
33
- start_at: Date.new( 2014, 7, 13 ) }],
34
- [ 'Matchday 13 | Tue Jun/24',
35
- { pos: 13,
36
- title: 'Matchday 13',
37
- ko: false,
38
- start_at: Date.new( 2014, 6, 24 ) }],
39
- [ '(16) Round of 16 | Sat Jun/28 - Tue Jul/1',
40
- { pos: 16,
41
- title: 'Round of 16',
42
- ko: true,
43
- start_at: Date.new( 2014, 6, 28 ),
44
- end_at: Date.new( 2014, 7, 1 ) }],
45
- [ '(18) Semi-finals | Tue Jul/8 - Wed Jul/9',
46
- { pos: 18,
47
- title: 'Semi-finals',
48
- ko: true,
49
- start_at: Date.new( 2014, 7, 8 ),
50
- end_at: Date.new( 2014, 7, 9 ) }],
51
- [ '(19) Match for third place | Sat Jul/12',
52
- { pos: 19,
53
- title: 'Match for third place',
54
- ko: true,
55
- start_at: Date.new( 2014, 7, 12 ) }],
56
- [ '(20) Final | Sun Jul/13',
57
- { pos: 20,
58
- title: 'Final',
59
- ko: true,
60
- start_at: Date.new( 2014, 7, 13 ) }] ]
61
-
62
- assert_rounds( data, Date.new( 2014, 6, 12 )) ## starts Jun/12 2014
63
- end
64
-
65
-
66
- private
67
- class Reader
68
- include LogUtils::Logging # add logger
69
- include SportDb::FixtureHelpers
70
- end
71
-
72
- def assert_rounds( data, event_start_at )
73
- data.each do |rec|
74
- line = rec[0]
75
- hash = rec[1]
76
-
77
- start_at, end_at, pos, title, ko = parse_round_def( line, event_start_at )
78
-
79
- assert_equal hash[:pos], pos, "pos expected #{hash[:pos]} is #{pos} in line >#{line}<"
80
- assert_equal hash[:title], title
81
- assert_equal hash[:ko], ko
82
-
83
- if hash[:start_at]
84
- assert_equal hash[:start_at].year, start_at.year
85
- assert_equal hash[:start_at].month, start_at.month
86
- assert_equal hash[:start_at].day, start_at.day
87
- end
88
-
89
- if hash[:end_at]
90
- assert_equal hash[:end_at].year, end_at.year
91
- assert_equal hash[:end_at].month, end_at.month
92
- assert_equal hash[:end_at].day, end_at.day
93
- end
94
- end
95
- end
96
-
97
- def parse_round_def( line, event_start_at )
98
- reader = Reader.new
99
-
100
- start_at = reader.find_date!( line, start_at: event_start_at )
101
- end_at = reader.find_date!( line, start_at: event_start_at )
102
- pos = reader.find_round_pos!( line )
103
- title = reader.find_round_def_title!( line )
104
- knockout = reader.is_knockout_round?( title ) # NB: use title as input NOT line
105
-
106
- [start_at, end_at, pos, title, knockout]
107
- end
108
-
109
- end # class TestRoundDef
@@ -1,183 +0,0 @@
1
- # encoding: utf-8
2
-
3
-
4
- require 'helper'
5
-
6
- class TestRoundHeader < MiniTest::Test
7
-
8
-
9
- def test_round_en
10
- SportDb.lang.lang = 'en'
11
-
12
- data = [
13
- [ "2. Round / Group B",
14
- { pos:2,
15
- title: '2. Round',
16
- group_pos: 2,
17
- group_title: 'Group B',
18
- ko: false } ],
19
-
20
- [ "(1) Matchday P.1 / 1st Leg // January 22-24",
21
- { pos:1,
22
- title: 'Matchday P.1 / 1st Leg',
23
- title2: 'January 22-24',
24
- ko: false } ],
25
-
26
- [ "(4) Matchday 2 / Group 1 // February 19-21",
27
- { pos:4,
28
- title: 'Matchday 2',
29
- title2: 'February 19-21',
30
- group_pos: 1,
31
- group_title: 'Group 1',
32
- ko: false } ],
33
-
34
- [ "(13) Round of 16 / 1st Leg // April 25, May 1-3",
35
- { pos:13,
36
- title: 'Round of 16 / 1st Leg',
37
- title2: 'April 25, May 1-3',
38
- ko: false } ], # NB: 1st Leg is NOT k.o. (only 2nd Leg)
39
-
40
- [ "(14) Round of 16 / 2nd Leg // May 8-10",
41
- { pos:14,
42
- title: 'Round of 16 / 2nd Leg',
43
- title2: 'May 8-10',
44
- ko: true }],
45
-
46
- [ "(4) Match for fifth place",
47
- { pos:4,
48
- title: 'Match for fifth place',
49
- ko: true }],
50
-
51
- [ "(5) Match for third place",
52
- { pos:5,
53
- title: 'Match for third place',
54
- ko: true }],
55
-
56
- [ "(1) Play-off for quarter-finals",
57
- { pos:1,
58
- title: 'Play-off for quarter-finals',
59
- ko: true }],
60
-
61
- [ "(1) Play-off 1st Leg // 11–15 October",
62
- { pos:1,
63
- title: 'Play-off 1st Leg',
64
- title2: '11–15 October',
65
- ko: false } ],
66
-
67
- [ "(2) Play-off 2nd Leg // 15-19 November",
68
- { pos:2,
69
- title: 'Play-off 2nd Leg',
70
- title2: '15-19 November',
71
- ko: true } ],
72
- ]
73
-
74
- assert_rounds( data )
75
- end
76
-
77
-
78
- def test_finals_en
79
- SportDb.lang.lang = 'en'
80
-
81
- data = [
82
- [ '(4) Quarter-finals',
83
- { pos: 4,
84
- title: 'Quarter-finals',
85
- ko: true } ],
86
-
87
- [ '(5) Semi-finals',
88
- { pos: 5,
89
- title: 'Semi-finals',
90
- ko: true } ],
91
-
92
- [ '(6) Final',
93
- { pos: 6,
94
- title: 'Final',
95
- ko: true } ] ]
96
-
97
- assert_rounds( data )
98
- end
99
-
100
-
101
- def test_round_es
102
- SportDb.lang.lang = 'es'
103
-
104
- data = [
105
- [ 'Jornada 2 // 27, 28 y 29 de julio',
106
- { pos:2,
107
- title: 'Jornada 2',
108
- title2: '27, 28 y 29 de julio',
109
- ko: false } ],
110
-
111
- [ '(18) Cuartos de Final / Ida // 14/15 de noviembre',
112
- { pos:18,
113
- title: 'Cuartos de Final / Ida',
114
- title2: '14/15 de noviembre',
115
- ko: false } ],
116
-
117
- [ '(19) Cuartos de Final / Vuelta // 17/18 de noviembre',
118
- { pos:19,
119
- title: 'Cuartos de Final / Vuelta',
120
- title2: '17/18 de noviembre',
121
- ko: true } ]]
122
-
123
- assert_rounds( data )
124
- end
125
-
126
-
127
- def test_round_de
128
- SportDb.lang.lang = 'de'
129
-
130
- data = [
131
- [ 'Spieltag 5 / Gruppe A // Di./Mi., 20.+21. Nov 2012',
132
- { pos: 5,
133
- title: 'Spieltag 5',
134
- title2: 'Di./Mi., 20.+21. Nov 2012',
135
- group_pos: 1,
136
- group_title: 'Gruppe A',
137
- ko: false } ],
138
-
139
- [ '(8) Achtelfinale Rückspiele // Di./Mi., 5.+6./12.+13. Mär 2013',
140
- { pos: 8,
141
- title: 'Achtelfinale Rückspiele',
142
- title2: 'Di./Mi., 5.+6./12.+13. Mär 2013',
143
- ko: true } ]]
144
-
145
- assert_rounds( data )
146
- end
147
-
148
-
149
- private
150
- class Reader
151
- include LogUtils::Logging # add logger
152
- include SportDb::FixtureHelpers
153
- end
154
-
155
- def assert_rounds( data )
156
- data.each do |rec|
157
- line = rec[0]
158
- hash = rec[1]
159
-
160
- pos, title, title2, group_pos, group_title, ko = parse_round_header( line )
161
-
162
- assert_equal hash[:pos], pos, "pos expected #{hash[:pos]} is #{pos} in line >#{line}<"
163
- assert_equal hash[:title], title
164
- assert_equal hash[:title2], title2
165
- assert_equal hash[:ko], ko
166
- assert_equal( hash[:group_pos], group_pos, "group_pos expected #{hash[:group_pos]} is #{group_pos} in line >#{line}<" ) if hash[:group_pos]
167
- assert_equal( hash[:group_title], group_title) if hash[:group_title]
168
- end
169
- end
170
-
171
- def parse_round_header( line )
172
- reader = Reader.new
173
-
174
- title2 = reader.find_round_header_title2!( line )
175
- group_title, group_pos = reader.find_group_title_and_pos!( line )
176
- pos = reader.find_round_pos!( line )
177
- title = reader.find_round_header_title!( line )
178
- knockout = reader.is_knockout_round?( title ) # NB: use title as input NOT line
179
-
180
- [pos, title, title2, group_pos, group_title, knockout]
181
- end
182
-
183
- end # class TestRoundHeader
@@ -1,70 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'helper'
4
-
5
- class TestScores < MiniTest::Test
6
-
7
-
8
- def test_scores
9
- data = [
10
- [ '10:0', [10,0]],
11
- [ '1:22', [1,22]],
12
- [ '1-22', [1,22]],
13
-
14
- ## do not support three digits
15
- [ '1-222', []],
16
- [ '111-0', []],
17
- [ '1:222', []],
18
- [ '111:0', []],
19
-
20
- ## penality only
21
- [ '3-4iE', [nil,nil,nil,nil,3,4]],
22
- [ '3:4iE', [nil,nil,nil,nil,3,4]],
23
- [ '3:4 iE', [nil,nil,nil,nil,3,4]],
24
- [ '3:4 i.E.', [nil,nil,nil,nil,3,4]],
25
- [ '3-4 pen', [nil,nil,nil,nil,3,4]],
26
- [ '3-4 PSO', [nil,nil,nil,nil,3,4]], # PSO => penalty shotout
27
- [ '3-4p', [nil,nil,nil,nil,3,4]],
28
- [ '3-4 p', [nil,nil,nil,nil,3,4]],
29
-
30
- ## extra time only - allow ?? why not ?? only allow penalty w/ missing extra time?
31
- ## todo/fix: issue warning or error in parser!!!
32
- [ '3-4nV', [nil,nil,3,4]],
33
- [ '3:4nV', [nil,nil,3,4]],
34
- [ '3-4 aet', [nil,nil,3,4]],
35
- [ '3-4 a.e.t.', [nil,nil,3,4]],
36
-
37
- [ '3:4nV 1:1', [1,1,3,4]],
38
- [ '1:1 3:4nV', [1,1,3,4]],
39
- [ '3:4 nV 1:1', [1,1,3,4]],
40
- [ '3:4 n.V. 1:1', [1,1,3,4]],
41
-
42
- [ '3:4iE 1:1', [1,1,nil,nil,3,4]],
43
- [ '1:1 3:4iE', [1,1,nil,nil,3,4]],
44
-
45
- [ '1:1 2:2nV 3:4iE', [1,1,2,2,3,4]],
46
- [ '3:4iE 2:2nV 1:1', [1,1,2,2,3,4]],
47
- [ '3:4 i.E. 2:2 n.V. 1:1', [1,1,2,2,3,4]],
48
- [ '3-4p 2-2aet 1-1', [1,1,2,2,3,4]],
49
- [ '3-4 pen 2-2 aet 1-1', [1,1,2,2,3,4]]
50
- ]
51
-
52
- assert_scores( data )
53
- end
54
-
55
- private
56
- def assert_scores( data )
57
- data.each do |rec|
58
- line = rec[0]
59
- exp = rec[1]
60
-
61
- assert_equal exp, parse_scores( line )
62
- end
63
- end
64
-
65
- def parse_scores( line )
66
- finder = SportDb::ScoresFinder.new
67
- finder.find!( line )
68
- end
69
-
70
- end # class TestScores
@@ -1,76 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_squad_club_reader.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
-
10
- require 'helper'
11
-
12
- class TestSquadClubReaderXX < MiniTest::Test # note: TestSquadClubReader alreay defined, thus, add xx
13
-
14
- def setup
15
- WorldDb.delete!
16
- SportDb.delete!
17
- PersonDb.delete!
18
-
19
- add_bl
20
- end
21
-
22
- def add_bl
23
- SportDb.read_builtin # add 2013/14 season
24
-
25
- at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
26
-
27
- teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
28
- teamreader.read()
29
-
30
- leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
31
- leaguereader.read()
32
-
33
- ## check/fix: is country_id more_attribs needed? why? why not?
34
- gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
35
- gamereader.read()
36
-
37
- bl = Event.find_by_key!( 'at.2013/14' )
38
-
39
- assert_equal 10, bl.teams.count
40
- assert_equal 36, bl.rounds.count
41
- assert_equal 180, bl.games.count # 36x5 = 180
42
-
43
- ## add players
44
- ## -- read persons
45
- ## personreader = PersonReader.new( SportDb.test_data_path )
46
- ## personreader.read( 'players/europe/at-austria/players', country_id: at.id )
47
-
48
- ## assert_equal 30, Person.count
49
- end
50
-
51
-
52
- def test_austria
53
- austria = Team.find_by_key!( 'austria' )
54
-
55
- event = Event.find_by_key!( 'at.2013/14' )
56
-
57
- reader = TestClubSquadReader.from_file( 'at-austria/2013_14/squads/austria', team_id: austria.id, event_id: event.id )
58
- reader.read()
59
-
60
- assert_equal 28, Roster.count
61
- end # method test_br
62
-
63
-
64
- def test_salzburg
65
- salzburg = Team.find_by_key!( 'salzburg' )
66
-
67
- event = Event.find_by_key!( 'at.2013/14' )
68
-
69
- reader = TestClubSquadReader.from_file( 'at-austria/2013_14/squads/salzburg', team_id: salzburg.id, event_id: event.id )
70
- reader.read()
71
-
72
- assert_equal 27, Roster.count
73
- end # method test_salzburg
74
-
75
-
76
- end # class TestSquadClubReader
@@ -1,116 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_squad_national_team_reader.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
-
10
- require 'helper'
11
-
12
- class TestSquadNationalTeamReader < MiniTest::Test
13
-
14
- def setup
15
- WorldDb.delete!
16
- SportDb.delete!
17
- PersonDb.delete!
18
-
19
- add_world_cup_2014
20
- end
21
-
22
- def add_world_cup_2014
23
- SportDb.read_builtin # add 2014 season
24
-
25
- leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
26
- leaguereader.read()
27
-
28
- assert_equal 1, League.count
29
-
30
- l = League.find_by_key!( 'world' )
31
- assert_equal 'World Cup', l.title
32
-
33
- gamereader = TestGameReader.from_file( 'world-cup/2014/cup' )
34
- gamereader.read()
35
-
36
- assert_equal 1, Event.count
37
- end
38
-
39
- def test_br
40
- br = Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 1, area: 1)
41
-
42
- ## read persons
43
- ## personreader = PersonReader.new( SportDb.test_data_path )
44
- ## personreader.read( 'players/south-america/br-brazil/players', country_id: br.id )
45
- ##
46
- ## assert_equal 30, Person.count
47
-
48
- bra = Team.create!( key: 'bra', title: 'Brazil', code: 'BRA', country_id: br.id )
49
-
50
-
51
- event = Event.find_by_key!( 'world.2014' )
52
-
53
- reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/br-brazil', team_id: bra.id, event_id: event.id )
54
- reader.read()
55
-
56
- assert_equal 23, Roster.count
57
- end # method test_br
58
-
59
-
60
- def test_de
61
- de = Country.create!( key: 'de', title: 'Germany', code: 'GER', pop: 1, area: 1)
62
-
63
- ## read persons
64
- ## personreader = PersonReader.new( SportDb.test_data_path )
65
- ## personreader.read( 'players/europe/de-deutschland/players', country_id: de.id )
66
- ##
67
- ## assert_equal 27, Person.count
68
-
69
- ger = Team.create!( key: 'ger', title: 'Germany', code: 'GER', country_id: de.id )
70
-
71
- event = Event.find_by_key!( 'world.2014' )
72
-
73
- reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/de-deutschland', team_id: ger.id, event_id: event.id )
74
- reader.read()
75
-
76
- assert_equal 3, Roster.count
77
- end # method test_de
78
-
79
-
80
- def test_uy
81
- uy = Country.create!( key: 'uy', title: 'Uruguay', code: 'URU', pop: 1, area: 1)
82
-
83
- assert_equal 0, Person.count
84
- assert_equal 0, Roster.count
85
-
86
- uru = Team.create!( key: 'uru', title: 'Uruguay', code: 'URU', country_id: uy.id )
87
-
88
- event = Event.find_by_key!( 'world.2014' )
89
-
90
- reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/uy-uruguay', team_id: uru.id, event_id: event.id )
91
- reader.read()
92
-
93
- assert_equal 23, Roster.count
94
- assert_equal 23, Person.count
95
- end # method test_uy
96
-
97
-
98
- def test_jp
99
- jp = Country.create!( key: 'jp', title: 'Japan', code: 'JPN', pop: 1, area: 1)
100
-
101
- assert_equal 0, Person.count
102
- assert_equal 0, Roster.count
103
-
104
- jpn = Team.create!( key: 'jpn', title: 'Japan', code: 'JPN', country_id: jp.id )
105
-
106
- event = Event.find_by_key!( 'world.2014' )
107
-
108
- reader = TestNationalTeamSquadReader.from_file( 'world-cup/2014/squads/jp-japan', team_id: jpn.id, event_id: event.id )
109
- reader.read()
110
-
111
- assert_equal 23, Roster.count
112
- assert_equal 23, Person.count
113
- end # method test_jp
114
-
115
-
116
- end # class TestSquadNationalTeamReader