sportdb-models 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/HISTORY.md +21 -0
  4. data/Manifest.txt +142 -0
  5. data/README.md +28 -0
  6. data/Rakefile +59 -0
  7. data/config/fixtures/de.yml +46 -0
  8. data/config/fixtures/en.yml +54 -0
  9. data/config/fixtures/es.yml +48 -0
  10. data/config/fixtures/fr.yml +53 -0
  11. data/config/fixtures/it.yml +55 -0
  12. data/config/fixtures/pt.yml +46 -0
  13. data/config/fixtures/ro.yml +55 -0
  14. data/data/seasons.txt +74 -0
  15. data/data/setups/all.txt +5 -0
  16. data/lib/sportdb/calc.rb +279 -0
  17. data/lib/sportdb/deleter.rb +52 -0
  18. data/lib/sportdb/finders/date.rb +374 -0
  19. data/lib/sportdb/finders/goals.rb +260 -0
  20. data/lib/sportdb/finders/scores.rb +122 -0
  21. data/lib/sportdb/lang.rb +216 -0
  22. data/lib/sportdb/matcher.rb +31 -0
  23. data/lib/sportdb/models.rb +259 -0
  24. data/lib/sportdb/models/assoc.rb +106 -0
  25. data/lib/sportdb/models/assoc_assoc.rb +15 -0
  26. data/lib/sportdb/models/badge.rb +14 -0
  27. data/lib/sportdb/models/event.rb +65 -0
  28. data/lib/sportdb/models/event_ground.rb +15 -0
  29. data/lib/sportdb/models/event_team.rb +16 -0
  30. data/lib/sportdb/models/forward.rb +55 -0
  31. data/lib/sportdb/models/game.rb +244 -0
  32. data/lib/sportdb/models/goal.rb +15 -0
  33. data/lib/sportdb/models/ground.rb +100 -0
  34. data/lib/sportdb/models/group.rb +23 -0
  35. data/lib/sportdb/models/group_team.rb +14 -0
  36. data/lib/sportdb/models/league.rb +83 -0
  37. data/lib/sportdb/models/person.rb +21 -0
  38. data/lib/sportdb/models/roster.rb +18 -0
  39. data/lib/sportdb/models/round.rb +22 -0
  40. data/lib/sportdb/models/season.rb +14 -0
  41. data/lib/sportdb/models/stats/alltime_standing.rb +44 -0
  42. data/lib/sportdb/models/stats/alltime_standing_entry.rb +23 -0
  43. data/lib/sportdb/models/stats/event_standing.rb +55 -0
  44. data/lib/sportdb/models/stats/event_standing_entry.rb +21 -0
  45. data/lib/sportdb/models/stats/group_standing.rb +50 -0
  46. data/lib/sportdb/models/stats/group_standing_entry.rb +22 -0
  47. data/lib/sportdb/models/team.rb +119 -0
  48. data/lib/sportdb/models/team_comp.rb +64 -0
  49. data/lib/sportdb/models/utils.rb +78 -0
  50. data/lib/sportdb/models/world/city.rb +21 -0
  51. data/lib/sportdb/models/world/continent.rb +20 -0
  52. data/lib/sportdb/models/world/country.rb +19 -0
  53. data/lib/sportdb/models/world/region.rb +19 -0
  54. data/lib/sportdb/patterns.rb +38 -0
  55. data/lib/sportdb/reader.rb +130 -0
  56. data/lib/sportdb/reader_file.rb +123 -0
  57. data/lib/sportdb/reader_zip.rb +165 -0
  58. data/lib/sportdb/readers/assoc.rb +54 -0
  59. data/lib/sportdb/readers/event.rb +200 -0
  60. data/lib/sportdb/readers/game.rb +877 -0
  61. data/lib/sportdb/readers/ground.rb +53 -0
  62. data/lib/sportdb/readers/league.rb +54 -0
  63. data/lib/sportdb/readers/season.rb +83 -0
  64. data/lib/sportdb/readers/squad_club.rb +201 -0
  65. data/lib/sportdb/readers/squad_national_team.rb +173 -0
  66. data/lib/sportdb/readers/team.rb +53 -0
  67. data/lib/sportdb/schema.rb +373 -0
  68. data/lib/sportdb/standings.rb +178 -0
  69. data/lib/sportdb/stats.rb +27 -0
  70. data/lib/sportdb/utils.rb +89 -0
  71. data/lib/sportdb/utils_date.rb +26 -0
  72. data/lib/sportdb/utils_goals.rb +20 -0
  73. data/lib/sportdb/utils_group.rb +63 -0
  74. data/lib/sportdb/utils_map.rb +44 -0
  75. data/lib/sportdb/utils_round.rb +165 -0
  76. data/lib/sportdb/utils_scores.rb +17 -0
  77. data/lib/sportdb/utils_teams.rb +43 -0
  78. data/lib/sportdb/version.rb +23 -0
  79. data/test/data/at-austria/2013_14/bl.txt +227 -0
  80. data/test/data/at-austria/2013_14/bl.yml +30 -0
  81. data/test/data/at-austria/2013_14/bl_ii.txt +154 -0
  82. data/test/data/at-austria/2013_14/el.txt +4 -0
  83. data/test/data/at-austria/2013_14/el.yml +25 -0
  84. data/test/data/at-austria/2013_14/squads/austria.txt +40 -0
  85. data/test/data/at-austria/2013_14/squads/salzburg.txt +35 -0
  86. data/test/data/at-austria/leagues.txt +11 -0
  87. data/test/data/at-austria/teams.txt +75 -0
  88. data/test/data/at-austria/teams_2.txt +34 -0
  89. data/test/data/national-teams/assocs.txt +231 -0
  90. data/test/data/national-teams/europe/assocs.txt +13 -0
  91. data/test/data/national-teams/europe/teams.txt +13 -0
  92. data/test/data/national-teams/north-america/assocs.txt +10 -0
  93. data/test/data/national-teams/north-america/teams.txt +7 -0
  94. data/test/data/national-teams/teams.txt +19 -0
  95. data/test/data/players/europe/at-austria/players.txt +45 -0
  96. data/test/data/players/europe/de-deutschland/players.txt +41 -0
  97. data/test/data/players/south-america/br-brazil/players.txt +51 -0
  98. data/test/data/world-cup/1930/cup.txt +71 -0
  99. data/test/data/world-cup/1930/cup.yml +23 -0
  100. data/test/data/world-cup/1930/cup_goals.txt +47 -0
  101. data/test/data/world-cup/1930/cup_goals.yml +23 -0
  102. data/test/data/world-cup/1954/cup.txt +90 -0
  103. data/test/data/world-cup/1954/cup.yml +30 -0
  104. data/test/data/world-cup/1962/cup.txt +86 -0
  105. data/test/data/world-cup/1962/cup.yml +32 -0
  106. data/test/data/world-cup/1974/cup.yml +35 -0
  107. data/test/data/world-cup/1974/cup_finals.txt +14 -0
  108. data/test/data/world-cup/1974/cup_i.txt +55 -0
  109. data/test/data/world-cup/1974/cup_ii.txt +34 -0
  110. data/test/data/world-cup/2014/cup.txt +5 -0
  111. data/test/data/world-cup/2014/cup.yml +54 -0
  112. data/test/data/world-cup/2014/squads/br-brazil.txt +46 -0
  113. data/test/data/world-cup/2014/squads/de-deutschland.txt +8 -0
  114. data/test/data/world-cup/2014/squads/jp-japan.txt +30 -0
  115. data/test/data/world-cup/2014/squads/uy-uruguay.txt +32 -0
  116. data/test/data/world-cup/leagues.txt +5 -0
  117. data/test/data/world-cup/seasons_1930.txt +4 -0
  118. data/test/data/world-cup/seasons_1954.txt +4 -0
  119. data/test/data/world-cup/seasons_1962.txt +4 -0
  120. data/test/data/world-cup/seasons_1974.txt +5 -0
  121. data/test/data/world-cup/teams_1930.txt +26 -0
  122. data/test/data/world-cup/teams_1954.txt +30 -0
  123. data/test/data/world-cup/teams_1962.txt +29 -0
  124. data/test/data/world-cup/teams_1974.txt +29 -0
  125. data/test/helper.rb +120 -0
  126. data/test/test_assoc_reader.rb +201 -0
  127. data/test/test_changes.rb +74 -0
  128. data/test/test_cursor.rb +50 -0
  129. data/test/test_date.rb +100 -0
  130. data/test/test_goals.rb +109 -0
  131. data/test/test_lang.rb +130 -0
  132. data/test/test_load.rb +61 -0
  133. data/test/test_reader.rb +88 -0
  134. data/test/test_reader_from_string.rb +65 -0
  135. data/test/test_round_auto.rb +370 -0
  136. data/test/test_round_def.rb +109 -0
  137. data/test/test_round_header.rb +183 -0
  138. data/test/test_scores.rb +70 -0
  139. data/test/test_squad_club_reader.rb +76 -0
  140. data/test/test_squad_national_team_reader.rb +116 -0
  141. data/test/test_standings.rb +279 -0
  142. data/test/test_standings_ii.rb +46 -0
  143. data/test/test_utils.rb +124 -0
  144. data/test/test_winner.rb +95 -0
  145. metadata +378 -0
@@ -0,0 +1,74 @@
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
@@ -0,0 +1,50 @@
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 ADDED
@@ -0,0 +1,100 @@
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
@@ -0,0 +1,109 @@
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 ADDED
@@ -0,0 +1,130 @@
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