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.
@@ -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?
@@ -6,8 +6,8 @@ module SportDb
6
6
  module Formats
7
7
 
8
8
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 0
10
- PATCH = 4
9
+ MINOR = 1
10
+ PATCH = 2
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
13
13
  def self.version
@@ -1,5 +1,6 @@
1
1
  ## note: use the local version of gems
2
2
  $LOAD_PATH.unshift( File.expand_path( '../date-formats/lib' ))
3
+ $LOAD_PATH.unshift( File.expand_path( '../sportdb-langs/lib' ))
3
4
 
4
5
 
5
6
  ## minitest setup
@@ -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 ['Czechoslovakia'], recs[0].alt_names
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 ['East Germany'], recs[3].alt_names
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
@@ -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
@@ -9,25 +9,35 @@ require 'helper'
9
9
 
10
10
  class TestSeason < MiniTest::Test
11
11
 
12
- Season = SportDb::Import::Season
13
-
14
- def test_path
15
- assert_equal '2010-11', Season.new( '2010-11' ).path
16
- assert_equal '2010-11', Season.new( '2010-2011' ).path
17
- assert_equal '2010-11', Season.new( '2010/11' ).path
18
- assert_equal '2010-11', Season.new( '2010/1' ).path
19
- assert_equal '2010-11', Season.new( '2010/2011' ).path
20
- assert_equal '2010', Season.new( '2010' ).path
21
-
22
- assert_equal '2010s/2010-11', Season.new( '2010-11' ).path( format: 'long' )
23
- assert_equal '2010s/2010-11', Season.new( '2010-2011' ).path( format: 'long' )
24
- assert_equal '2010s/2010', Season.new( '2010' ).path( format: 'long' )
25
-
26
- assert_equal '1999-00', Season.new( '1999-00' ).path
27
- assert_equal '1999-00', Season.new( '1999-2000' ).path
28
- assert_equal '1990s/1999-00', Season.new( '1999-00' ).path( format: 'long' )
29
- assert_equal '1990s/1999-00', Season.new( '1999-2000' ).path( format: 'long' )
30
- end # method test_path
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.0.4
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-05-18 00:00:00.000000000 Z
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