sportdb-formats 1.0.5 → 1.1.3
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 +4 -4
- data/Manifest.txt +8 -11
- data/Rakefile +1 -1
- data/lib/sportdb/formats.rb +19 -0
- data/lib/sportdb/formats/country/country_index.rb +2 -2
- data/lib/sportdb/formats/event/event_index.rb +141 -0
- data/lib/sportdb/formats/event/event_reader.rb +183 -0
- data/lib/sportdb/formats/league/league_index.rb +22 -18
- data/lib/sportdb/formats/league/league_outline_reader.rb +27 -7
- data/lib/sportdb/formats/league/league_reader.rb +7 -1
- data/lib/sportdb/formats/match/mapper.rb +63 -63
- data/lib/sportdb/formats/match/mapper_teams.rb +1 -1
- data/lib/sportdb/formats/match/match_parser.rb +141 -193
- data/lib/sportdb/formats/match/match_parser_csv.rb +169 -25
- data/lib/sportdb/formats/match/match_status_parser.rb +86 -0
- data/lib/sportdb/formats/name_helper.rb +4 -1
- data/lib/sportdb/formats/package.rb +57 -9
- data/lib/sportdb/formats/parser_helper.rb +11 -2
- data/lib/sportdb/formats/score/score_formats.rb +19 -0
- data/lib/sportdb/formats/score/score_parser.rb +10 -2
- data/lib/sportdb/formats/season_utils.rb +0 -11
- data/lib/sportdb/formats/structs/group.rb +5 -12
- data/lib/sportdb/formats/structs/match.rb +7 -1
- data/lib/sportdb/formats/structs/round.rb +6 -13
- data/lib/sportdb/formats/structs/season.rb +114 -45
- data/lib/sportdb/formats/structs/standings.rb +30 -9
- data/lib/sportdb/formats/structs/team.rb +8 -2
- data/lib/sportdb/formats/team/club_index.rb +13 -11
- data/lib/sportdb/formats/team/club_index_history.rb +138 -0
- data/lib/sportdb/formats/team/club_reader_history.rb +203 -0
- data/lib/sportdb/formats/team/club_reader_props.rb +2 -3
- data/lib/sportdb/formats/version.rb +2 -2
- data/test/helper.rb +48 -81
- data/test/test_club_index_history.rb +107 -0
- data/test/test_club_reader_history.rb +212 -0
- data/test/test_country_reader.rb +2 -2
- data/test/test_datafile_package.rb +1 -1
- data/test/test_match_status_parser.rb +49 -0
- data/test/test_regex.rb +25 -7
- data/test/test_scores.rb +2 -0
- data/test/test_season.rb +68 -19
- metadata +12 -15
- data/test/test_conf.rb +0 -65
- data/test/test_csv_match_parser.rb +0 -114
- data/test/test_csv_match_parser_utils.rb +0 -20
- data/test/test_match_auto.rb +0 -72
- data/test/test_match_auto_champs.rb +0 -45
- data/test/test_match_auto_euro.rb +0 -37
- data/test/test_match_auto_worldcup.rb +0 -61
- data/test/test_match_champs.rb +0 -27
- data/test/test_match_eng.rb +0 -26
- data/test/test_match_euro.rb +0 -27
- data/test/test_match_worldcup.rb +0 -27
data/test/test_country_reader.rb
CHANGED
@@ -75,13 +75,13 @@ TXT
|
|
75
75
|
assert_equal 'Czechoslovakia (-1992)', recs[0].name
|
76
76
|
assert_equal 'TCH', recs[0].code
|
77
77
|
assert_equal 'czechoslovakia', recs[0].key
|
78
|
-
assert_equal [
|
78
|
+
assert_equal [], recs[0].alt_names
|
79
79
|
assert_equal [], recs[0].tags
|
80
80
|
|
81
81
|
assert_equal 'East Germany (-1989)', recs[3].name
|
82
82
|
assert_equal 'GDR', recs[3].code
|
83
83
|
assert_equal 'eastgermany', recs[3].key
|
84
|
-
assert_equal [
|
84
|
+
assert_equal [], recs[3].alt_names
|
85
85
|
assert_equal [], recs[3].tags
|
86
86
|
end
|
87
87
|
|
@@ -16,7 +16,7 @@ class TestDatafilePackage < MiniTest::Test
|
|
16
16
|
].each do |eng|
|
17
17
|
assert eng.find( '2015-16/.conf.txt' ).read.start_with?( '= English Premier League 2015/16' )
|
18
18
|
assert eng.find( '2017-18/.conf.txt' ).read.start_with?( '= English Premier League 2017/18' )
|
19
|
-
assert eng.find( '2015-16/1-premierleague
|
19
|
+
assert eng.find( '2015-16/1-premierleague.txt' ).read.start_with?( '= English Premier League 2015/16' )
|
20
20
|
end
|
21
21
|
|
22
22
|
[Datafile::DirPackage.new( '../../../openfootball/austria' ),
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_match_status_parser.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestMatchStatusParser < MiniTest::Test
|
12
|
+
|
13
|
+
Status = SportDb::Status
|
14
|
+
StatusParser = SportDb::StatusParser
|
15
|
+
|
16
|
+
def test_find
|
17
|
+
[['awarded [cancelled] canceled [ddd]', Status::CANCELLED],
|
18
|
+
['awarded [bbb; canceled] canceled [awarded; comments] eeee', Status::AWARDED],
|
19
|
+
['aaa bbb ccc ddd eeee', nil],
|
20
|
+
].each do |rec|
|
21
|
+
line = rec[0]
|
22
|
+
status_exp = rec[1]
|
23
|
+
puts "line (before): >#{line}<"
|
24
|
+
status = StatusParser.find!( line )
|
25
|
+
puts "status: >#{status}<"
|
26
|
+
puts "line (after): >#{line}<"
|
27
|
+
puts
|
28
|
+
|
29
|
+
assert_equal status_exp, status
|
30
|
+
end
|
31
|
+
end # method test_find
|
32
|
+
|
33
|
+
def test_parse
|
34
|
+
[['cancelled ddd', Status::CANCELLED],
|
35
|
+
['CANCELLED', Status::CANCELLED],
|
36
|
+
['can.', Status::CANCELLED],
|
37
|
+
['awarded; comments', Status::AWARDED],
|
38
|
+
['awd. - comments', Status::AWARDED],
|
39
|
+
['aaa bbb ccc ddd eeee', nil],
|
40
|
+
].each do |rec|
|
41
|
+
str = rec[0]
|
42
|
+
status_exp = rec[1]
|
43
|
+
assert_equal status_exp, StatusParser.parse( str )
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end # class TestMatchStatusParser
|
48
|
+
|
49
|
+
|
data/test/test_regex.rb
CHANGED
@@ -9,9 +9,27 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestRegex < MiniTest::Test
|
11
11
|
|
12
|
+
HEADER_SEP_RE = SportDb::MatchParser::HEADER_SEP_RE
|
13
|
+
|
14
|
+
def test_header_sep
|
15
|
+
assert_equal ['Round', 'Fr+Sa Dec 11+12'], 'Round // Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
16
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 /// Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
17
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 -- Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
18
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 --- Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
19
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 ++ Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
20
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 +++ Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
21
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 || Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
22
|
+
|
23
|
+
assert_equal ['Final - Leg 1'], 'Final - Leg 1'.split( HEADER_SEP_RE )
|
24
|
+
assert_equal ['Final | Leg 1'], 'Final | Leg 1'.split( HEADER_SEP_RE )
|
25
|
+
assert_equal ['Final / Leg 1'], 'Final / Leg 1'.split( HEADER_SEP_RE )
|
26
|
+
assert_equal ['Final, Leg 1'], 'Final, Leg 1'.split( HEADER_SEP_RE )
|
27
|
+
end
|
28
|
+
|
29
|
+
|
12
30
|
ADDR_MARKER_RE = SportDb::Import::ClubReader::ADDR_MARKER_RE
|
13
31
|
B_TEAM_MARKER_RE = SportDb::Import::ClubReader::B_TEAM_MARKER_RE
|
14
|
-
|
32
|
+
|
15
33
|
def test_addr
|
16
34
|
assert '~ Wien' =~ ADDR_MARKER_RE
|
17
35
|
assert 'Wien ~' =~ ADDR_MARKER_RE
|
@@ -22,13 +40,13 @@ class TestRegex < MiniTest::Test
|
|
22
40
|
assert 'Fischhofgasse 12 /// 1100 Wien' =~ ADDR_MARKER_RE
|
23
41
|
|
24
42
|
assert_nil 'Fischhofgasse 12 + 1100 Wien' =~ ADDR_MARKER_RE
|
25
|
-
assert_nil 'Fischhofgasse 12++1100 Wien' =~ ADDR_MARKER_RE
|
43
|
+
assert_nil 'Fischhofgasse 12++1100 Wien' =~ ADDR_MARKER_RE ## todo/fix: make it a match!!! why? why not?
|
26
44
|
assert_nil 'Fischhofgasse 12 / 1100 Wien' =~ ADDR_MARKER_RE
|
27
|
-
assert_nil 'Fischhofgasse 12//1100 Wien' =~ ADDR_MARKER_RE
|
28
|
-
|
45
|
+
assert_nil 'Fischhofgasse 12//1100 Wien' =~ ADDR_MARKER_RE ## todo/fix: make it a match!!! why? why not?
|
46
|
+
|
29
47
|
assert_nil 'Atlanta United FC, 2017, Atlanta › Georgia' =~ ADDR_MARKER_RE
|
30
48
|
end
|
31
|
-
|
49
|
+
|
32
50
|
def test_b_team
|
33
51
|
assert 'b) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
34
52
|
assert '(b) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
@@ -38,12 +56,12 @@ class TestRegex < MiniTest::Test
|
|
38
56
|
assert '(ii.) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
39
57
|
assert '2) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
40
58
|
assert '(2) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
41
|
-
|
59
|
+
|
42
60
|
assert_nil '(3) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
43
61
|
assert_nil '(iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
44
62
|
assert_nil 'iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
45
63
|
assert_nil 'c) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
46
64
|
assert_nil '(c) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
47
65
|
end
|
48
|
-
|
66
|
+
|
49
67
|
end # class TestRegex
|
data/test/test_scores.rb
CHANGED
@@ -80,12 +80,14 @@ class TestScores < MiniTest::Test
|
|
80
80
|
[ '2-1aet (1-1, 0-0)', [0,0, 1,1, 2,1]],
|
81
81
|
[ '2-1 A.E.T. (1-1, 0-0)', [0,0, 1,1, 2,1]],
|
82
82
|
[ '2-1AET (1-1, 0-0)', [0,0, 1,1, 2,1]],
|
83
|
+
[ '2-1 a.e.t.', [nil,nil,nil,nil, 2,1]],
|
83
84
|
|
84
85
|
[ '3-4 pen. 2-2 a.e.t. (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
|
85
86
|
[ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
|
86
87
|
[ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
|
87
88
|
[ '3-4p 2-2aet (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
|
88
89
|
[ '3-4PSO 2-2AET (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
|
90
|
+
[ '3-4 pen. 2-2 a.e.t.', [nil,nil,nil,nil, 2,2, 3,4]],
|
89
91
|
|
90
92
|
[ '4-3 pen. 1-0 a.e.t. (1-0, )', [nil,nil, 1,0, 1,0, 4,3]],
|
91
93
|
[ '3-4 pen. 2-1 a.e.t. (2-1, )', [nil,nil, 2,1, 2,1, 3,4]],
|
data/test/test_season.rb
CHANGED
@@ -9,25 +9,35 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestSeason < MiniTest::Test
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
assert_equal '2010-11', Season.new( '2010-
|
16
|
-
assert_equal '2010-11', Season.new( '2010
|
17
|
-
assert_equal '2010-11', Season.new( '2010/
|
18
|
-
assert_equal '2010-11', Season.new( '2010/
|
19
|
-
assert_equal '2010
|
20
|
-
|
21
|
-
|
22
|
-
assert_equal '
|
23
|
-
|
24
|
-
assert_equal '2010s/2010',
|
25
|
-
|
26
|
-
assert_equal '
|
27
|
-
|
28
|
-
assert_equal '
|
29
|
-
assert_equal '
|
30
|
-
|
12
|
+
|
13
|
+
def test_to_path
|
14
|
+
assert_equal '2010-11', Season.new( '2010-11' ).to_path
|
15
|
+
assert_equal '2010-11', Season.new( '2010-2011' ).to_path
|
16
|
+
assert_equal '2010-11', Season.new( '2010/11' ).to_path
|
17
|
+
assert_equal '2010-11', Season.new( '2010/1' ).to_path
|
18
|
+
assert_equal '2010-11', Season.new( '2010/2011' ).to_path
|
19
|
+
assert_equal '2010', Season.new( '2010' ).to_path
|
20
|
+
|
21
|
+
assert_equal '2010-11', Season.new( 2010, 2011 ).to_path
|
22
|
+
assert_equal '2010', Season.new( 2010 ).to_path
|
23
|
+
|
24
|
+
assert_equal '2010s/2010-11', Season.new( '2010-11' ).to_path( :decade )
|
25
|
+
assert_equal '2010s/2010-11', Season.new( '2010-2011' ).to_path( :decade )
|
26
|
+
assert_equal '2010s/2010', Season.new( '2010' ).to_path( :decade )
|
27
|
+
|
28
|
+
assert_equal '1999-00', Season.new( '1999-00' ).to_path
|
29
|
+
assert_equal '1999-00', Season.new( '1999-2000' ).to_path
|
30
|
+
assert_equal '1990s/1999-00', Season.new( '1999-00' ).to_path( :decade )
|
31
|
+
assert_equal '1990s/1999-00', Season.new( '1999-2000' ).to_path( :decade )
|
32
|
+
|
33
|
+
assert_equal '2000s/2010-11', Season.new( '2010-11' ).to_path( :century )
|
34
|
+
assert_equal '2000s/2010-11', Season.new( '2010-2011' ).to_path( :century )
|
35
|
+
assert_equal '2000s/2010', Season.new( '2010' ).to_path( :century )
|
36
|
+
|
37
|
+
assert_equal '1900s/1999-00', Season.new( '1999-00' ).to_path( :century )
|
38
|
+
assert_equal '1900s/1999-00', Season.new( '1999-2000' ).to_path( :century )
|
39
|
+
end # method test_to_path
|
40
|
+
|
31
41
|
|
32
42
|
def test_key
|
33
43
|
assert_equal '2010/11', Season.new( '2010-11' ).key
|
@@ -59,4 +69,43 @@ class TestSeason < MiniTest::Test
|
|
59
69
|
assert_equal '1998/99', Season.new( '1999-00' ).prev.key
|
60
70
|
assert_equal '1998/99', Season.new( '1999-2000' ).prev.key
|
61
71
|
end
|
72
|
+
|
73
|
+
def test_next
|
74
|
+
assert_equal '2009/10', Season.new( '2008-09' ).next.key
|
75
|
+
assert_equal '2009/10', Season.new( '2008-2009' ).next.key
|
76
|
+
assert_equal '2009', Season.new( '2008' ).next.key
|
77
|
+
|
78
|
+
assert_equal '1998/99', Season.new( '1997-98' ).next.key
|
79
|
+
assert_equal '1998/99', Season.new( '1997-1998' ).next.key
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
def test_range
|
84
|
+
s2010 = Season.new( '2010' )..Season.new( '2019' )
|
85
|
+
pp s2010.to_a
|
86
|
+
# => [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019]
|
87
|
+
|
88
|
+
s2010 = Season.new( '2010-11')..Season.new( '2019-20')
|
89
|
+
pp s2010.to_a
|
90
|
+
# => [2010/11, 2011/12, 2012/13, 2013/14, 2014/15,
|
91
|
+
# 2015/16, 2016/17, 2017/18, 2018/19, 2019/20]
|
92
|
+
|
93
|
+
puts s2010 === Season.new( '2015-16' ) # true
|
94
|
+
puts s2010 === Season.new( '2015' ) # false - why? if using >= <=
|
95
|
+
puts s2010 === Season.new( '1999-00' ) # false
|
96
|
+
puts s2010 === Season.new( '2020-21' ) # false
|
97
|
+
|
98
|
+
puts Season.new( '2010-11' ) < Season.new( '2015' ) # true
|
99
|
+
puts Season.new( '2015' ) < Season.new( '2019-20') # true
|
100
|
+
|
101
|
+
puts Season.new( '2015' ) == Season.new( '2015-16') # false
|
102
|
+
puts Season.new( '2015' ) < Season.new( '2015-16') # true
|
103
|
+
puts Season.new( '2015' ) == Season.new( '2015') # true
|
104
|
+
|
105
|
+
puts
|
106
|
+
puts s2010.include? Season.new( '2015-16' ) # true
|
107
|
+
puts s2010.include? Season.new( '2015' ) # false
|
108
|
+
puts s2010.include? Season.new( '1999-00' ) # false
|
109
|
+
end
|
110
|
+
|
62
111
|
end # class TestSeason
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-formats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alphabets
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubyzip
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,6 +127,8 @@ files:
|
|
127
127
|
- lib/sportdb/formats/country/country_reader.rb
|
128
128
|
- lib/sportdb/formats/datafile.rb
|
129
129
|
- lib/sportdb/formats/datafile_package.rb
|
130
|
+
- lib/sportdb/formats/event/event_index.rb
|
131
|
+
- lib/sportdb/formats/event/event_reader.rb
|
130
132
|
- lib/sportdb/formats/goals.rb
|
131
133
|
- lib/sportdb/formats/league/league_index.rb
|
132
134
|
- lib/sportdb/formats/league/league_outline_reader.rb
|
@@ -137,6 +139,7 @@ files:
|
|
137
139
|
- lib/sportdb/formats/match/match_parser.rb
|
138
140
|
- lib/sportdb/formats/match/match_parser_auto_conf.rb
|
139
141
|
- lib/sportdb/formats/match/match_parser_csv.rb
|
142
|
+
- lib/sportdb/formats/match/match_status_parser.rb
|
140
143
|
- lib/sportdb/formats/name_helper.rb
|
141
144
|
- lib/sportdb/formats/outline_reader.rb
|
142
145
|
- lib/sportdb/formats/package.rb
|
@@ -155,7 +158,9 @@ files:
|
|
155
158
|
- lib/sportdb/formats/structs/team.rb
|
156
159
|
- lib/sportdb/formats/structs/team_usage.rb
|
157
160
|
- lib/sportdb/formats/team/club_index.rb
|
161
|
+
- lib/sportdb/formats/team/club_index_history.rb
|
158
162
|
- lib/sportdb/formats/team/club_reader.rb
|
163
|
+
- lib/sportdb/formats/team/club_reader_history.rb
|
159
164
|
- lib/sportdb/formats/team/club_reader_props.rb
|
160
165
|
- lib/sportdb/formats/team/national_team_index.rb
|
161
166
|
- lib/sportdb/formats/team/team_index.rb
|
@@ -163,14 +168,13 @@ files:
|
|
163
168
|
- lib/sportdb/formats/version.rb
|
164
169
|
- test/helper.rb
|
165
170
|
- test/test_club_index.rb
|
171
|
+
- test/test_club_index_history.rb
|
166
172
|
- test/test_club_reader.rb
|
173
|
+
- test/test_club_reader_history.rb
|
167
174
|
- test/test_club_reader_props.rb
|
168
175
|
- test/test_clubs.rb
|
169
|
-
- test/test_conf.rb
|
170
176
|
- test/test_country_index.rb
|
171
177
|
- test/test_country_reader.rb
|
172
|
-
- test/test_csv_match_parser.rb
|
173
|
-
- test/test_csv_match_parser_utils.rb
|
174
178
|
- test/test_csv_reader.rb
|
175
179
|
- test/test_datafile.rb
|
176
180
|
- test/test_datafile_package.rb
|
@@ -179,14 +183,7 @@ files:
|
|
179
183
|
- test/test_league_outline_reader.rb
|
180
184
|
- test/test_league_reader.rb
|
181
185
|
- test/test_match.rb
|
182
|
-
- test/
|
183
|
-
- test/test_match_auto_champs.rb
|
184
|
-
- test/test_match_auto_euro.rb
|
185
|
-
- test/test_match_auto_worldcup.rb
|
186
|
-
- test/test_match_champs.rb
|
187
|
-
- test/test_match_eng.rb
|
188
|
-
- test/test_match_euro.rb
|
189
|
-
- test/test_match_worldcup.rb
|
186
|
+
- test/test_match_status_parser.rb
|
190
187
|
- test/test_name_helper.rb
|
191
188
|
- test/test_outline_reader.rb
|
192
189
|
- test/test_package.rb
|
data/test/test_conf.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_conf.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestConf < MiniTest::Test
|
12
|
-
|
13
|
-
COUNTRY_RE = SportDb::ConfParser::COUNTRY_RE
|
14
|
-
TABLE_RE = SportDb::ConfParser::TABLE_RE
|
15
|
-
|
16
|
-
def test_re
|
17
|
-
m=COUNTRY_RE.match( 'Manchester United › ENG' )
|
18
|
-
pp m
|
19
|
-
pp m[0]
|
20
|
-
assert_equal 'ENG', m[:country]
|
21
|
-
|
22
|
-
m=COUNTRY_RE.match( 'Manchester United›ENG' )
|
23
|
-
pp m
|
24
|
-
pp m[0]
|
25
|
-
assert_equal 'ENG', m[:country]
|
26
|
-
|
27
|
-
|
28
|
-
m=TABLE_RE.match( '1 Manchester City 38 32 4 2 106-27 100' )
|
29
|
-
pp m
|
30
|
-
assert_equal 'Manchester City', m[:team]
|
31
|
-
|
32
|
-
m=TABLE_RE.match( '1. Manchester City 38 32 4 2 106:27 100' )
|
33
|
-
pp m
|
34
|
-
assert_equal 'Manchester City', m[:team]
|
35
|
-
|
36
|
-
m=TABLE_RE.match( '- Manchester City 38 32 4 2 106 - 27 100' )
|
37
|
-
pp m
|
38
|
-
assert_equal 'Manchester City', m[:team]
|
39
|
-
|
40
|
-
|
41
|
-
m=TABLE_RE.match( '1. 1. FC Mainz 38 32 4 2 106-27 100 [-7]' )
|
42
|
-
pp m
|
43
|
-
assert_equal '1. FC Mainz', m[:team]
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
def test_conf
|
48
|
-
%w[conf/at_cup.txt
|
49
|
-
conf/at_reg.txt
|
50
|
-
conf/at_champs.txt
|
51
|
-
conf/eng.txt
|
52
|
-
conf/champs.txt
|
53
|
-
].each do |path|
|
54
|
-
txt, exp = read_test( path )
|
55
|
-
|
56
|
-
puts "testing conf #{path}..."
|
57
|
-
teams = parse_conf( txt )
|
58
|
-
|
59
|
-
## note: json always returns hash tables with string keys (not symbols),
|
60
|
-
## thus, always stringify keys before comparing!!!!
|
61
|
-
assert_equal exp, teams.deep_stringify_keys
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end # class TestConf
|
@@ -1,114 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_csv_match_parser.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestCsvMatchParser < MiniTest::Test
|
12
|
-
|
13
|
-
##
|
14
|
-
# Div,Date,HomeTeam,AwayTeam,FTHG,FTAG,FTR,HTHG,HTAG,HTR,
|
15
|
-
# Referee,HS,AS,HST,AST,HF,AF,HC,AC,HY,AY,HR,AR,
|
16
|
-
# B365H,B365D,B365A,BWH,BWD,BWA,IWH,IWD,IWA,LBH,LBD,LBA,PSH,PSD,PSA,
|
17
|
-
# WHH,WHD,WHA,VCH,VCD,VCA,
|
18
|
-
# Bb1X2,BbMxH,BbAvH,BbMxD,BbAvD,BbMxA,BbAvA,BbOU,BbMx>2.5,BbAv>2.5,BbMx<2.5,BbAv<2.5,
|
19
|
-
# BbAH,BbAHh,BbMxAHH,BbAvAHH,BbMxAHA,BbAvAHA,PSCH,PSCD,PSCA
|
20
|
-
def test_eng_filters
|
21
|
-
path = "#{SportDb::Test.data_dir}/england/2017-18/E0.csv"
|
22
|
-
|
23
|
-
matches = SportDb::CsvMatchParser.read( path,
|
24
|
-
filters: { 'HomeTeam' => 'Arsenal' } )
|
25
|
-
|
26
|
-
pp path
|
27
|
-
pp matches[0..2]
|
28
|
-
|
29
|
-
m=matches[0]
|
30
|
-
assert_equal '2017-08-11', m.date
|
31
|
-
assert_equal 4, m.score1
|
32
|
-
assert_equal 3, m.score2
|
33
|
-
assert_equal 2, m.score1i
|
34
|
-
assert_equal 2, m.score2i
|
35
|
-
assert_equal 'Arsenal', m.team1
|
36
|
-
assert_equal 'Leicester', m.team2
|
37
|
-
|
38
|
-
m=matches[1]
|
39
|
-
assert_equal '2017-09-09', m.date
|
40
|
-
assert_equal 3, m.score1
|
41
|
-
assert_equal 0, m.score2
|
42
|
-
assert_equal 2, m.score1i
|
43
|
-
assert_equal 0, m.score2i
|
44
|
-
assert_equal 'Arsenal', m.team1
|
45
|
-
assert_equal 'Bournemouth', m.team2
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
def test_eng_headers
|
50
|
-
path = "#{SportDb::Test.data_dir}/england/2017-18/E0.csv"
|
51
|
-
|
52
|
-
headers = { team1: 'HomeTeam',
|
53
|
-
team2: 'AwayTeam',
|
54
|
-
date: 'Date',
|
55
|
-
score1: 'FTHG',
|
56
|
-
score2: 'FTAG' }
|
57
|
-
|
58
|
-
matches = SportDb::CsvMatchParser.read( path, headers: headers )
|
59
|
-
|
60
|
-
pp path
|
61
|
-
pp matches[0..2]
|
62
|
-
|
63
|
-
m=matches[0]
|
64
|
-
assert_equal '2017-08-11', m.date
|
65
|
-
assert_equal 4, m.score1
|
66
|
-
assert_equal 3, m.score2
|
67
|
-
assert_nil m.score1i ## todo/fix: missing half time (ht) score !!!!
|
68
|
-
assert_nil m.score2i ## todo/fix: missing half time (ht) score !!!!
|
69
|
-
assert_equal 'Arsenal', m.team1
|
70
|
-
assert_equal 'Leicester', m.team2
|
71
|
-
|
72
|
-
m=matches[1]
|
73
|
-
assert_equal '2017-08-12', m.date
|
74
|
-
assert_equal 0, m.score1
|
75
|
-
assert_equal 2, m.score2
|
76
|
-
assert_nil m.score1i ## todo/fix: missing half time (ht) score !!!!
|
77
|
-
assert_nil m.score2i ## todo/fix: missing half time (ht) score !!!!
|
78
|
-
assert_equal 'Brighton', m.team1
|
79
|
-
assert_equal 'Man City', m.team2
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
###
|
84
|
-
# Country,League,Season,Date,Time,Home,Away,HG,AG,
|
85
|
-
# Res,PH,PD,PA,MaxH,MaxD,MaxA,AvgH,AvgD,AvgA
|
86
|
-
def test_at
|
87
|
-
path = "#{SportDb::Test.data_dir}/austria/AUT.csv"
|
88
|
-
|
89
|
-
matches = SportDb::CsvMatchParser.read( path, filters: { 'Season' => '2017/2018' } )
|
90
|
-
|
91
|
-
pp matches[0..2]
|
92
|
-
pp path
|
93
|
-
|
94
|
-
m=matches[0]
|
95
|
-
assert_equal '2017-07-22', m.date
|
96
|
-
assert_equal 2, m.score1
|
97
|
-
assert_equal 2, m.score2
|
98
|
-
assert_nil m.score1i ## todo/fix: missing half time (ht) score !!!!
|
99
|
-
assert_nil m.score2i ## todo/fix: missing half time (ht) score !!!!
|
100
|
-
assert_equal 'Rapid Vienna', m.team1
|
101
|
-
assert_equal 'Mattersburg', m.team2
|
102
|
-
|
103
|
-
m=matches[1]
|
104
|
-
assert_equal '2017-07-22', m.date
|
105
|
-
assert_equal 0, m.score1
|
106
|
-
assert_equal 2, m.score2
|
107
|
-
assert_nil m.score1i ## todo/fix: missing half time (ht) score !!!!
|
108
|
-
assert_nil m.score2i ## todo/fix: missing half time (ht) score !!!!
|
109
|
-
assert_equal 'AC Wolfsberger', m.team1
|
110
|
-
assert_equal 'Salzburg', m.team2
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
end # class TestCsvMatchParser
|