sportdb-models 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +2 -0
- data/Manifest.txt +0 -4
- data/README.md +6 -9
- data/Rakefile +1 -1
- data/lib/sportdb/models/models/lineup.rb +4 -1
- data/lib/sportdb/models/models/team.rb +3 -2
- data/lib/sportdb/models/schema.rb +6 -1
- data/lib/sportdb/models/version.rb +4 -7
- data/lib/sportdb/models.rb +104 -43
- metadata +16 -15
- data/test/helper.rb +0 -46
- data/test/test_changes.rb +0 -78
- data/test/test_cursor.rb +0 -55
- data/test/test_winner.rb +0 -100
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4f4d65007750a5f87beb091e967c48e761908b79f736d8a919b165c8d8657616
|
4
|
+
data.tar.gz: 8ab5b00ce91188d10bbb8e915f0e6f3469d84ddb62528c47b6436db1eddbacf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d315bc6659797ce8c9afc9bb0feedb8ac14e25766eb65caedf36da082666bc0f284f0def80d62fa8b04e3789bb7f7caecd6859ca38bed607e82ffcf6a70309bf
|
7
|
+
data.tar.gz: c0216968600f67c288576b73efbcce26706a949ffa8e4822d74541a904ba797a55f82a4ad604d86acf5c86806f4d4204a0b1af2d0b8ae15e840c0df050ee4228
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# sportdb-models gem - sport.db schema 'n' models for easy (re)use
|
2
2
|
|
3
|
-
|
4
|
-
[![Build Status](https://secure.travis-ci.org/geraldb/sport.db.ruby.png?branch=master)](http://travis-ci.org/geraldb/sport.db.ruby)
|
5
|
-
-->
|
3
|
+
|
6
4
|
|
7
5
|
* home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
|
8
6
|
* bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
|
9
7
|
* gem :: [rubygems.org/gems/sportdb-models](https://rubygems.org/gems/sportdb-models)
|
10
8
|
* rdoc :: [rubydoc.info/gems/sportdb-models](http://rubydoc.info/gems/sportdb-models)
|
11
|
-
|
9
|
+
|
12
10
|
|
13
11
|
|
14
12
|
## Usage Models
|
@@ -18,14 +16,13 @@
|
|
18
16
|
|
19
17
|
## License
|
20
18
|
|
21
|
-
![](https://publicdomainworks.github.io/buttons/zero88x31.png)
|
22
|
-
|
23
19
|
The `sportdb-models` scripts are dedicated to the public domain.
|
24
20
|
Use it as you please with no restrictions whatsoever.
|
25
21
|
|
26
22
|
|
27
23
|
## Questions? Comments?
|
28
24
|
|
29
|
-
|
30
|
-
[
|
31
|
-
|
25
|
+
Yes, you can. More than welcome.
|
26
|
+
See [Help & Support »](https://github.com/openfootball/help)
|
27
|
+
|
28
|
+
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ Hoe.spec 'sportdb-models' do
|
|
9
9
|
self.summary = "sportdb-models - sport.db schema 'n' models for easy (re)use"
|
10
10
|
self.description = summary
|
11
11
|
|
12
|
-
self.urls =
|
12
|
+
self.urls = { home: 'https://github.com/sportdb/sport.db' }
|
13
13
|
|
14
14
|
self.author = 'Gerald Bauer'
|
15
15
|
self.email = 'opensport@googlegroups.com'
|
@@ -2,7 +2,10 @@
|
|
2
2
|
module SportDb
|
3
3
|
module Model
|
4
4
|
|
5
|
-
### use Squad for name
|
5
|
+
### todo/fix - yes, use Squad for name
|
6
|
+
### use lineup table for match (specific) players lineup/formation
|
7
|
+
## NOT league (all season) squad !!!!!
|
8
|
+
|
6
9
|
|
7
10
|
class Lineup < ActiveRecord::Base
|
8
11
|
|
@@ -16,8 +16,9 @@ class Team < ActiveRecord::Base
|
|
16
16
|
has_many :home_matches, class_name: 'Match', foreign_key: 'team1_id'
|
17
17
|
has_many :away_matches, class_name: 'Match', foreign_key: 'team2_id'
|
18
18
|
|
19
|
-
|
20
|
-
validates :
|
19
|
+
## note: for now allow any key and code
|
20
|
+
## validates :key, format: { with: TEAM_KEY_RE, message: TEAM_KEY_MESSAGE }
|
21
|
+
## validates :code, format: { with: TEAM_CODE_RE, message: TEAM_CODE_MESSAGE }, allow_nil: true
|
21
22
|
|
22
23
|
has_many :event_teams, class_name: 'EventTeam' # join table (events+teams)
|
23
24
|
has_many :events, :through => :event_teams
|
@@ -208,8 +208,13 @@ create_table :matches do |t|
|
|
208
208
|
|
209
209
|
|
210
210
|
t.date :date # optional play date - todo/fix: split into play_date AND play_time!!!
|
211
|
-
|
211
|
+
## note: activerecord(rails) will auto-add date (2000-01-01) to hours/time!!!
|
212
|
+
## work around - save a string type!!!!
|
213
|
+
## e.g. 19:00 etc.
|
214
|
+
## t.time :time
|
215
|
+
t.string :time
|
212
216
|
|
217
|
+
|
213
218
|
t.boolean :postponed, null: false, default: false
|
214
219
|
## t.date :date2 # optional old date (when postponed)
|
215
220
|
## t.date :date3 # optional old date (when postponed twice)
|
@@ -1,11 +1,9 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module SportDb
|
4
2
|
module Module
|
5
3
|
module Models
|
6
4
|
MAJOR = 2
|
7
|
-
MINOR =
|
8
|
-
PATCH =
|
5
|
+
MINOR = 1
|
6
|
+
PATCH = 0
|
9
7
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
10
8
|
|
11
9
|
def self.version
|
@@ -13,13 +11,12 @@ module Models
|
|
13
11
|
end
|
14
12
|
|
15
13
|
def self.banner
|
16
|
-
"sportdb-models/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
14
|
+
"sportdb-models/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
|
17
15
|
end
|
18
16
|
|
19
17
|
def self.root
|
20
|
-
|
18
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )
|
21
19
|
end
|
22
|
-
|
23
20
|
end # module Models
|
24
21
|
end # module Module
|
25
22
|
|
data/lib/sportdb/models.rb
CHANGED
@@ -1,48 +1,45 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
1
|
# core and stlibs (note: get included via worlddb-models gem; see worlddb-models gem/lib)
|
5
2
|
require 'worlddb/models' # NOTE: include worlddb-models gem (not cli tools gem, that is, worlddb)
|
6
3
|
require 'persondb/models'
|
7
4
|
|
8
5
|
|
9
6
|
# our own code
|
7
|
+
require_relative 'models/version' # let version always go first
|
10
8
|
|
11
|
-
|
9
|
+
require_relative 'models/formats'
|
10
|
+
require_relative 'models/models/forward'
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
require_relative 'models/models/world/city'
|
13
|
+
require_relative 'models/models/world/country'
|
14
|
+
require_relative 'models/models/world/continent'
|
15
|
+
require_relative 'models/models/world/state'
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
require_relative 'models/models/assoc'
|
18
|
+
require_relative 'models/models/badge'
|
19
|
+
require_relative 'models/models/event'
|
20
|
+
require_relative 'models/models/goal'
|
21
|
+
require_relative 'models/models/ground'
|
22
|
+
require_relative 'models/models/group'
|
23
|
+
require_relative 'models/models/league'
|
24
|
+
require_relative 'models/models/lineup'
|
25
|
+
require_relative 'models/models/match'
|
26
|
+
require_relative 'models/models/person'
|
27
|
+
require_relative 'models/models/round'
|
28
|
+
require_relative 'models/models/season'
|
29
|
+
require_relative 'models/models/stage'
|
30
|
+
require_relative 'models/models/team'
|
20
31
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
require 'sportdb/models/models/goal'
|
25
|
-
require 'sportdb/models/models/ground'
|
26
|
-
require 'sportdb/models/models/group'
|
27
|
-
require 'sportdb/models/models/league'
|
28
|
-
require 'sportdb/models/models/lineup'
|
29
|
-
require 'sportdb/models/models/match'
|
30
|
-
require 'sportdb/models/models/person'
|
31
|
-
require 'sportdb/models/models/round'
|
32
|
-
require 'sportdb/models/models/season'
|
33
|
-
require 'sportdb/models/models/stage'
|
34
|
-
require 'sportdb/models/models/team'
|
32
|
+
require_relative 'models/models/stats/alltime_standing'
|
33
|
+
require_relative 'models/models/stats/event_standing'
|
34
|
+
require_relative 'models/models/stats/group_standing'
|
35
35
|
|
36
|
-
|
37
|
-
require 'sportdb/models/models/stats/event_standing'
|
38
|
-
require 'sportdb/models/models/stats/group_standing'
|
36
|
+
require_relative 'models/schema' # note: requires sportdb/models (include SportDB::Models)
|
39
37
|
|
40
|
-
|
38
|
+
require_relative 'models/utils' # e.g. MatchCursor
|
41
39
|
|
42
|
-
|
40
|
+
require_relative 'models/deleter'
|
41
|
+
require_relative 'models/stats'
|
43
42
|
|
44
|
-
require 'sportdb/models/deleter'
|
45
|
-
require 'sportdb/models/stats'
|
46
43
|
|
47
44
|
|
48
45
|
module SportDb
|
@@ -62,6 +59,38 @@ module SportDb
|
|
62
59
|
SportDb.create
|
63
60
|
end
|
64
61
|
|
62
|
+
def self.auto_migrate!
|
63
|
+
### todo/fix:
|
64
|
+
## check props table and versions!!!!!
|
65
|
+
|
66
|
+
# first time? - auto-run db migratation, that is, create db tables
|
67
|
+
unless LogDb::Model::Log.table_exists?
|
68
|
+
LogDb.create # add logs table
|
69
|
+
end
|
70
|
+
|
71
|
+
unless ConfDb::Model::Prop.table_exists?
|
72
|
+
ConfDb.create # add props table
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
unless TagDb::Model::Tag.table_exists?
|
77
|
+
TagDb.create # add tags & taggings tables
|
78
|
+
end
|
79
|
+
|
80
|
+
unless WorldDb::Model::Place.table_exists?
|
81
|
+
WorldDb.create # add places, & co. tables
|
82
|
+
end
|
83
|
+
|
84
|
+
unless PersonDb::Model::Person.table_exists?
|
85
|
+
PersonDb.create # add persons table
|
86
|
+
end
|
87
|
+
|
88
|
+
unless SportDb::Model::League.table_exists?
|
89
|
+
SportDb.create
|
90
|
+
end
|
91
|
+
end # method auto_migrate!
|
92
|
+
|
93
|
+
|
65
94
|
# delete ALL records (use with care!)
|
66
95
|
def self.delete!
|
67
96
|
puts '*** deleting sport table records/data...'
|
@@ -74,8 +103,14 @@ module SportDb
|
|
74
103
|
end
|
75
104
|
|
76
105
|
|
77
|
-
|
106
|
+
### use/change to **config - to allow "inline" conif with keywords
|
107
|
+
## (without enclosing {}) - why? why not?
|
108
|
+
def self.connect!( config={} ) # convenience shortcut w/ automigrate
|
109
|
+
connect( config )
|
110
|
+
auto_migrate!
|
111
|
+
end
|
78
112
|
|
113
|
+
def self.connect( config={} )
|
79
114
|
if config.empty?
|
80
115
|
puts "ENV['DATBASE_URL'] - >#{ENV['DATABASE_URL']}<"
|
81
116
|
|
@@ -132,19 +167,43 @@ module SportDb
|
|
132
167
|
end
|
133
168
|
|
134
169
|
|
170
|
+
|
171
|
+
def self.open( path ) ## shortcut for sqlite only
|
172
|
+
config = {
|
173
|
+
adapter: 'sqlite3',
|
174
|
+
database: path # e.g. ':memory', './sport.db'
|
175
|
+
}
|
176
|
+
connect!( config )
|
177
|
+
end
|
178
|
+
|
135
179
|
def self.setup_in_memory_db
|
136
180
|
# Database Setup & Config
|
137
|
-
|
181
|
+
## add logger as option - why? why not?
|
182
|
+
## e.g. open_mem( logger: true ) or
|
183
|
+
## always possible to add logger "manually" before
|
184
|
+
## thus, no need for option/flag really ??
|
185
|
+
## ActiveRecord::Base.logger = Logger.new( STDOUT )
|
138
186
|
## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
|
139
|
-
|
140
|
-
|
141
|
-
|
187
|
+
|
188
|
+
config = {
|
189
|
+
adapter: 'sqlite3',
|
190
|
+
database: ':memory:'
|
191
|
+
}
|
192
|
+
connect( config )
|
142
193
|
|
143
194
|
## build schema
|
144
195
|
create_all
|
145
196
|
end # setup_in_memory_db (using SQLite :memory:)
|
146
197
|
|
147
198
|
|
199
|
+
###########
|
200
|
+
# add more aliases/alt names for in memory db - why? why not?
|
201
|
+
## rename to open_mem for canonical name - why? why not?
|
202
|
+
class << self
|
203
|
+
alias_method :open_mem, :setup_in_memory_db
|
204
|
+
alias_method :open_memory, :setup_in_memory_db
|
205
|
+
alias_method :open_in_memory, :setup_in_memory_db
|
206
|
+
end
|
148
207
|
end # module SportDb
|
149
208
|
|
150
209
|
|
@@ -155,17 +214,19 @@ module SportDb
|
|
155
214
|
# add alias why? why not?
|
156
215
|
#
|
157
216
|
# more aliases to consider:
|
158
|
-
# -
|
159
|
-
# -
|
160
|
-
#
|
161
|
-
#
|
217
|
+
# - Roster for Squad/Lineup?
|
218
|
+
# - Stadium / Venue for Ground? - why? why not?
|
219
|
+
#
|
220
|
+
# use Competition/Tournament for League/Cup alias
|
221
|
+
#
|
222
|
+
# Event => LeagueSeason (League+Season) - use LeagueSeason alias - why? why not?
|
162
223
|
|
163
224
|
|
164
|
-
|
165
|
-
|
225
|
+
### fix - use Squad for (all) LeagueSeason players
|
226
|
+
## use Lineup for players for one match!!!!
|
166
227
|
|
167
228
|
LineUp = Lineup
|
168
|
-
Squad = Lineup
|
229
|
+
Squad = Lineup #### fix - do NOT use squad and lineup as alias (see above)!!!!
|
169
230
|
|
170
231
|
Game = Match ## add (old) alias - why? why not?
|
171
232
|
end # module Model
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: worlddb-models
|
@@ -42,30 +42,36 @@ dependencies:
|
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '7'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '4.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '7'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: hoe
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '4.1'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '4.1'
|
69
75
|
description: sportdb-models - sport.db schema 'n' models for easy (re)use
|
70
76
|
email: opensport@googlegroups.com
|
71
77
|
executables: []
|
@@ -108,15 +114,11 @@ files:
|
|
108
114
|
- lib/sportdb/models/stats.rb
|
109
115
|
- lib/sportdb/models/utils.rb
|
110
116
|
- lib/sportdb/models/version.rb
|
111
|
-
- test/helper.rb
|
112
|
-
- test/test_changes.rb
|
113
|
-
- test/test_cursor.rb
|
114
|
-
- test/test_winner.rb
|
115
117
|
homepage: https://github.com/sportdb/sport.db
|
116
118
|
licenses:
|
117
119
|
- Public Domain
|
118
120
|
metadata: {}
|
119
|
-
post_install_message:
|
121
|
+
post_install_message:
|
120
122
|
rdoc_options:
|
121
123
|
- "--main"
|
122
124
|
- README.md
|
@@ -133,9 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
135
|
- !ruby/object:Gem::Version
|
134
136
|
version: '0'
|
135
137
|
requirements: []
|
136
|
-
|
137
|
-
|
138
|
-
signing_key:
|
138
|
+
rubygems_version: 3.4.10
|
139
|
+
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: sportdb-models - sport.db schema 'n' models for easy (re)use
|
141
142
|
test_files: []
|
data/test/helper.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
## minitest setup
|
2
|
-
require 'minitest/autorun'
|
3
|
-
|
4
|
-
|
5
|
-
## our own code
|
6
|
-
require 'sportdb/models'
|
7
|
-
|
8
|
-
|
9
|
-
#####################
|
10
|
-
# Models shortcuts
|
11
|
-
|
12
|
-
Country = WorldDb::Model::Country
|
13
|
-
|
14
|
-
Person = PersonDb::Model::Person
|
15
|
-
|
16
|
-
League = SportDb::Model::League
|
17
|
-
Season = SportDb::Model::Season
|
18
|
-
Event = SportDb::Model::Event
|
19
|
-
Team = SportDb::Model::Team
|
20
|
-
Lineup = SportDb::Model::Lineup
|
21
|
-
Assoc = SportDb::Model::Assoc
|
22
|
-
AssocAssoc = SportDb::Model::AssocAssoc
|
23
|
-
|
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
|
29
|
-
|
30
|
-
|
31
|
-
EventStanding = SportDb::Model::EventStanding
|
32
|
-
EventStandingEntry = SportDb::Model::EventStandingEntry
|
33
|
-
GroupStanding = SportDb::Model::GroupStanding
|
34
|
-
GroupStandingEntry = SportDb::Model::GroupStandingEntry
|
35
|
-
AlltimeStanding = SportDb::Model::AlltimeStanding
|
36
|
-
AlltimeStandingEntry = SportDb::Model::AlltimeStandingEntry
|
37
|
-
|
38
|
-
|
39
|
-
#################################
|
40
|
-
# setup db -> schema / tables
|
41
|
-
|
42
|
-
SportDb.setup_in_memory_db
|
43
|
-
|
44
|
-
## test helpers here
|
45
|
-
SportDb.delete!
|
46
|
-
SportDb.tables
|
data/test/test_changes.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_changes.rb
|
6
|
-
|
7
|
-
require 'helper'
|
8
|
-
|
9
|
-
class TestChanges < MiniTest::Test
|
10
|
-
|
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
|
-
score1: 1,
|
24
|
-
score2: 2,
|
25
|
-
score1et: nil,
|
26
|
-
score2et: nil,
|
27
|
-
score1p: nil,
|
28
|
-
score2p: nil
|
29
|
-
}
|
30
|
-
|
31
|
-
assert_equal false, match1.check_for_changes( match_attribs )
|
32
|
-
assert_equal true, match2.check_for_changes( match_attribs )
|
33
|
-
end
|
34
|
-
|
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
|
-
|
41
|
-
match2 = Match.new
|
42
|
-
match2.score1 = 1
|
43
|
-
match2.score2 = 2
|
44
|
-
match2.date = DateTime.new( 2012, 12, 24 )
|
45
|
-
|
46
|
-
match_attribs = {
|
47
|
-
score1: 1,
|
48
|
-
score2: 2,
|
49
|
-
date: DateTime.new( 2012, 11, 5 )
|
50
|
-
}
|
51
|
-
|
52
|
-
assert_equal false, match1.check_for_changes( match_attribs )
|
53
|
-
assert_equal true, match2.check_for_changes( match_attribs )
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_group_id
|
57
|
-
match1 = Match.new
|
58
|
-
match1.score1 = 1
|
59
|
-
match1.score2 = 2
|
60
|
-
match1.group_id = 1
|
61
|
-
|
62
|
-
match2 = Match.new
|
63
|
-
match2.score1 = 1
|
64
|
-
match2.score2 = 2
|
65
|
-
match2.group_id = 2
|
66
|
-
|
67
|
-
match_attribs = {
|
68
|
-
score1: 1,
|
69
|
-
score2: 2,
|
70
|
-
group_id: 1
|
71
|
-
}
|
72
|
-
|
73
|
-
assert_equal false, match1.check_for_changes( match_attribs )
|
74
|
-
assert_equal true, match2.check_for_changes( match_attribs )
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
end # class TestChanges
|
data/test/test_cursor.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_cursor.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestCursor < MiniTest::Test
|
11
|
-
|
12
|
-
def test_matches
|
13
|
-
matches = []
|
14
|
-
|
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
|
-
|
20
|
-
MatchCursor.new( matches ).each do |match,state|
|
21
|
-
if state.index == 0
|
22
|
-
assert_equal 3, match.score1
|
23
|
-
assert_equal 1, match.score2
|
24
|
-
assert_equal true, state.new_date?
|
25
|
-
assert_equal true, state.new_year?
|
26
|
-
assert_equal true, state.new_week?
|
27
|
-
end
|
28
|
-
|
29
|
-
if state.index == 1
|
30
|
-
assert_equal 1, match.score1
|
31
|
-
assert_equal 3, match.score2
|
32
|
-
assert_equal true, state.new_date?
|
33
|
-
assert_equal false, state.new_year?
|
34
|
-
assert_equal false, state.new_week?
|
35
|
-
end
|
36
|
-
|
37
|
-
if state.index == 2
|
38
|
-
assert_equal 2, match.score1
|
39
|
-
assert_equal 0, match.score2
|
40
|
-
assert_equal false, state.new_date?
|
41
|
-
assert_equal false, state.new_year?
|
42
|
-
assert_equal false, state.new_week?
|
43
|
-
end
|
44
|
-
|
45
|
-
if state.index == 3
|
46
|
-
assert_equal 3, match.score1
|
47
|
-
assert_equal 2, match.score2
|
48
|
-
assert_equal true, state.new_date?
|
49
|
-
assert_equal true, state.new_week?
|
50
|
-
assert_equal false, state.new_year?
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end # class TestCursor
|
data/test/test_winner.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_winner.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestWinner < MiniTest::Test
|
11
|
-
|
12
|
-
def test_1_2
|
13
|
-
match = Match.new
|
14
|
-
match.score1 = 1
|
15
|
-
match.score2 = 2
|
16
|
-
match.calc_winner
|
17
|
-
|
18
|
-
assert_equal 2, match.winner90
|
19
|
-
assert_equal 2, match.winner
|
20
|
-
assert_equal true, match.winner2?
|
21
|
-
assert_equal false, match.winner1?
|
22
|
-
assert_equal false, match.draw?
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_1_1
|
26
|
-
match = Match.new
|
27
|
-
match.score1 = 1
|
28
|
-
match.score2 = 1
|
29
|
-
match.calc_winner
|
30
|
-
|
31
|
-
assert_equal 0, match.winner90
|
32
|
-
assert_equal 0, match.winner
|
33
|
-
assert_equal true, match.draw?
|
34
|
-
assert_equal false, match.winner1?
|
35
|
-
assert_equal false, match.winner2?
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_2_1
|
39
|
-
match = Match.new
|
40
|
-
match.score1 = 2
|
41
|
-
match.score2 = 1
|
42
|
-
match.calc_winner
|
43
|
-
|
44
|
-
assert_equal 1, match.winner90
|
45
|
-
assert_equal 1, match.winner
|
46
|
-
assert_equal true, match.winner1?
|
47
|
-
assert_equal false, match.winner2?
|
48
|
-
assert_equal false, match.draw?
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_1_1__2_1
|
52
|
-
match = Match.new
|
53
|
-
match.score1 = 1
|
54
|
-
match.score2 = 1
|
55
|
-
match.score1et = 2
|
56
|
-
match.score2et = 1
|
57
|
-
match.calc_winner
|
58
|
-
|
59
|
-
assert_equal 0, match.winner90
|
60
|
-
assert_equal 1, match.winner
|
61
|
-
assert_equal true, match.winner1?
|
62
|
-
assert_equal false, match.winner2?
|
63
|
-
assert_equal false, match.draw?
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_1_1__2_2__3_5
|
67
|
-
match = Match.new
|
68
|
-
match.score1 = 1
|
69
|
-
match.score2 = 1
|
70
|
-
match.score1et = 2
|
71
|
-
match.score2et = 2
|
72
|
-
match.score1p = 3
|
73
|
-
match.score2p = 5
|
74
|
-
match.calc_winner
|
75
|
-
|
76
|
-
assert_equal 0, match.winner90
|
77
|
-
assert_equal 2, match.winner
|
78
|
-
assert_equal true, match.winner2?
|
79
|
-
assert_equal false, match.winner1?
|
80
|
-
assert_equal false, match.draw?
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_1_1_x_3_5
|
84
|
-
match = Match.new
|
85
|
-
match.score1 = 1
|
86
|
-
match.score2 = 1
|
87
|
-
match.score1et = nil
|
88
|
-
match.score2et = nil
|
89
|
-
match.score1p = 3
|
90
|
-
match.score2p = 5
|
91
|
-
match.calc_winner
|
92
|
-
|
93
|
-
assert_equal 0, match.winner90
|
94
|
-
assert_equal 2, match.winner
|
95
|
-
assert_equal true, match.winner2?
|
96
|
-
assert_equal false, match.winner1?
|
97
|
-
assert_equal false, match.draw?
|
98
|
-
end
|
99
|
-
|
100
|
-
end # class TestWinner
|