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_changes.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class TestChanges < MiniTest::Test
|
6
|
-
|
7
|
-
def test_scores
|
8
|
-
game1 = Game.new
|
9
|
-
game1.score1 = 1
|
10
|
-
game1.score2 = 2
|
11
|
-
|
12
|
-
game2 = Game.new
|
13
|
-
game2.score1 = 1
|
14
|
-
game2.score2 = 1
|
15
|
-
game2.score1p = 5
|
16
|
-
game2.score2p = 3
|
17
|
-
|
18
|
-
game_attribs = {
|
19
|
-
score1: 1,
|
20
|
-
score2: 2,
|
21
|
-
score1et: nil,
|
22
|
-
score2et: nil,
|
23
|
-
score1p: nil,
|
24
|
-
score2p: nil
|
25
|
-
}
|
26
|
-
|
27
|
-
assert_equal false, game1.check_for_changes( game_attribs )
|
28
|
-
assert_equal true, game2.check_for_changes( game_attribs )
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_play_at
|
32
|
-
game1 = Game.new
|
33
|
-
game1.score1 = 1
|
34
|
-
game1.score2 = 2
|
35
|
-
game1.play_at = DateTime.new( 2012, 11, 5 )
|
36
|
-
|
37
|
-
game2 = Game.new
|
38
|
-
game2.score1 = 1
|
39
|
-
game2.score2 = 2
|
40
|
-
game2.play_at = DateTime.new( 2012, 12, 24 )
|
41
|
-
|
42
|
-
game_attribs = {
|
43
|
-
score1: 1,
|
44
|
-
score2: 2,
|
45
|
-
play_at: DateTime.new( 2012, 11, 5 )
|
46
|
-
}
|
47
|
-
|
48
|
-
assert_equal false, game1.check_for_changes( game_attribs )
|
49
|
-
assert_equal true, game2.check_for_changes( game_attribs )
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_group_id
|
53
|
-
game1 = Game.new
|
54
|
-
game1.score1 = 1
|
55
|
-
game1.score2 = 2
|
56
|
-
game1.group_id = 1
|
57
|
-
|
58
|
-
game2 = Game.new
|
59
|
-
game2.score1 = 1
|
60
|
-
game2.score2 = 2
|
61
|
-
game2.group_id = 2
|
62
|
-
|
63
|
-
game_attribs = {
|
64
|
-
score1: 1,
|
65
|
-
score2: 2,
|
66
|
-
group_id: 1
|
67
|
-
}
|
68
|
-
|
69
|
-
assert_equal false, game1.check_for_changes( game_attribs )
|
70
|
-
assert_equal true, game2.check_for_changes( game_attribs )
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
end # class TestChanges
|
data/test/test_cursor.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class TestCursor < MiniTest::Test
|
6
|
-
|
7
|
-
def test_games
|
8
|
-
games = []
|
9
|
-
|
10
|
-
games << Game.new( score1: 3, score2: 1, play_at: DateTime.new(2013, 8, 9) )
|
11
|
-
games << Game.new( score1: 1, score2: 3, play_at: DateTime.new(2013, 8, 10) )
|
12
|
-
games << Game.new( score1: 2, score2: 0, play_at: DateTime.new(2013, 8, 10) )
|
13
|
-
games << Game.new( score1: 3, score2: 2, play_at: DateTime.new(2013, 8, 12) ) # new_week
|
14
|
-
|
15
|
-
GameCursor.new( games ).each do |game,state|
|
16
|
-
if state.index == 0
|
17
|
-
assert_equal 3, game.score1
|
18
|
-
assert_equal 1, game.score2
|
19
|
-
assert_equal true, state.new_date?
|
20
|
-
assert_equal true, state.new_year?
|
21
|
-
assert_equal true, state.new_week?
|
22
|
-
end
|
23
|
-
|
24
|
-
if state.index == 1
|
25
|
-
assert_equal 1, game.score1
|
26
|
-
assert_equal 3, game.score2
|
27
|
-
assert_equal true, state.new_date?
|
28
|
-
assert_equal false, state.new_year?
|
29
|
-
assert_equal false, state.new_week?
|
30
|
-
end
|
31
|
-
|
32
|
-
if state.index == 2
|
33
|
-
assert_equal 2, game.score1
|
34
|
-
assert_equal 0, game.score2
|
35
|
-
assert_equal false, state.new_date?
|
36
|
-
assert_equal false, state.new_year?
|
37
|
-
assert_equal false, state.new_week?
|
38
|
-
end
|
39
|
-
|
40
|
-
if state.index == 3
|
41
|
-
assert_equal 3, game.score1
|
42
|
-
assert_equal 2, game.score2
|
43
|
-
assert_equal true, state.new_date?
|
44
|
-
assert_equal true, state.new_week?
|
45
|
-
assert_equal false, state.new_year?
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end # class TestCursor
|
data/test/test_date.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_date.rb
|
6
|
-
|
7
|
-
require 'helper'
|
8
|
-
|
9
|
-
class TestDate < MiniTest::Test
|
10
|
-
|
11
|
-
def test_date
|
12
|
-
data = [
|
13
|
-
[ '19.01.2013 22.00', '2013-01-19 22:00' ],
|
14
|
-
[ '21.01.2013 21.30', '2013-01-21 21:30' ],
|
15
|
-
[ '26.01.2013', '2013-01-26' ],
|
16
|
-
[ '[26.01.2013]', '2013-01-26' ],
|
17
|
-
[ '[21.1.]', '2013-01-21 12:00' ]
|
18
|
-
]
|
19
|
-
|
20
|
-
assert_dates( data, start_at: DateTime.new( 2013, 1, 1 ) )
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_date_fr
|
24
|
-
data = [
|
25
|
-
[ '[Ven 08. Août]', '2014-08-08' ],
|
26
|
-
[ 'Ven 08. Août', '2014-08-08' ],
|
27
|
-
[ 'Ven 8. Août', '2014-08-08' ],
|
28
|
-
[ '[Sam 9. Août]', '2014-08-09' ],
|
29
|
-
[ '[Dim 10. Août]', '2014-08-10' ],
|
30
|
-
[ '[Sam 31. Janv]', '2015-01-31' ],
|
31
|
-
[ '[Sam 7. Févr]', '2015-02-07' ],
|
32
|
-
[ '[Sam 31. Jan]', '2015-01-31' ],
|
33
|
-
[ '[Sam 7. Fév]', '2015-02-07' ],
|
34
|
-
]
|
35
|
-
|
36
|
-
assert_dates( data, start_at: DateTime.new( 2014, 8, 1 ) )
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_date_en
|
40
|
-
data = [
|
41
|
-
[ 'Jun/12 2011 14:00', '2011-06-12 14:00' ],
|
42
|
-
[ 'Oct/12 2013 16:00', '2013-10-12 16:00' ],
|
43
|
-
|
44
|
-
[ 'Jan/26 2011', '2011-01-26' ],
|
45
|
-
[ 'Jan/26 2011', '2011-01-26 12:00' ],
|
46
|
-
|
47
|
-
[ 'Jan/26', '2013-01-26' ],
|
48
|
-
[ 'Jan/26', '2013-01-26 12:00' ],
|
49
|
-
[ '26 January', '2013-01-26' ],
|
50
|
-
[ '26 January', '2013-01-26 12:00' ],
|
51
|
-
|
52
|
-
[ 'Jun/13', '2013-06-13' ],
|
53
|
-
[ 'Jun/13', '2013-06-13 12:00' ],
|
54
|
-
[ '13 June', '2013-06-13' ],
|
55
|
-
[ '13 June', '2013-06-13 12:00' ]
|
56
|
-
]
|
57
|
-
|
58
|
-
assert_dates( data, start_at: DateTime.new( 2013, 1, 1 ) )
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def assert_dates( data, opts )
|
65
|
-
data.each do |rec|
|
66
|
-
line = rec[0]
|
67
|
-
str = rec[1]
|
68
|
-
if str.index( ':' )
|
69
|
-
assert_datetime( DateTime.strptime( str, '%Y-%m-%d %H:%M' ), parse_date( line, opts ))
|
70
|
-
else
|
71
|
-
assert_date( DateTime.strptime( str, '%Y-%m-%d' ), parse_date( line, opts ))
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
## todo: check if assert_datetime or assert_date exist already? what is the best practice to check dates ???
|
77
|
-
def assert_date( exp, act )
|
78
|
-
assert_equal exp.year, act.year
|
79
|
-
assert_equal exp.month, act.month
|
80
|
-
assert_equal exp.day, act.day
|
81
|
-
end
|
82
|
-
|
83
|
-
def assert_time( exp, act )
|
84
|
-
assert_equal exp.hour, act.hour
|
85
|
-
assert_equal exp.min, act.min
|
86
|
-
end
|
87
|
-
|
88
|
-
def assert_datetime( exp, act )
|
89
|
-
assert_date( exp, act )
|
90
|
-
assert_time( exp, act )
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
def parse_date( line, opts={} )
|
95
|
-
# e.g. lets you pass in opts[:start_at] ???
|
96
|
-
finder = SportDb::DateFinder.new
|
97
|
-
finder.find!( line, opts )
|
98
|
-
end
|
99
|
-
|
100
|
-
end # class TestScores
|
data/test/test_goals.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_goals.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestGoals < 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_1930
|
72
|
-
teamreader = TestTeamReader.from_file( 'world-cup/teams_1930' )
|
73
|
-
teamreader.read()
|
74
|
-
|
75
|
-
assert_equal 13, Team.count
|
76
|
-
|
77
|
-
seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1930' )
|
78
|
-
seasonreader.read()
|
79
|
-
|
80
|
-
assert_equal 1, Season.count
|
81
|
-
|
82
|
-
y = Season.find_by_key!( '1930' )
|
83
|
-
assert_equal '1930', y.title
|
84
|
-
|
85
|
-
|
86
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
87
|
-
leaguereader.read()
|
88
|
-
|
89
|
-
assert_equal 1, League.count
|
90
|
-
|
91
|
-
l = League.find_by_key!( 'world' )
|
92
|
-
assert_equal 'World Cup', l.title
|
93
|
-
|
94
|
-
|
95
|
-
gamereader = TestGameReader.from_file( 'world-cup/1930/cup_goals' )
|
96
|
-
gamereader.read()
|
97
|
-
|
98
|
-
assert_equal 1, Event.count
|
99
|
-
|
100
|
-
w = Event.find_by_key!( 'world.1930' )
|
101
|
-
|
102
|
-
assert_equal 13, w.teams.count
|
103
|
-
## assert_equal 18, w.games.count
|
104
|
-
## assert_equal 12, w.rounds.count
|
105
|
-
|
106
|
-
end # method test_world_cup_1930
|
107
|
-
|
108
|
-
|
109
|
-
end # class TestGoals
|
data/test/test_lang.rb
DELETED
@@ -1,130 +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 TestLang < MiniTest::Test
|
12
|
-
|
13
|
-
def test_getters
|
14
|
-
|
15
|
-
lang = SportDb.lang
|
16
|
-
lang.lang = 'en'
|
17
|
-
|
18
|
-
group = 'Group'
|
19
|
-
|
20
|
-
round = 'Round|Matchday|Week'
|
21
|
-
round << '|Round of 32|Last 32'
|
22
|
-
round << '|Round of 16|Last 16|8th finals'
|
23
|
-
round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
|
24
|
-
round << '|Semifinals|Semi-finals|Semis|Last 4'
|
25
|
-
round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
|
26
|
-
round << '|Third place match|Third-place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
|
27
|
-
round << '|Final|Finals'
|
28
|
-
round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
|
29
|
-
|
30
|
-
knockout_round = 'Round of 32|Last 32'
|
31
|
-
knockout_round << '|Round of 16|Last 16|8th finals'
|
32
|
-
knockout_round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
|
33
|
-
knockout_round << '|Semifinals|Semi-finals|Semis|Last 4'
|
34
|
-
knockout_round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
|
35
|
-
knockout_round << '|Third place match|Third-place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
|
36
|
-
knockout_round << '|Final|Finals'
|
37
|
-
knockout_round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
|
38
|
-
|
39
|
-
assert_equal group, lang.group
|
40
|
-
assert_equal round, lang.round
|
41
|
-
assert_equal knockout_round, lang.knockout_round
|
42
|
-
|
43
|
-
# NB: call twice to test caching with ||=
|
44
|
-
assert_equal group, lang.group
|
45
|
-
assert_equal round, lang.round
|
46
|
-
assert_equal knockout_round, lang.knockout_round
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_getters_de
|
51
|
-
lang = SportDb.lang
|
52
|
-
lang.lang = 'de'
|
53
|
-
|
54
|
-
group = 'Gruppe'
|
55
|
-
|
56
|
-
round = 'Spieltag|Runde'
|
57
|
-
round << '|Sechzehntelfinale|1/16 Finale'
|
58
|
-
round << '|Achtelfinale|1/8 Finale'
|
59
|
-
round << '|Viertelfinale|1/4 Finale'
|
60
|
-
round << '|Halbfinale|Semifinale|1/2 Finale'
|
61
|
-
round << '|Spiel um Platz 5'
|
62
|
-
round << '|Spiel um Platz 3'
|
63
|
-
round << '|Finale|Endspiel'
|
64
|
-
|
65
|
-
knockout_round = 'Sechzehntelfinale|1/16 Finale'
|
66
|
-
knockout_round << '|Achtelfinale|1/8 Finale'
|
67
|
-
knockout_round << '|Viertelfinale|1/4 Finale'
|
68
|
-
knockout_round << '|Halbfinale|Semifinale|1/2 Finale'
|
69
|
-
knockout_round << '|Spiel um Platz 5'
|
70
|
-
knockout_round << '|Spiel um Platz 3'
|
71
|
-
knockout_round << '|Finale|Endspiel'
|
72
|
-
|
73
|
-
|
74
|
-
assert_equal group, lang.group
|
75
|
-
assert_equal round, lang.round
|
76
|
-
assert_equal knockout_round, lang.knockout_round
|
77
|
-
|
78
|
-
# NB: call twice to test caching with ||=
|
79
|
-
|
80
|
-
assert_equal group, lang.group
|
81
|
-
assert_equal round, lang.round
|
82
|
-
assert_equal knockout_round, lang.knockout_round
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_regex_knockout_round
|
86
|
-
lang = SportDb.lang
|
87
|
-
lang.lang = 'en'
|
88
|
-
|
89
|
-
lines = [
|
90
|
-
'(4) Quarter-finals',
|
91
|
-
'(5) Semi-finals',
|
92
|
-
'(6) Final',
|
93
|
-
'(1) Play-off 1st Leg // 11–15 October',
|
94
|
-
'(2) Play-off 2nd Leg // 15-19 November',
|
95
|
-
'(1) Play-off for quarter-finals',
|
96
|
-
'(4) Match for fifth place',
|
97
|
-
'(5) Match for third place',
|
98
|
-
## check for ALL UPCASE too
|
99
|
-
'(4) QUARTER-FINALS',
|
100
|
-
'(5) SEMI-FINALS',
|
101
|
-
'(6) FINAL'
|
102
|
-
]
|
103
|
-
|
104
|
-
lines.each do |line|
|
105
|
-
assert( line =~ lang.regex_knockout_round )
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_regex_knockout_round_de
|
111
|
-
lang = SportDb.lang
|
112
|
-
lang.lang = 'de'
|
113
|
-
|
114
|
-
lines = [
|
115
|
-
'(1) Achtelfinale // Di+Mi 14.+15. & 21.+22. Feb 2012',
|
116
|
-
'(2) Achtelfinale Rückspiele // Di+Mi 6.+7. & 13.+14. März 2012',
|
117
|
-
'(3) Viertelfinale // Di+Mi 27.+28. März 2012',
|
118
|
-
'(4) Viertelfinale Rückspiele // Di+Mi 3.+4. April 2012',
|
119
|
-
'(5) Halbfinale // Di+Mi 17.+18. April 2012',
|
120
|
-
'(6) Halbfinale Rückspiele // Di+Mi 24.+25. April 2012',
|
121
|
-
'(7) Finale // Sa 19. Mai 2012'
|
122
|
-
]
|
123
|
-
|
124
|
-
lines.each do |line|
|
125
|
-
assert( line =~ lang.regex_knockout_round )
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
end # class TestLang
|