sportdb-models 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +22 -20
- data/Manifest.txt +0 -4
- data/README.md +28 -31
- data/Rakefile +32 -32
- data/lib/sportdb/models/formats.rb +23 -23
- data/lib/sportdb/models/models/assoc.rb +38 -38
- data/lib/sportdb/models/models/badge.rb +14 -14
- data/lib/sportdb/models/models/forward.rb +55 -55
- data/lib/sportdb/models/models/goal.rb +15 -15
- data/lib/sportdb/models/models/league.rb +20 -20
- data/lib/sportdb/models/models/lineup.rb +20 -17
- data/lib/sportdb/models/models/person.rb +21 -21
- data/lib/sportdb/models/models/season.rb +15 -15
- data/lib/sportdb/models/models/stats/event_standing.rb +31 -31
- data/lib/sportdb/models/models/team.rb +3 -2
- data/lib/sportdb/models/models/world/continent.rb +20 -20
- data/lib/sportdb/models/models/world/state.rb +19 -19
- data/lib/sportdb/models/schema.rb +471 -466
- data/lib/sportdb/models/version.rb +26 -27
- data/lib/sportdb/models.rb +240 -212
- metadata +8 -13
- 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
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
|