sports 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +0 -23
- data/README.md +0 -3
- data/Rakefile +1 -4
- data/lib/sports.rb +5 -71
- data/lib/sports/version.rb +1 -1
- metadata +4 -69
- data/lib/sports/config.rb +0 -40
- data/lib/sports/goal_parser_csv.rb +0 -28
- data/lib/sports/match_parser_csv.rb +0 -490
- data/lib/sports/match_status_parser.rb +0 -90
- data/lib/sports/name_helper.rb +0 -87
- data/lib/sports/season.rb +0 -199
- data/lib/sports/structs/country.rb +0 -26
- data/lib/sports/structs/goal.rb +0 -231
- data/lib/sports/structs/group.rb +0 -16
- data/lib/sports/structs/league.rb +0 -35
- data/lib/sports/structs/match.rb +0 -180
- data/lib/sports/structs/matchlist.rb +0 -215
- data/lib/sports/structs/round.rb +0 -23
- data/lib/sports/structs/standings.rb +0 -271
- data/lib/sports/structs/team.rb +0 -147
- data/lib/sports/structs/team_usage.rb +0 -84
- data/test/helper.rb +0 -12
- data/test/test_clubs.rb +0 -38
- data/test/test_csv_reader.rb +0 -30
- data/test/test_match.rb +0 -30
- data/test/test_match_status_parser.rb +0 -57
- data/test/test_name_helper.rb +0 -65
- data/test/test_season.rb +0 -141
data/test/helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
## note: use the local version of sportdb gems
|
2
|
-
$LOAD_PATH.unshift( File.expand_path( '../date-formats/lib' ))
|
3
|
-
$LOAD_PATH.unshift( File.expand_path( '../score-formats/lib' ))
|
4
|
-
|
5
|
-
## minitest setup
|
6
|
-
require 'minitest/autorun'
|
7
|
-
|
8
|
-
|
9
|
-
## our own code
|
10
|
-
require 'sports'
|
11
|
-
|
12
|
-
|
data/test/test_clubs.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_clubs.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestClubs < MiniTest::Test
|
9
|
-
|
10
|
-
Club = Sports::Club
|
11
|
-
|
12
|
-
|
13
|
-
def test_new
|
14
|
-
club = Club.new( name: 'Rapid Wien' )
|
15
|
-
|
16
|
-
assert_equal 'Rapid Wien', club.name
|
17
|
-
assert_equal ['Rapid Wien'], club.names
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_duplicates
|
21
|
-
club = Club.new
|
22
|
-
club.name = 'Rapid Wien'
|
23
|
-
|
24
|
-
assert_equal false, club.duplicates?
|
25
|
-
duplicates = {}
|
26
|
-
assert_equal duplicates, club.duplicates
|
27
|
-
|
28
|
-
club.alt_names_auto += ['Rapid', 'Rapid Wien', 'SK Rapid Wien']
|
29
|
-
|
30
|
-
pp club
|
31
|
-
|
32
|
-
assert_equal true, club.duplicates?
|
33
|
-
duplicates = {'rapidwien'=>['Rapid Wien','Rapid Wien']}
|
34
|
-
pp club.duplicates
|
35
|
-
assert_equal duplicates, club.duplicates
|
36
|
-
end
|
37
|
-
|
38
|
-
end # class TestClubs
|
data/test/test_csv_reader.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_csv_reader.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestCsvReader < MiniTest::Test
|
10
|
-
|
11
|
-
def test_parse
|
12
|
-
recs = parse_csv( <<TXT )
|
13
|
-
### World Countries
|
14
|
-
|
15
|
-
Key, Code, Name
|
16
|
-
af, AFG, Afghanistan
|
17
|
-
al, ALB, Albania
|
18
|
-
dz, ALG, Algeria
|
19
|
-
as, ASA, American Samoa (US)
|
20
|
-
TXT
|
21
|
-
|
22
|
-
pp recs
|
23
|
-
assert_equal [{ 'Key' => 'af', 'Code' => 'AFG', 'Name' => 'Afghanistan'},
|
24
|
-
{ 'Key' => 'al', 'Code' => 'ALB', 'Name' => 'Albania'},
|
25
|
-
{ 'Key' => 'dz', 'Code' => 'ALG', 'Name' => 'Algeria'},
|
26
|
-
{ 'Key' => 'as', 'Code' => 'ASA', 'Name' => 'American Samoa (US)'},
|
27
|
-
], recs[0..3]
|
28
|
-
end
|
29
|
-
|
30
|
-
end # class TestCsvReader
|
data/test/test_match.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestMatch < MiniTest::Test
|
11
|
-
|
12
|
-
Match = Sports::Match
|
13
|
-
|
14
|
-
|
15
|
-
def test_round
|
16
|
-
m = Match.new( team1: 'Team 1',
|
17
|
-
team2: 'Team 2',
|
18
|
-
round: 3 )
|
19
|
-
pp m
|
20
|
-
assert_equal 3, m.round
|
21
|
-
assert_nil m.score1
|
22
|
-
assert_nil m.score2
|
23
|
-
|
24
|
-
m = Match.new
|
25
|
-
m.update( round: 4 )
|
26
|
-
pp m
|
27
|
-
assert_equal 4, m.round
|
28
|
-
end # method test_round
|
29
|
-
|
30
|
-
end # class TestMatch
|
@@ -1,57 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_match_status_parser.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestMatchStatusParser < MiniTest::Test
|
10
|
-
|
11
|
-
Status = SportDb::Status
|
12
|
-
StatusParser = SportDb::StatusParser
|
13
|
-
|
14
|
-
def test_find
|
15
|
-
[['awarded [cancelled] canceled [ddd]', Status::CANCELLED],
|
16
|
-
['awarded [bbb; canceled] canceled [awarded; comments] eeee', Status::AWARDED],
|
17
|
-
['aaa bbb ccc ddd eeee', nil],
|
18
|
-
].each do |rec|
|
19
|
-
line = rec[0]
|
20
|
-
status_exp = rec[1]
|
21
|
-
puts "line (before): >#{line}<"
|
22
|
-
status = StatusParser.find!( line )
|
23
|
-
puts "status: >#{status}<"
|
24
|
-
puts "line (after): >#{line}<"
|
25
|
-
puts
|
26
|
-
|
27
|
-
if status_exp.nil?
|
28
|
-
assert_nil status
|
29
|
-
else
|
30
|
-
assert_equal status_exp, status
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end # method test_find
|
34
|
-
|
35
|
-
def test_parse
|
36
|
-
[['cancelled ddd', Status::CANCELLED],
|
37
|
-
['CANCELLED', Status::CANCELLED],
|
38
|
-
['can.', Status::CANCELLED],
|
39
|
-
['awarded; comments', Status::AWARDED],
|
40
|
-
['awd. - comments', Status::AWARDED],
|
41
|
-
['aaa bbb ccc ddd eeee', nil],
|
42
|
-
].each do |rec|
|
43
|
-
str = rec[0]
|
44
|
-
status_exp = rec[1]
|
45
|
-
status = StatusParser.parse( str )
|
46
|
-
|
47
|
-
if status_exp.nil? ## for "silencing" minitest warning - Use assert_nil if expecting nil
|
48
|
-
assert_nil status
|
49
|
-
else
|
50
|
-
assert_equal status_exp, status
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end # class TestMatchStatusParser
|
56
|
-
|
57
|
-
|
data/test/test_name_helper.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_name_helper.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestNameHelper < MiniTest::Test
|
10
|
-
|
11
|
-
include SportDb::NameHelper
|
12
|
-
|
13
|
-
|
14
|
-
def test_strip_norm ## strip (remove) non-norm characters e.g. ()'- etc.
|
15
|
-
[['Estudiantes (LP)', 'Estudiantes LP'],
|
16
|
-
['Central Córdoba (SdE)', 'Central Córdoba SdE'],
|
17
|
-
['Saint Patrick’s Athletic FC', 'Saint Patricks Athletic FC'],
|
18
|
-
['Myllykosken Pallo −47', 'Myllykosken Pallo 47'],
|
19
|
-
].each do |rec|
|
20
|
-
assert_equal rec[1], strip_norm( rec[0] )
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_strip_year
|
25
|
-
[['A (1911-1912)', 'A'],
|
26
|
-
['B (1911-1912, 1913-1915)', 'B'],
|
27
|
-
['C (1911-___)', 'C'],
|
28
|
-
['D (1911-???)', 'D'],
|
29
|
-
['FC Linz (1946-2001, 2013-)', 'FC Linz'],
|
30
|
-
['Admira Wien (-????)', 'Admira Wien'],
|
31
|
-
['Admira Wien (-____)', 'Admira Wien'],
|
32
|
-
].each do |rec|
|
33
|
-
assert_equal rec[1], strip_year( rec[0] )
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_strip_lang
|
38
|
-
[['Bayern Munich [en]', 'Bayern Munich'],
|
39
|
-
].each do |rec|
|
40
|
-
assert_equal rec[1], strip_lang( rec[0] )
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
def test_variants
|
46
|
-
## hungarian
|
47
|
-
assert_equal ['Raba ETO Gyor'], variants( 'Rába ETO Győr' )
|
48
|
-
assert_equal ['Raba ETO Gyor', 'Rába ETO Gyoer'], variants( 'Rába ETO Györ' )
|
49
|
-
|
50
|
-
## romanian
|
51
|
-
assert_equal ['Targu Mures'], variants( 'Târgu Mureș' )
|
52
|
-
assert_equal ['Targu Mures'], variants( 'Târgu Mureş' )
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
=begin
|
57
|
-
### fix: move to ClubReader!!!!! not for general use
|
58
|
-
def test_wiki
|
59
|
-
assert_equal 'FC Wacker Innsbruck', strip_wiki( 'FC Wacker Innsbruck (2002)' )
|
60
|
-
assert_equal 'SK Austria Klagenfurt', strip_wiki( 'SK Austria Klagenfurt (2007)' )
|
61
|
-
|
62
|
-
assert_equal 'Willem II', strip_wiki( 'Willem II (football club)' )
|
63
|
-
end
|
64
|
-
=end
|
65
|
-
end # class TestNameHelper
|
data/test/test_season.rb
DELETED
@@ -1,141 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_season.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestSeason < MiniTest::Test
|
9
|
-
|
10
|
-
|
11
|
-
def test_to_path
|
12
|
-
assert_equal '2010-11', Season( '2010-11' ).to_path
|
13
|
-
assert_equal '2010-11', Season( '2010-2011' ).to_path
|
14
|
-
assert_equal '2010-11', Season( '2010/11' ).to_path
|
15
|
-
assert_equal '2010-11', Season( '2010/1' ).to_path
|
16
|
-
assert_equal '2010-11', Season( '2010/2011' ).to_path
|
17
|
-
assert_equal '2010', Season( '2010' ).to_path
|
18
|
-
|
19
|
-
assert_equal '2010-11', Season( 2010, 2011 ).to_path
|
20
|
-
assert_equal '2010-11', Season( 2010_2011 ).to_path
|
21
|
-
assert_equal '2010-11', Season( 20102011 ).to_path
|
22
|
-
assert_equal '2010-11', Season( 201011 ).to_path
|
23
|
-
assert_equal '2010-11', Season( 20101 ).to_path
|
24
|
-
assert_equal '2010', Season( 2010 ).to_path
|
25
|
-
|
26
|
-
assert_equal '2010s/2010-11', Season( '2010-11' ).to_path( :decade )
|
27
|
-
assert_equal '2010s/2010-11', Season( '2010-2011' ).to_path( :decade )
|
28
|
-
assert_equal '2010s/2010', Season( '2010' ).to_path( :decade )
|
29
|
-
|
30
|
-
assert_equal '1999-00', Season( '1999-00' ).to_path
|
31
|
-
assert_equal '1999-00', Season( '1999-2000' ).to_path
|
32
|
-
assert_equal '1990s/1999-00', Season( '1999-00' ).to_path( :decade )
|
33
|
-
assert_equal '1990s/1999-00', Season( '1999-2000' ).to_path( :decade )
|
34
|
-
|
35
|
-
assert_equal '2000s/2010-11', Season( '2010-11' ).to_path( :century )
|
36
|
-
assert_equal '2000s/2010-11', Season( '2010-2011' ).to_path( :century )
|
37
|
-
assert_equal '2000s/2010', Season( '2010' ).to_path( :century )
|
38
|
-
|
39
|
-
assert_equal '1900s/1999-00', Season( '1999-00' ).to_path( :century )
|
40
|
-
assert_equal '1900s/1999-00', Season( '1999-2000' ).to_path( :century )
|
41
|
-
end # method test_to_path
|
42
|
-
|
43
|
-
|
44
|
-
def test_key
|
45
|
-
assert_equal '2010/11', Season( '2010-11' ).key
|
46
|
-
assert_equal '2010/11', Season( '2010-2011' ).key
|
47
|
-
assert_equal '2010/11', Season( '2010/11' ).key
|
48
|
-
assert_equal '2010/11', Season( '2010/1' ).key
|
49
|
-
assert_equal '2010/11', Season( '2010/2011' ).key
|
50
|
-
assert_equal '2010', Season( '2010' ).key
|
51
|
-
|
52
|
-
assert_equal '1999/00', Season( '1999-00' ).key
|
53
|
-
assert_equal '1999/00', Season( '1999-2000' ).key
|
54
|
-
end # method test_key
|
55
|
-
|
56
|
-
|
57
|
-
def test_years
|
58
|
-
[Season( '1999-00' ),
|
59
|
-
Season( '1999/00' ),
|
60
|
-
Season( '1999/2000' ),
|
61
|
-
Season( 1999, 2000 ),
|
62
|
-
Season( 1999_00 ), ## allow "hacky" shortcuts - why? why not?
|
63
|
-
Season( 1999_2000 ),
|
64
|
-
].each do |season|
|
65
|
-
assert_equal 1999, season.start_year
|
66
|
-
assert_equal 2000, season.end_year
|
67
|
-
end
|
68
|
-
|
69
|
-
[Season( '2010/1' ),
|
70
|
-
Season( '2010/11' ),
|
71
|
-
Season( 201011 ), ## allow "hacky" shortcuts - why? why not?
|
72
|
-
Season( 20102011 ),
|
73
|
-
].each do |season|
|
74
|
-
assert_equal 2010, season.start_year
|
75
|
-
assert_equal 2011, season.end_year
|
76
|
-
end
|
77
|
-
|
78
|
-
[Season( '1999' ),
|
79
|
-
Season( 1999 ),
|
80
|
-
].each do |season|
|
81
|
-
assert_equal 1999, season.start_year
|
82
|
-
assert_equal 1999, season.end_year
|
83
|
-
end
|
84
|
-
|
85
|
-
[Season( '2010' ),
|
86
|
-
Season( 2010 ),
|
87
|
-
].each do |season|
|
88
|
-
assert_equal 2010, season.start_year
|
89
|
-
assert_equal 2010, season.end_year
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
def test_prev
|
95
|
-
assert_equal '2009/10', Season( '2010-11' ).prev.key
|
96
|
-
assert_equal '2009/10', Season( '2010-2011' ).prev.key
|
97
|
-
assert_equal '2009', Season( '2010' ).prev.key
|
98
|
-
|
99
|
-
assert_equal '1998/99', Season( '1999-00' ).prev.key
|
100
|
-
assert_equal '1998/99', Season( '1999-2000' ).prev.key
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_next
|
104
|
-
assert_equal '2009/10', Season( '2008-09' ).next.key
|
105
|
-
assert_equal '2009/10', Season( '2008-2009' ).next.key
|
106
|
-
assert_equal '2009', Season( '2008' ).next.key
|
107
|
-
|
108
|
-
assert_equal '1998/99', Season( '1997-98' ).next.key
|
109
|
-
assert_equal '1998/99', Season( '1997-1998' ).next.key
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
def test_range
|
114
|
-
s2010 = Season( '2010' )..Season( '2019' )
|
115
|
-
pp s2010.to_a
|
116
|
-
# => [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019]
|
117
|
-
|
118
|
-
s2010 = Season( '2010-11')..Season( '2019-20')
|
119
|
-
pp s2010.to_a
|
120
|
-
# => [2010/11, 2011/12, 2012/13, 2013/14, 2014/15,
|
121
|
-
# 2015/16, 2016/17, 2017/18, 2018/19, 2019/20]
|
122
|
-
|
123
|
-
puts s2010 === Season( '2015-16' ) # true
|
124
|
-
puts s2010 === Season( '2015' ) # !!!! false - why? if using >= <=
|
125
|
-
puts s2010 === Season( '1999-00' ) # false
|
126
|
-
puts s2010 === Season( '2020-21' ) # false
|
127
|
-
|
128
|
-
puts
|
129
|
-
puts s2010.include? Season( '2015-16' ) # true
|
130
|
-
puts s2010.include? Season( '2015' ) # !!! false
|
131
|
-
puts s2010.include? Season( '1999-00' ) # false
|
132
|
-
|
133
|
-
assert_equal true, Season( '2010-11' ) < Season( '2015' )
|
134
|
-
assert_equal true, Season( '2015' ) < Season( '2019-20' )
|
135
|
-
|
136
|
-
assert_equal false, Season( '2015' ) == Season( '2015-16' )
|
137
|
-
assert_equal true, Season( '2015' ) < Season( '2015-16' )
|
138
|
-
assert_equal true, Season( '2015' ) == Season( '2015' )
|
139
|
-
end
|
140
|
-
|
141
|
-
end # class TestSeason
|