sportdb-formats 1.0.4 → 1.1.2
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 +4 -0
- data/lib/sportdb/formats.rb +14 -0
- data/lib/sportdb/formats/country/country_reader.rb +1 -1
- data/lib/sportdb/formats/event/event_index.rb +143 -0
- data/lib/sportdb/formats/event/event_reader.rb +183 -0
- data/lib/sportdb/formats/league/league_outline_reader.rb +24 -7
- 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 +119 -183
- data/lib/sportdb/formats/match/match_parser_csv.rb +23 -6
- data/lib/sportdb/formats/package.rb +27 -1
- data/lib/sportdb/formats/parser_helper.rb +11 -2
- data/lib/sportdb/formats/score/score_parser.rb +6 -0
- 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 +5 -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 +1 -2
- data/lib/sportdb/formats/version.rb +2 -2
- data/test/helper.rb +1 -0
- data/test/test_country_reader.rb +2 -2
- data/test/test_match_auto_relegation.rb +41 -0
- data/test/test_match_start_date.rb +44 -0
- data/test/test_regex.rb +25 -7
- data/test/test_season.rb +68 -19
- metadata +6 -2
@@ -11,10 +11,9 @@ class Team
|
|
11
11
|
## todo: use just names for alt_names - why? why not?
|
12
12
|
attr_accessor :key, :name, :alt_names,
|
13
13
|
:code, ## code == abbreviation e.g. ARS etc.
|
14
|
-
:year, :year_end, ## todo/fix: change year_end to end_year (like in season)!!!
|
14
|
+
:year, :year_end, ## todo/fix: change year to start_year and year_end to end_year (like in season)!!!
|
15
15
|
:country
|
16
16
|
|
17
|
-
alias_method :title, :name ## add alias/compat - why? why not
|
18
17
|
|
19
18
|
def names
|
20
19
|
## todo/check: add alt_names_auto too? - why? why not?
|
data/test/helper.rb
CHANGED
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
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_match_auto_relegation.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestMatchAutoRelegation < MiniTest::Test
|
12
|
+
|
13
|
+
def test_rel
|
14
|
+
txt = <<TXT
|
15
|
+
Hinspiel
|
16
|
+
[31.5.]
|
17
|
+
SC Wiener Neustadt 0-2 SKN St. Pölten
|
18
|
+
|
19
|
+
Rückspiel
|
20
|
+
[3.6.]
|
21
|
+
SKN St. Pölten 1-1 SC Wiener Neustadt
|
22
|
+
TXT
|
23
|
+
|
24
|
+
start = Date.new( 2017, 7, 1 )
|
25
|
+
SportDb::Import.config.lang = 'de'
|
26
|
+
|
27
|
+
teams, rounds, groups, round_defs, group_defs = SportDb::AutoConfParser.parse( txt, start: start )
|
28
|
+
|
29
|
+
puts "teams:"
|
30
|
+
pp teams
|
31
|
+
puts "rounds:"
|
32
|
+
pp rounds
|
33
|
+
puts "groups:"
|
34
|
+
pp groups
|
35
|
+
puts "round defs:"
|
36
|
+
pp round_defs
|
37
|
+
puts "group defs:"
|
38
|
+
pp group_defs
|
39
|
+
end
|
40
|
+
|
41
|
+
end # class TestMatchAutoRelegation
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_match_start_date.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestMatchStart < MiniTest::Test
|
12
|
+
|
13
|
+
def test_eng
|
14
|
+
txt =<<TXT
|
15
|
+
Matchday 1
|
16
|
+
[Aug 2]
|
17
|
+
A - B
|
18
|
+
Matchday 2
|
19
|
+
[Jan 3]
|
20
|
+
A - B
|
21
|
+
Matchday 3
|
22
|
+
[Aug 4]
|
23
|
+
A - B
|
24
|
+
TXT
|
25
|
+
|
26
|
+
teams =<<TXT
|
27
|
+
A
|
28
|
+
B
|
29
|
+
TXT
|
30
|
+
SportDb::Import.config.lang = 'en'
|
31
|
+
|
32
|
+
start = Date.new( 2017, 7, 1 )
|
33
|
+
|
34
|
+
parser = SportDb::MatchParser.new( txt, teams, start )
|
35
|
+
matches, rounds = parser.parse
|
36
|
+
|
37
|
+
pp rounds
|
38
|
+
pp matches ## only dump last record for now
|
39
|
+
|
40
|
+
assert_equal Date.new( 2017, 8, 2), matches[0].date
|
41
|
+
assert_equal Date.new( 2018, 1, 3), matches[1].date
|
42
|
+
assert_equal Date.new( 2018, 8, 4), matches[2].date
|
43
|
+
end # method test_end
|
44
|
+
end # class TestMatchStart
|
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_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.2
|
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-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alphabets
|
@@ -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
|
@@ -182,10 +184,12 @@ files:
|
|
182
184
|
- test/test_match_auto.rb
|
183
185
|
- test/test_match_auto_champs.rb
|
184
186
|
- test/test_match_auto_euro.rb
|
187
|
+
- test/test_match_auto_relegation.rb
|
185
188
|
- test/test_match_auto_worldcup.rb
|
186
189
|
- test/test_match_champs.rb
|
187
190
|
- test/test_match_eng.rb
|
188
191
|
- test/test_match_euro.rb
|
192
|
+
- test/test_match_start_date.rb
|
189
193
|
- test/test_match_worldcup.rb
|
190
194
|
- test/test_name_helper.rb
|
191
195
|
- test/test_outline_reader.rb
|