sportdb-models 1.18.5 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +27 -145
  3. data/Rakefile +4 -5
  4. data/lib/sportdb/models.rb +93 -160
  5. data/lib/sportdb/{deleter.rb → models/deleter.rb} +4 -10
  6. data/lib/sportdb/models/formats.rb +23 -0
  7. data/lib/sportdb/models/models/assoc.rb +38 -0
  8. data/lib/sportdb/models/{badge.rb → models/badge.rb} +1 -1
  9. data/lib/sportdb/models/models/event.rb +55 -0
  10. data/lib/sportdb/models/{forward.rb → models/forward.rb} +3 -3
  11. data/lib/sportdb/models/{goal.rb → models/goal.rb} +1 -1
  12. data/lib/sportdb/models/models/ground.rb +16 -0
  13. data/lib/sportdb/models/{group.rb → models/group.rb} +10 -7
  14. data/lib/sportdb/models/models/league.rb +20 -0
  15. data/lib/sportdb/models/{roster.rb → models/lineup.rb} +3 -4
  16. data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
  17. data/lib/sportdb/models/{person.rb → models/person.rb} +0 -0
  18. data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
  19. data/lib/sportdb/models/{season.rb → models/season.rb} +2 -1
  20. data/lib/sportdb/models/{stage.rb → models/stage.rb} +9 -5
  21. data/lib/sportdb/models/{stats/alltime_standing_entry.rb → models/stats/alltime_standing.rb} +9 -1
  22. data/lib/sportdb/models/{stats/event_standing_entry.rb → models/stats/event_standing.rb} +11 -1
  23. data/lib/sportdb/models/{stats/group_standing_entry.rb → models/stats/group_standing.rb} +10 -1
  24. data/lib/sportdb/models/models/team.rb +56 -0
  25. data/lib/sportdb/models/{world → models/world}/city.rb +2 -2
  26. data/lib/sportdb/models/{world → models/world}/continent.rb +0 -0
  27. data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
  28. data/lib/sportdb/models/{world → models/world}/state.rb +0 -0
  29. data/lib/sportdb/{schema.rb → models/schema.rb} +165 -100
  30. data/lib/sportdb/models/stats.rb +23 -0
  31. data/lib/sportdb/models/utils.rb +24 -24
  32. data/lib/sportdb/{version.rb → models/version.rb} +12 -5
  33. data/test/helper.rb +10 -114
  34. data/test/test_changes.rb +38 -38
  35. data/test/test_cursor.rb +15 -15
  36. data/test/test_winner.rb +75 -70
  37. metadata +29 -161
  38. data/lib/sportdb/calc.rb +0 -279
  39. data/lib/sportdb/indexers/team.rb +0 -87
  40. data/lib/sportdb/mapper_teams.rb +0 -24
  41. data/lib/sportdb/matcher.rb +0 -31
  42. data/lib/sportdb/models/assoc.rb +0 -106
  43. data/lib/sportdb/models/assoc_assoc.rb +0 -15
  44. data/lib/sportdb/models/event.rb +0 -66
  45. data/lib/sportdb/models/event_ground.rb +0 -15
  46. data/lib/sportdb/models/event_team.rb +0 -16
  47. data/lib/sportdb/models/ground.rb +0 -100
  48. data/lib/sportdb/models/group_team.rb +0 -14
  49. data/lib/sportdb/models/league.rb +0 -83
  50. data/lib/sportdb/models/stage_team.rb +0 -14
  51. data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
  52. data/lib/sportdb/models/stats/event_standing.rb +0 -55
  53. data/lib/sportdb/models/stats/group_standing.rb +0 -50
  54. data/lib/sportdb/models/team.rb +0 -119
  55. data/lib/sportdb/models/team_compat.rb +0 -64
  56. data/lib/sportdb/patterns.rb +0 -37
  57. data/lib/sportdb/pretty_printer.rb +0 -175
  58. data/lib/sportdb/reader.rb +0 -132
  59. data/lib/sportdb/reader_file.rb +0 -131
  60. data/lib/sportdb/reader_zip.rb +0 -172
  61. data/lib/sportdb/readers/assoc.rb +0 -54
  62. data/lib/sportdb/readers/event.rb +0 -253
  63. data/lib/sportdb/readers/event_meta.rb +0 -133
  64. data/lib/sportdb/readers/event_table.rb +0 -196
  65. data/lib/sportdb/readers/game.rb +0 -912
  66. data/lib/sportdb/readers/ground.rb +0 -53
  67. data/lib/sportdb/readers/league.rb +0 -54
  68. data/lib/sportdb/readers/season.rb +0 -83
  69. data/lib/sportdb/readers/squad_club.rb +0 -201
  70. data/lib/sportdb/readers/squad_national_team.rb +0 -173
  71. data/lib/sportdb/readers/team.rb +0 -53
  72. data/lib/sportdb/rsssf_reader.rb +0 -367
  73. data/lib/sportdb/standings.rb +0 -178
  74. data/lib/sportdb/stats.rb +0 -27
  75. data/lib/sportdb/utils.rb +0 -89
  76. data/lib/sportdb/utils_date.rb +0 -26
  77. data/lib/sportdb/utils_goals.rb +0 -20
  78. data/lib/sportdb/utils_group.rb +0 -63
  79. data/lib/sportdb/utils_map.rb +0 -44
  80. data/lib/sportdb/utils_round.rb +0 -165
  81. data/lib/sportdb/utils_scores.rb +0 -17
  82. data/lib/sportdb/utils_teams.rb +0 -48
  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/2014_15/1-bundesliga-ii.txt +0 -158
  91. data/test/data/at-austria/2014_15/1-bundesliga.yml +0 -18
  92. data/test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt +0 -20
  93. data/test/data/at-austria/2015_16/1-bundesliga-v2.yml +0 -20
  94. data/test/data/at-austria/2015_16/1-bundesliga.conf.txt +0 -20
  95. data/test/data/at-austria/2015_16/1-bundesliga.yml +0 -24
  96. data/test/data/at-austria/2015_16/cup.yml +0 -77
  97. data/test/data/at-austria/leagues.txt +0 -11
  98. data/test/data/at-austria/teams.txt +0 -68
  99. data/test/data/at-austria/teams_2.txt +0 -21
  100. data/test/data/csv/de-2013-14--1-bundesliga.txt +0 -307
  101. data/test/data/de-deutschland/2013-14/1-bundesliga.yml +0 -26
  102. data/test/data/de-deutschland/leagues.txt +0 -4
  103. data/test/data/de-deutschland/teams.txt +0 -53
  104. data/test/data/eng-england/2015-16/1-premierleague-v2.yml +0 -2
  105. data/test/data/eng-england/2015-16/1-premierleague.yml +0 -5
  106. data/test/data/national-teams/assocs.txt +0 -231
  107. data/test/data/national-teams/europe/assocs.txt +0 -13
  108. data/test/data/national-teams/europe/teams.txt +0 -13
  109. data/test/data/national-teams/north-america/assocs.txt +0 -10
  110. data/test/data/national-teams/north-america/teams.txt +0 -7
  111. data/test/data/national-teams/teams.txt +0 -19
  112. data/test/data/players/europe/at-austria/players.txt +0 -45
  113. data/test/data/players/europe/de-deutschland/players.txt +0 -41
  114. data/test/data/players/south-america/br-brazil/players.txt +0 -51
  115. data/test/data/rsssf/at-2014-15--1-bundesliga.txt +0 -339
  116. data/test/data/rsssf/at-2015-16--1-bundesliga.txt +0 -18
  117. data/test/data/world-cup/1930/cup.txt +0 -71
  118. data/test/data/world-cup/1930/cup.yml +0 -23
  119. data/test/data/world-cup/1930/cup_goals.txt +0 -47
  120. data/test/data/world-cup/1930/cup_goals.yml +0 -23
  121. data/test/data/world-cup/1954/cup.txt +0 -90
  122. data/test/data/world-cup/1954/cup.yml +0 -30
  123. data/test/data/world-cup/1962/cup.txt +0 -86
  124. data/test/data/world-cup/1962/cup.yml +0 -32
  125. data/test/data/world-cup/1974/cup.yml +0 -35
  126. data/test/data/world-cup/1974/cup_finals.txt +0 -14
  127. data/test/data/world-cup/1974/cup_i.txt +0 -55
  128. data/test/data/world-cup/1974/cup_ii.txt +0 -34
  129. data/test/data/world-cup/2014/cup.txt +0 -5
  130. data/test/data/world-cup/2014/cup.yml +0 -54
  131. data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
  132. data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
  133. data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
  134. data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
  135. data/test/data/world-cup/leagues.txt +0 -5
  136. data/test/data/world-cup/seasons_1930.txt +0 -4
  137. data/test/data/world-cup/seasons_1954.txt +0 -4
  138. data/test/data/world-cup/seasons_1962.txt +0 -4
  139. data/test/data/world-cup/seasons_1974.txt +0 -5
  140. data/test/data/world-cup/teams_1930.txt +0 -26
  141. data/test/data/world-cup/teams_1954.txt +0 -30
  142. data/test/data/world-cup/teams_1962.txt +0 -29
  143. data/test/data/world-cup/teams_1974.txt +0 -29
  144. data/test/test_assoc_reader.rb +0 -199
  145. data/test/test_event_meta_reader.rb +0 -47
  146. data/test/test_event_reader.rb +0 -64
  147. data/test/test_event_table_reader.rb +0 -57
  148. data/test/test_goals.rb +0 -107
  149. data/test/test_indexer_team.rb +0 -34
  150. data/test/test_load.rb +0 -61
  151. data/test/test_pp.rb +0 -35
  152. data/test/test_reader.rb +0 -88
  153. data/test/test_reader_from_string.rb +0 -63
  154. data/test/test_round_auto.rb +0 -370
  155. data/test/test_round_def.rb +0 -109
  156. data/test/test_round_header.rb +0 -183
  157. data/test/test_rsssf_reader.rb +0 -76
  158. data/test/test_squad_club_reader.rb +0 -76
  159. data/test/test_squad_national_team_reader.rb +0 -116
  160. data/test/test_standings.rb +0 -279
  161. data/test/test_standings_ii.rb +0 -46
  162. data/test/test_utils.rb +0 -124
@@ -0,0 +1,23 @@
1
+
2
+ module SportDb
3
+
4
+ class Stats
5
+ include Models
6
+
7
+ def tables
8
+ puts " #{League.count} leagues / #{Season.count} seasons"
9
+ puts " #{Event.count} events (league+season recs) / #{Round.count} rounds / #{Group.count} groups / #{Stage.count} stages"
10
+ puts " #{Team.count} teams"
11
+ puts " #{Match.count} matches"
12
+ puts " #{Badge.count} badges"
13
+
14
+ puts " #{Lineup.count} lineups (person+team+event recs)"
15
+ puts " #{Goal.count} goals (person+match recs)"
16
+
17
+ puts " #{Assoc.count} assocs|orgs"
18
+ puts " #{Ground.count} grounds|stadiums"
19
+ end
20
+
21
+ end # class Stats
22
+
23
+ end # module SportDb
@@ -2,27 +2,27 @@ module SportDb
2
2
  module Model
3
3
 
4
4
 
5
- class GameCursor
5
+ class MatchCursor
6
6
 
7
- def initialize( games )
8
- @games = games
7
+ def initialize( matches )
8
+ @matches = matches
9
9
  end
10
10
 
11
11
  def each
12
- state = GameCursorState.new
12
+ state = MatchCursorState.new
13
13
 
14
- @games.each do |game|
15
- state.next( game )
16
- yield( game, state ) # e.g. lets you use state.new_date? or state.new_week? or state.new_year? etc.
14
+ @matches.each do |match|
15
+ state.next( match )
16
+ yield( match, state ) # e.g. lets you use state.new_date? or state.new_week? or state.new_year? etc.
17
17
  end
18
18
  end # method each
19
- end # class GameCursor
19
+ end # class MatchCursor
20
20
 
21
21
 
22
- class GameCursorState
22
+ class MatchCursorState
23
23
 
24
24
  def initialize
25
- @last_play_at = DateTime.new( 1971, 1, 1 )
25
+ @last_date = DateTime.new( 1971, 1, 1 )
26
26
  @new_date = true
27
27
  @new_year = true
28
28
  @new_week = true
@@ -34,44 +34,44 @@ class GameCursorState
34
34
  def new_date?() @new_date; end
35
35
  def new_year?() @new_year; end
36
36
  def new_week?() @new_week; end
37
-
37
+
38
38
 
39
39
  ## add new league ?
40
40
  ## add new round ?
41
41
  ## add new time ?
42
-
43
- def next( game )
42
+
43
+ def next( match )
44
44
  @index += 1 # zero-based index; start off with -1 (undefined/uninitialized)
45
- game_play_at = game.play_at # cache play_at value ref
45
+ match_date = match.date # cache date value ref
46
46
 
47
- if @last_play_at.year == game_play_at.year &&
48
- @last_play_at.month == game_play_at.month &&
49
- @last_play_at.day == game_play_at.day
47
+ if @last_date.year == match_date.year &&
48
+ @last_date.month == match_date.month &&
49
+ @last_date.day == match_date.day
50
50
  @new_date = false
51
51
  else
52
52
  @new_date = true
53
-
53
+
54
54
  # check for new_year
55
- if @last_play_at.year == game_play_at.year
55
+ if @last_date.year == match_date.year
56
56
  @new_year = false
57
57
  else
58
58
  @new_year = true
59
59
  end
60
-
60
+
61
61
  # check for new_week
62
62
  # -- todo: find a method for week number; do NOT use strftime; there must be something easier
63
63
  # -- check if activesupport adds .week or similar ??? use it if it exists
64
- if @last_play_at.strftime('%V') == game_play_at.strftime('%V')
64
+ if @last_date.strftime('%V') == match_date.strftime('%V')
65
65
  @new_week = false
66
66
  else
67
67
  @new_week = true
68
68
  end
69
69
  end
70
70
 
71
- @last_play_at = game.play_at
71
+ @last_date = match.date
72
72
  end # method next
73
-
74
- end # class GameCursorState
73
+
74
+ end # class MatchCursorState
75
75
 
76
76
 
77
77
  end # module Model
@@ -1,10 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module SportDb
4
-
5
- MAJOR = 1 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 18
7
- PATCH = 5
4
+ module Module
5
+ module Models
6
+ MAJOR = 2
7
+ MINOR = 0
8
+ PATCH = 1
8
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
10
 
10
11
  def self.version
@@ -16,7 +17,13 @@ module SportDb
16
17
  end
17
18
 
18
19
  def self.root
19
- "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
20
+ "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
20
21
  end
21
22
 
23
+ end # module Models
24
+ end # module Module
25
+
26
+ #################
27
+ ## add convenience shortcuts
28
+ VERSION = Module::Models::VERSION
22
29
  end # module SportDb
@@ -1,13 +1,8 @@
1
-
2
- ## $:.unshift(File.dirname(__FILE__))
3
-
4
1
  ## minitest setup
5
-
6
2
  require 'minitest/autorun'
7
3
 
8
4
 
9
5
  ## our own code
10
-
11
6
  require 'sportdb/models'
12
7
 
13
8
 
@@ -22,15 +17,15 @@ League = SportDb::Model::League
22
17
  Season = SportDb::Model::Season
23
18
  Event = SportDb::Model::Event
24
19
  Team = SportDb::Model::Team
25
- Roster = SportDb::Model::Roster
20
+ Lineup = SportDb::Model::Lineup
26
21
  Assoc = SportDb::Model::Assoc
27
22
  AssocAssoc = SportDb::Model::AssocAssoc
28
23
 
29
- Round = SportDb::Model::Round
30
- Group = SportDb::Model::Group
31
- Stage = SportDb::Model::Stage
32
- Game = SportDb::Model::Game
33
- GameCursor = SportDb::Model::GameCursor
24
+ Round = SportDb::Model::Round
25
+ Group = SportDb::Model::Group
26
+ Stage = SportDb::Model::Stage
27
+ Match = SportDb::Model::Match
28
+ MatchCursor = SportDb::Model::MatchCursor
34
29
 
35
30
 
36
31
  EventStanding = SportDb::Model::EventStanding
@@ -41,110 +36,11 @@ AlltimeStanding = SportDb::Model::AlltimeStanding
41
36
  AlltimeStandingEntry = SportDb::Model::AlltimeStandingEntry
42
37
 
43
38
 
44
-
45
- ####################
46
- # Reader shortcuts
47
-
48
- Reader = SportDb::Reader
49
- TeamReader = SportDb::TeamReader
50
- TeamIndexer = SportDb::TeamIndexer
51
- AssocReader = SportDb::AssocReader
52
- SeasonReader = SportDb::SeasonReader
53
- LeagueReader = SportDb::LeagueReader
54
- EventReader = SportDb::EventReader
55
- EventMetaReader = SportDb::EventMetaReader
56
- EventTableReader = SportDb::EventTableReader
57
- GameReader = SportDb::GameReader
58
- NationalTeamSquadReader = SportDb::NationalTeamSquadReader
59
- ClubSquadReader = SportDb::ClubSquadReader
60
-
61
- ## moved to racing.db - remove/delete!!
62
- ## RaceTeamReader = SportDb::RaceTeamReader
63
-
64
- PersonReader = PersonDb::PersonReader
65
-
66
- ######
67
- # New Reader ShortCuts
68
-
69
- module TestPrettyPrinter
70
- def self.from_file( name, opts={} )
71
- SportDb::PrettyPrinter.from_file( "#{SportDb.test_data_path}/#{name}.txt", opts )
72
- end
73
- end
74
-
75
-
76
- module TestTeamReader
77
- def self.from_file( name, more_attribs={} )
78
- TeamReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
79
- end
80
- end
81
-
82
- module TestTeamIndexer
83
- def self.from_file( name, more_attribs={} )
84
- TeamIndexer.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
85
- end
86
- end
87
-
88
-
89
- module TestClubSquadReader
90
- def self.from_file( name, more_attribs={} )
91
- ClubSquadReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
92
- end
93
- end
94
-
95
- module TestNationalTeamSquadReader
96
- def self.from_file( name, more_attribs={} )
97
- NationalTeamSquadReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
98
- end
99
- end
100
-
101
- module TestLeagueReader
102
- def self.from_file( name, more_attribs={} )
103
- LeagueReader.from_file( "#{SportDb.test_data_path}/#{name}.txt", more_attribs )
104
- end
105
- end
106
-
107
- module TestSeasonReader
108
- def self.from_file( name )
109
- SeasonReader.from_file( "#{SportDb.test_data_path}/#{name}.txt" )
110
- end
111
- end
112
-
113
- module TestEventReader
114
- def self.from_file( name )
115
- EventReader.from_file( "#{SportDb.test_data_path}/#{name}.yml" )
116
- end
117
- end
118
-
119
- module TestEventMetaReader
120
- def self.from_file( name )
121
- EventMetaReader.from_file( "#{SportDb.test_data_path}/#{name}.yml" )
122
- end
123
- end
124
-
125
- module TestEventTableReader
126
- def self.from_file( name )
127
- EventTableReader.from_file( "#{SportDb.test_data_path}/#{name}.txt" )
128
- end
129
- end
130
-
131
-
132
- module TestGameReader
133
- ## NOTE: pass in .yml as path (that is, event config!!!!)
134
- def self.from_file( name, more_attribs={} )
135
- GameReader.from_file( "#{SportDb.test_data_path}/#{name}.yml", more_attribs )
136
- end
137
- end
138
-
139
- module TestAssocReader
140
- def self.from_file( name )
141
- AssocReader.from_file( "#{SportDb.test_data_path}/#{name}.txt" )
142
- end
143
- end
144
-
145
-
146
-
147
39
  #################################
148
40
  # setup db -> schema / tables
149
41
 
150
42
  SportDb.setup_in_memory_db
43
+
44
+ ## test helpers here
45
+ SportDb.delete!
46
+ SportDb.tables
@@ -8,18 +8,18 @@ require 'helper'
8
8
 
9
9
  class TestChanges < MiniTest::Test
10
10
 
11
- def test_scores
12
- game1 = Game.new
13
- game1.score1 = 1
14
- game1.score2 = 2
15
-
16
- game2 = Game.new
17
- game2.score1 = 1
18
- game2.score2 = 1
19
- game2.score1p = 5
20
- game2.score2p = 3
21
-
22
- game_attribs = {
11
+ def test_score
12
+ match1 = Match.new
13
+ match1.score1 = 1
14
+ match1.score2 = 2
15
+
16
+ match2 = Match.new
17
+ match2.score1 = 1
18
+ match2.score2 = 1
19
+ match2.score1p = 5
20
+ match2.score2p = 3
21
+
22
+ match_attribs = {
23
23
  score1: 1,
24
24
  score2: 2,
25
25
  score1et: nil,
@@ -28,50 +28,50 @@ class TestChanges < MiniTest::Test
28
28
  score2p: nil
29
29
  }
30
30
 
31
- assert_equal false, game1.check_for_changes( game_attribs )
32
- assert_equal true, game2.check_for_changes( game_attribs )
31
+ assert_equal false, match1.check_for_changes( match_attribs )
32
+ assert_equal true, match2.check_for_changes( match_attribs )
33
33
  end
34
34
 
35
- def test_play_at
36
- game1 = Game.new
37
- game1.score1 = 1
38
- game1.score2 = 2
39
- game1.play_at = DateTime.new( 2012, 11, 5 )
35
+ def test_date
36
+ match1 = Match.new
37
+ match1.score1 = 1
38
+ match1.score2 = 2
39
+ match1.date = Date.new( 2012, 11, 5 )
40
40
 
41
- game2 = Game.new
42
- game2.score1 = 1
43
- game2.score2 = 2
44
- game2.play_at = DateTime.new( 2012, 12, 24 )
41
+ match2 = Match.new
42
+ match2.score1 = 1
43
+ match2.score2 = 2
44
+ match2.date = DateTime.new( 2012, 12, 24 )
45
45
 
46
- game_attribs = {
46
+ match_attribs = {
47
47
  score1: 1,
48
48
  score2: 2,
49
- play_at: DateTime.new( 2012, 11, 5 )
49
+ date: DateTime.new( 2012, 11, 5 )
50
50
  }
51
51
 
52
- assert_equal false, game1.check_for_changes( game_attribs )
53
- assert_equal true, game2.check_for_changes( game_attribs )
52
+ assert_equal false, match1.check_for_changes( match_attribs )
53
+ assert_equal true, match2.check_for_changes( match_attribs )
54
54
  end
55
55
 
56
56
  def test_group_id
57
- game1 = Game.new
58
- game1.score1 = 1
59
- game1.score2 = 2
60
- game1.group_id = 1
57
+ match1 = Match.new
58
+ match1.score1 = 1
59
+ match1.score2 = 2
60
+ match1.group_id = 1
61
61
 
62
- game2 = Game.new
63
- game2.score1 = 1
64
- game2.score2 = 2
65
- game2.group_id = 2
62
+ match2 = Match.new
63
+ match2.score1 = 1
64
+ match2.score2 = 2
65
+ match2.group_id = 2
66
66
 
67
- game_attribs = {
67
+ match_attribs = {
68
68
  score1: 1,
69
69
  score2: 2,
70
70
  group_id: 1
71
71
  }
72
72
 
73
- assert_equal false, game1.check_for_changes( game_attribs )
74
- assert_equal true, game2.check_for_changes( game_attribs )
73
+ assert_equal false, match1.check_for_changes( match_attribs )
74
+ assert_equal true, match2.check_for_changes( match_attribs )
75
75
  end
76
76
 
77
77
 
@@ -9,42 +9,42 @@ require 'helper'
9
9
 
10
10
  class TestCursor < MiniTest::Test
11
11
 
12
- def test_games
13
- games = []
12
+ def test_matches
13
+ matches = []
14
14
 
15
- games << Game.new( score1: 3, score2: 1, play_at: DateTime.new(2013, 8, 9) )
16
- games << Game.new( score1: 1, score2: 3, play_at: DateTime.new(2013, 8, 10) )
17
- games << Game.new( score1: 2, score2: 0, play_at: DateTime.new(2013, 8, 10) )
18
- games << Game.new( score1: 3, score2: 2, play_at: DateTime.new(2013, 8, 12) ) # new_week
15
+ matches << Match.new( score1: 3, score2: 1, date: Date.new(2013, 8, 9) )
16
+ matches << Match.new( score1: 1, score2: 3, date: Date.new(2013, 8, 10) )
17
+ matches << Match.new( score1: 2, score2: 0, date: Date.new(2013, 8, 10) )
18
+ matches << Match.new( score1: 3, score2: 2, date: Date.new(2013, 8, 12) ) # new_week
19
19
 
20
- GameCursor.new( games ).each do |game,state|
20
+ MatchCursor.new( matches ).each do |match,state|
21
21
  if state.index == 0
22
- assert_equal 3, game.score1
23
- assert_equal 1, game.score2
22
+ assert_equal 3, match.score1
23
+ assert_equal 1, match.score2
24
24
  assert_equal true, state.new_date?
25
25
  assert_equal true, state.new_year?
26
26
  assert_equal true, state.new_week?
27
27
  end
28
28
 
29
29
  if state.index == 1
30
- assert_equal 1, game.score1
31
- assert_equal 3, game.score2
30
+ assert_equal 1, match.score1
31
+ assert_equal 3, match.score2
32
32
  assert_equal true, state.new_date?
33
33
  assert_equal false, state.new_year?
34
34
  assert_equal false, state.new_week?
35
35
  end
36
36
 
37
37
  if state.index == 2
38
- assert_equal 2, game.score1
39
- assert_equal 0, game.score2
38
+ assert_equal 2, match.score1
39
+ assert_equal 0, match.score2
40
40
  assert_equal false, state.new_date?
41
41
  assert_equal false, state.new_year?
42
42
  assert_equal false, state.new_week?
43
43
  end
44
44
 
45
45
  if state.index == 3
46
- assert_equal 3, game.score1
47
- assert_equal 2, game.score2
46
+ assert_equal 3, match.score1
47
+ assert_equal 2, match.score2
48
48
  assert_equal true, state.new_date?
49
49
  assert_equal true, state.new_week?
50
50
  assert_equal false, state.new_year?