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
data/test/test_standings.rb
DELETED
@@ -1,279 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_standings.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
class TestStandings < MiniTest::Test
|
15
|
-
|
16
|
-
def setup
|
17
|
-
WorldDb.delete!
|
18
|
-
SportDb.delete!
|
19
|
-
## SportDb.read_builtin
|
20
|
-
|
21
|
-
add_countries
|
22
|
-
add_world_cup_1974
|
23
|
-
end
|
24
|
-
|
25
|
-
def add_countries
|
26
|
-
countries = [
|
27
|
-
['cd', 'Congo DR', 'COD' ],
|
28
|
-
['kr', 'South Korea', 'KOR' ],
|
29
|
-
['au', 'Australia', 'AUS' ],
|
30
|
-
|
31
|
-
['ar', 'Argentina', 'ARG' ],
|
32
|
-
['br', 'Brazil', 'BRA' ],
|
33
|
-
['bo', 'Bolivia', 'BOL' ],
|
34
|
-
['cl', 'Chile', 'CHI' ],
|
35
|
-
['co', 'Colombia', 'COL' ],
|
36
|
-
['uy', 'Uruguay', 'URU' ],
|
37
|
-
['pe', 'Peru', 'PER' ],
|
38
|
-
['py', 'Paraguay', 'PAR' ],
|
39
|
-
|
40
|
-
['mx', 'Mexico', 'MEX' ],
|
41
|
-
['us', 'United States', 'USA' ],
|
42
|
-
['ht', 'Haiti', 'HAI' ],
|
43
|
-
|
44
|
-
['at', 'Austria', 'AUT' ],
|
45
|
-
['be', 'Belgium', 'BEL' ],
|
46
|
-
['fr', 'France', 'FRA' ],
|
47
|
-
['rs', 'Serbia', 'SRB' ],
|
48
|
-
['ro', 'Romania', 'ROU' ],
|
49
|
-
['bg', 'Bulgaria', 'BUL' ],
|
50
|
-
['cz', 'Czech Republic', 'CZE' ],
|
51
|
-
['en', 'England', 'ENG' ],
|
52
|
-
['de', 'Germany', 'GER' ],
|
53
|
-
['hu', 'Hungary', 'HUN' ],
|
54
|
-
['it', 'Italy', 'ITA' ],
|
55
|
-
['ru', 'Russia', 'RUS' ],
|
56
|
-
['es', 'Spain', 'ESP' ],
|
57
|
-
['ch', 'Switzerland', 'SUI' ],
|
58
|
-
['sc', 'Scotland', 'SCO' ],
|
59
|
-
['tr', 'Turkey', 'TUR' ],
|
60
|
-
['nl', 'Netherlands', 'NED' ],
|
61
|
-
['pl', 'Poland', 'POL' ],
|
62
|
-
['se', 'Sweden', 'SWE' ],
|
63
|
-
]
|
64
|
-
|
65
|
-
countries.each do |country|
|
66
|
-
key = country[0]
|
67
|
-
name = country[1]
|
68
|
-
code = country[2]
|
69
|
-
Country.create!( key: key, name: name, code: code, pop: 1, area: 1 )
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
def add_world_cup_1974
|
75
|
-
teamreader = TestTeamReader.from_file( 'world-cup/teams_1974' )
|
76
|
-
teamreader.read()
|
77
|
-
|
78
|
-
seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1974' )
|
79
|
-
seasonreader.read()
|
80
|
-
|
81
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
82
|
-
leaguereader.read()
|
83
|
-
|
84
|
-
gamereader = TestGameReader.from_file( 'world-cup/1974/cup' )
|
85
|
-
gamereader.read()
|
86
|
-
|
87
|
-
ev = Event.find_by_key!( 'world.1974' )
|
88
|
-
|
89
|
-
assert_equal 16, ev.teams.count
|
90
|
-
assert_equal 38, ev.games.count
|
91
|
-
assert_equal 12, ev.rounds.count
|
92
|
-
end # method add_world_cup_1974
|
93
|
-
|
94
|
-
|
95
|
-
def test_alltime_standings
|
96
|
-
st = AlltimeStanding.create!( key: 'worldcup', title: 'All Time World Cup' )
|
97
|
-
|
98
|
-
assert_equal 1, AlltimeStanding.count
|
99
|
-
assert_equal 0, st.entries.count
|
100
|
-
|
101
|
-
## add some team entries
|
102
|
-
|
103
|
-
arg = Team.find_by_key!( 'arg' )
|
104
|
-
bra = Team.find_by_key!( 'bra' )
|
105
|
-
ita = Team.find_by_key!( 'ita' )
|
106
|
-
|
107
|
-
AlltimeStandingEntry.create!( standing_id: st.id, team_id: arg.id )
|
108
|
-
AlltimeStandingEntry.create!( standing_id: st.id, team_id: bra.id )
|
109
|
-
AlltimeStandingEntry.create!( standing_id: st.id, team_id: ita.id )
|
110
|
-
|
111
|
-
assert_equal 3, st.entries.count
|
112
|
-
assert_equal 3, AlltimeStandingEntry.count
|
113
|
-
|
114
|
-
st2 = AlltimeStandingEntry.first.standing # check back/parent ref w/ standing belongs_to assoc
|
115
|
-
assert_equal 'worldcup', st2.key
|
116
|
-
assert_equal 'All Time World Cup', st2.title
|
117
|
-
|
118
|
-
end # test_alltime_standings
|
119
|
-
|
120
|
-
|
121
|
-
def test_alltime_standings_recalc
|
122
|
-
st = AlltimeStanding.create!( key: 'worldcup', title: 'All Time World Cup' )
|
123
|
-
|
124
|
-
assert_equal 1, AlltimeStanding.count
|
125
|
-
assert_equal 0, st.entries.count
|
126
|
-
|
127
|
-
league = League.find_by_key!( 'world' )
|
128
|
-
|
129
|
-
st.recalc_for_league!( league )
|
130
|
-
assert_equal 16, st.entries.count
|
131
|
-
assert_equal 16, AlltimeStandingEntry.count
|
132
|
-
|
133
|
-
st.recalc_for_league!( league )
|
134
|
-
assert_equal 16, st.entries.count
|
135
|
-
assert_equal 16, AlltimeStandingEntry.count
|
136
|
-
|
137
|
-
|
138
|
-
# test merge to new team (not included)
|
139
|
-
at = Country.find_by_key!( 'at' )
|
140
|
-
aut = Team.create!( key: 'aut', title: 'Austria', code: 'AUT', country_id: at.id )
|
141
|
-
|
142
|
-
#### try merge teams
|
143
|
-
# merge (incl.) uruguay into bra
|
144
|
-
#
|
145
|
-
st.recalc_for_league!( league, merge: { 'bra' => 'uru',
|
146
|
-
'pol' => ['bul', 'yug'],
|
147
|
-
'aut' => 'aus' } )
|
148
|
-
|
149
|
-
assert_equal 13, st.entries.count
|
150
|
-
assert_equal 13, AlltimeStandingEntry.count
|
151
|
-
|
152
|
-
bra = Team.find_by_key!( 'bra' )
|
153
|
-
bra_stats = st.entries.where( team_id: bra.id ).first
|
154
|
-
assert_equal 2, bra_stats.recs
|
155
|
-
|
156
|
-
pol = Team.find_by_key!( 'pol' )
|
157
|
-
pol_stats = st.entries.where( team_id: pol.id ).first
|
158
|
-
assert_equal 3, pol_stats.recs
|
159
|
-
|
160
|
-
# test merge to new team (not included)
|
161
|
-
aut = Team.find_by_key!( 'aut' )
|
162
|
-
aut_stats = st.entries.where( team_id: aut.id ).first
|
163
|
-
assert_equal 1, aut_stats.recs
|
164
|
-
|
165
|
-
end # test_alltime_standings_recalc
|
166
|
-
|
167
|
-
|
168
|
-
def test_event_standings_recalc
|
169
|
-
ev = Event.find_by_key!( 'world.1974' )
|
170
|
-
|
171
|
-
assert_equal 16, ev.teams.count
|
172
|
-
|
173
|
-
st = EventStanding.create!( event_id: ev.id )
|
174
|
-
|
175
|
-
assert_equal 1, EventStanding.count
|
176
|
-
assert_equal 0, st.entries.count
|
177
|
-
|
178
|
-
st.recalc!
|
179
|
-
assert_equal 16, st.entries.count
|
180
|
-
|
181
|
-
st.recalc! ## try again (check update)
|
182
|
-
assert_equal 16, st.entries.count
|
183
|
-
|
184
|
-
## try global recalc
|
185
|
-
EventStandingEntry.delete_all
|
186
|
-
assert_equal 1, EventStanding.count
|
187
|
-
assert_equal 0, EventStandingEntry.count
|
188
|
-
|
189
|
-
EventStanding.recalc!
|
190
|
-
assert_equal 1, EventStanding.count
|
191
|
-
assert_equal 16, EventStandingEntry.count
|
192
|
-
|
193
|
-
end # test_event_standings_recalc
|
194
|
-
|
195
|
-
|
196
|
-
def test_group_standings_recalc
|
197
|
-
g2 = Group.find_by_pos!( 2 ) ## Group 2 | Yugoslavia Brazil Scotland Zaire
|
198
|
-
|
199
|
-
assert_equal 4, g2.teams.count
|
200
|
-
|
201
|
-
st2 = GroupStanding.create!( group_id: g2.id )
|
202
|
-
|
203
|
-
assert_equal 1, GroupStanding.count
|
204
|
-
assert_equal 0, st2.entries.count
|
205
|
-
|
206
|
-
st2.recalc!
|
207
|
-
assert_equal 4, st2.entries.count
|
208
|
-
|
209
|
-
st2.recalc! ## try again (check update)
|
210
|
-
assert_equal 4, st2.entries.count
|
211
|
-
|
212
|
-
## try global recalc
|
213
|
-
GroupStandingEntry.delete_all
|
214
|
-
assert_equal 1, GroupStanding.count
|
215
|
-
assert_equal 0, GroupStandingEntry.count
|
216
|
-
|
217
|
-
GroupStanding.recalc!
|
218
|
-
assert_equal 1, GroupStanding.count
|
219
|
-
assert_equal 4, GroupStandingEntry.count
|
220
|
-
|
221
|
-
end # test_group_standings_recalc
|
222
|
-
|
223
|
-
|
224
|
-
def test_group_standings
|
225
|
-
## Group 1 | East Germany West Germany Chile Australia
|
226
|
-
## Group 2 | Yugoslavia Brazil Scotland Zaire
|
227
|
-
## Group 3 | Netherlands Sweden Bulgaria Uruguay
|
228
|
-
## Group 4 | Poland Argentina Italy Haiti
|
229
|
-
|
230
|
-
g2 = Group.find_by_pos!( 2 )
|
231
|
-
g4 = Group.find_by_pos!( 4 )
|
232
|
-
|
233
|
-
assert_equal 4, g2.teams.count
|
234
|
-
assert_equal 4, g4.teams.count
|
235
|
-
|
236
|
-
st2 = GroupStanding.create!( group_id: g2.id )
|
237
|
-
st4 = GroupStanding.create!( group_id: g4.id )
|
238
|
-
|
239
|
-
assert_equal 2, GroupStanding.count
|
240
|
-
assert_equal 0, st2.entries.count
|
241
|
-
assert_equal 0, st4.entries.count
|
242
|
-
|
243
|
-
## add some team entries
|
244
|
-
bra = Team.find_by_key!( 'bra' )
|
245
|
-
arg = Team.find_by_key!( 'arg' )
|
246
|
-
ita = Team.find_by_key!( 'ita' )
|
247
|
-
|
248
|
-
GroupStandingEntry.create!( standing_id: st2.id, team_id: bra.id )
|
249
|
-
GroupStandingEntry.create!( standing_id: st4.id, team_id: arg.id )
|
250
|
-
GroupStandingEntry.create!( standing_id: st4.id, team_id: ita.id )
|
251
|
-
|
252
|
-
assert_equal 1, st2.entries.count
|
253
|
-
assert_equal 2, st4.entries.count
|
254
|
-
assert_equal 3, GroupStandingEntry.count
|
255
|
-
|
256
|
-
st2ii = st2.entries.first.standing # check back/parent ref w/ standing belongs_to assoc
|
257
|
-
assert_equal g2.title, st2ii.group.title
|
258
|
-
|
259
|
-
|
260
|
-
## Group I | Netherlands Brazil East Germany Argentina
|
261
|
-
## Group J | West Germany Poland Sweden Yugoslavia
|
262
|
-
|
263
|
-
gi = Group.find_by_pos!( 9 ) # note: I maps to 9
|
264
|
-
gj = Group.find_by_pos!( 10 ) # note: J maps to 10
|
265
|
-
|
266
|
-
assert_equal 4, gi.teams.count
|
267
|
-
assert_equal 4, gj.teams.count
|
268
|
-
|
269
|
-
sti = GroupStanding.create!( group_id: gi.id )
|
270
|
-
stj = GroupStanding.create!( group_id: gj.id )
|
271
|
-
|
272
|
-
assert_equal 4, GroupStanding.count
|
273
|
-
assert_equal 0, sti.entries.count
|
274
|
-
assert_equal 0, stj.entries.count
|
275
|
-
|
276
|
-
end # test_group_standings
|
277
|
-
|
278
|
-
|
279
|
-
end # class TestStandings
|
data/test/test_standings_ii.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_standings_ii.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestStandingsII < 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
|
-
|
39
|
-
standings = SportDb::Standings.new
|
40
|
-
standings.update( bl.games )
|
41
|
-
|
42
|
-
pp standings.to_a
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
end # class TestStandingsII
|
data/test/test_utils.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_lang.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
require 'helper'
|
10
|
-
|
11
|
-
class TestUtils < MiniTest::Test
|
12
|
-
|
13
|
-
def test_is_group_def
|
14
|
-
SportDb.lang.lang = 'en'
|
15
|
-
|
16
|
-
lines = [
|
17
|
-
'Group A |',
|
18
|
-
'Group B |'
|
19
|
-
]
|
20
|
-
|
21
|
-
reader = Reader.new
|
22
|
-
|
23
|
-
lines.each do |line|
|
24
|
-
assert_equal true, reader.is_group_def?( line )
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_is_group
|
29
|
-
SportDb.lang.lang = 'en'
|
30
|
-
|
31
|
-
lines = [
|
32
|
-
'Group A',
|
33
|
-
'Group A:',
|
34
|
-
'[Group A]'
|
35
|
-
]
|
36
|
-
|
37
|
-
reader = Reader.new
|
38
|
-
|
39
|
-
lines.each do |line|
|
40
|
-
assert_equal true, reader.is_group?( line )
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
def test_is_round_def
|
46
|
-
SportDb.lang.lang = 'en'
|
47
|
-
|
48
|
-
lines = [
|
49
|
-
'Matchday 1 |',
|
50
|
-
'Round 1 |'
|
51
|
-
]
|
52
|
-
|
53
|
-
reader = Reader.new
|
54
|
-
|
55
|
-
lines.each do |line|
|
56
|
-
assert_equal true, reader.is_round_def?( line )
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_is_round
|
61
|
-
SportDb.lang.lang = 'en'
|
62
|
-
|
63
|
-
lines = [
|
64
|
-
'Matchday 1',
|
65
|
-
'[Matchday 1]',
|
66
|
-
'Matchday 1:',
|
67
|
-
'Round 1'
|
68
|
-
]
|
69
|
-
|
70
|
-
reader = Reader.new
|
71
|
-
|
72
|
-
lines.each do |line|
|
73
|
-
assert_equal true, reader.is_round?( line )
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
def test_is_knockout_round
|
79
|
-
SportDb.lang.lang = 'en'
|
80
|
-
|
81
|
-
lines = [
|
82
|
-
'(4) Quarter-finals',
|
83
|
-
'(5) Semi-finals',
|
84
|
-
'(6) Final'
|
85
|
-
]
|
86
|
-
|
87
|
-
reader = Reader.new
|
88
|
-
|
89
|
-
lines.each do |line|
|
90
|
-
assert_equal true, reader.is_knockout_round?( line )
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
def test_is_knockout_round_de
|
96
|
-
SportDb.lang.lang = 'de'
|
97
|
-
|
98
|
-
lines = [
|
99
|
-
'(1) Achtelfinale // Di+Mi 14.+15. & 21.+22. Feb 2012',
|
100
|
-
'(2) Achtelfinale Rückspiele // Di+Mi 6.+7. & 13.+14. März 2012',
|
101
|
-
'(3) Viertelfinale // Di+Mi 27.+28. März 2012',
|
102
|
-
'(4) Viertelfinale Rückspiele // Di+Mi 3.+4. April 2012',
|
103
|
-
'(5) Halbfinale // Di+Mi 17.+18. April 2012',
|
104
|
-
'(6) Halbfinale Rückspiele // Di+Mi 24.+25. April 2012',
|
105
|
-
'(7) Finale // Sa 19. Mai 2012'
|
106
|
-
]
|
107
|
-
|
108
|
-
reader = Reader.new
|
109
|
-
|
110
|
-
lines.each do |line|
|
111
|
-
assert_equal true, reader.is_knockout_round?( line )
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
#######################
|
117
|
-
# private helpers
|
118
|
-
|
119
|
-
class Reader
|
120
|
-
include LogUtils::Logging # add logger
|
121
|
-
include SportDb::FixtureHelpers
|
122
|
-
end
|
123
|
-
|
124
|
-
end # class TestUtils
|