sportdb-formats 0.2.1 → 0.3.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.
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_club_helpers.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestClubHelpers < MiniTest::Test
11
+
12
+ Club = SportDb::Import::Club
13
+
14
+ def strip_norm( name ) Club.strip_norm( name ); end
15
+ def strip_lang( name ) Club.strip_lang( name ); end
16
+ def strip_year( name ) Club.strip_year( name ); end
17
+ def strip_wiki( name ) Club.strip_wiki( name ); end
18
+
19
+
20
+
21
+ def test_norm ## strip (remove) non-norm characters e.g. ()'- etc.
22
+ [
23
+ ['Estudiantes (LP)', 'Estudiantes LP'],
24
+ ['Central Córdoba (SdE)', 'Central Córdoba SdE'],
25
+ ['Saint Patrick’s Athletic FC', 'Saint Patricks Athletic FC'],
26
+ ['Myllykosken Pallo −47', 'Myllykosken Pallo 47'],
27
+ ].each do |rec|
28
+ assert_equal rec[1], strip_norm( rec[0] )
29
+ end
30
+ end
31
+
32
+ def test_variants
33
+ ## hungarian
34
+ assert_equal ['Raba ETO Gyor'], Variant.find( 'Rába ETO Győr' )
35
+ assert_equal ['Raba ETO Gyor', 'Rába ETO Gyoer'], Variant.find( 'Rába ETO Györ' )
36
+
37
+ ## romanian
38
+ assert_equal ['Targu Mures'], Variant.find( 'Târgu Mureș' )
39
+ assert_equal ['Targu Mures'], Variant.find( 'Târgu Mureş' )
40
+ end
41
+
42
+
43
+
44
+
45
+ def test_lang
46
+ assert_equal 'Bayern Munich', strip_lang( 'Bayern Munich [en]' )
47
+ end
48
+
49
+ def test_year
50
+ assert_equal 'FC Linz', strip_year( 'FC Linz (1946-2001, 2013-)' )
51
+
52
+ assert_equal 'Admira Wien', strip_year( 'Admira Wien (-????)' )
53
+ assert_equal 'Admira Wien', strip_year( 'Admira Wien (-____)' )
54
+ end
55
+
56
+
57
+ def test_wiki
58
+ assert_equal 'FC Wacker Innsbruck', strip_wiki( 'FC Wacker Innsbruck (2002)' )
59
+ assert_equal 'SK Austria Klagenfurt', strip_wiki( 'SK Austria Klagenfurt (2007)' )
60
+
61
+ assert_equal 'Willem II', strip_wiki( 'Willem II (football club)' )
62
+ end
63
+ end # class TestClubHelpers
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_clubs.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestClubs < MiniTest::Test
11
+
12
+ Club = SportDb::Import::Club
13
+
14
+ def test_create
15
+ club = Club.create( name: 'Rapid Wien' )
16
+
17
+ assert_equal 'Rapid Wien', club.name
18
+ assert_equal ['Rapid Wien'], club.names
19
+ end
20
+
21
+
22
+ def test_duplicates
23
+ club = Club.new
24
+ club.name = 'Rapid Wien'
25
+
26
+ assert_equal false, club.duplicates?
27
+ duplicates = {}
28
+ assert_equal duplicates, club.duplicates
29
+
30
+ club.alt_names_auto += ['Rapid', 'Rapid Wien', 'SK Rapid Wien']
31
+
32
+ pp club
33
+
34
+ assert_equal true, club.duplicates?
35
+ duplicates = {'rapidwien'=>['Rapid Wien','Rapid Wien']}
36
+ pp club.duplicates
37
+ assert_equal duplicates, club.duplicates
38
+ end
39
+
40
+ end # class TestClubs
@@ -0,0 +1,36 @@
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 = SportDb::Import::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
+
29
+ m = Match.create( team1: 'Team 1',
30
+ team2: 'Team 2',
31
+ round: 5 )
32
+ pp m
33
+ assert_equal 5, m.round
34
+ end # method test_round
35
+
36
+ end # class TestMatch
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_season.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestSeason < MiniTest::Test
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
31
+
32
+ def test_key
33
+ assert_equal '2010/11', Season.new( '2010-11' ).key
34
+ assert_equal '2010/11', Season.new( '2010-2011' ).key
35
+ assert_equal '2010/11', Season.new( '2010/11' ).key
36
+ assert_equal '2010/11', Season.new( '2010/1' ).key
37
+ assert_equal '2010/11', Season.new( '2010/2011' ).key
38
+ assert_equal '2010', Season.new( '2010' ).key
39
+
40
+ assert_equal '1999/00', Season.new( '1999-00' ).key
41
+ assert_equal '1999/00', Season.new( '1999-2000' ).key
42
+ end # method test_key
43
+
44
+ def test_years
45
+ season = Season.new( '1999-00' )
46
+ assert_equal 1999, season.start_year
47
+ assert_equal 2000, season.end_year
48
+
49
+ season = Season.new( '2010/1' )
50
+ assert_equal 2010, season.start_year
51
+ assert_equal 2011, season.end_year
52
+ end
53
+
54
+ def test_prev
55
+ assert_equal '2009/10', Season.new( '2010-11' ).prev.key
56
+ assert_equal '2009/10', Season.new( '2010-2011' ).prev.key
57
+ assert_equal '2009', Season.new( '2010' ).prev.key
58
+
59
+ assert_equal '1998/99', Season.new( '1999-00' ).prev.key
60
+ assert_equal '1998/99', Season.new( '1999-2000' ).prev.key
61
+ end
62
+ 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: 0.2.1
4
+ version: 0.3.0
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-01-07 00:00:00.000000000 Z
11
+ date: 2020-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphabets
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: 0.1.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.0
26
+ version: 0.1.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: date-formats
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -128,16 +128,25 @@ files:
128
128
  - lib/sportdb/formats/package.rb
129
129
  - lib/sportdb/formats/scores.rb
130
130
  - lib/sportdb/formats/season_utils.rb
131
+ - lib/sportdb/formats/structs/club.rb
132
+ - lib/sportdb/formats/structs/match.rb
133
+ - lib/sportdb/formats/structs/matchlist.rb
134
+ - lib/sportdb/formats/structs/season.rb
135
+ - lib/sportdb/formats/structs/standings.rb
136
+ - lib/sportdb/formats/structs/team_usage.rb
131
137
  - lib/sportdb/formats/version.rb
132
138
  - test/helper.rb
139
+ - test/test_club_helpers.rb
140
+ - test/test_clubs.rb
133
141
  - test/test_csv_reader.rb
134
142
  - test/test_datafile.rb
135
143
  - test/test_datafile_match.rb
136
144
  - test/test_goals.rb
145
+ - test/test_match.rb
137
146
  - test/test_outline_reader.rb
138
147
  - test/test_package.rb
139
148
  - test/test_scores.rb
140
- - test/test_season_utils.rb
149
+ - test/test_season.rb
141
150
  homepage: https://github.com/sportdb/sport.db
142
151
  licenses:
143
152
  - Public Domain
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_season_utils.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestSeasonUtils < MiniTest::Test
11
-
12
- def test_directory
13
- assert_equal '2010-11', SeasonUtils.directory( '2010-11' )
14
- assert_equal '2010-11', SeasonUtils.directory( '2010-2011' )
15
- assert_equal '2010-11', SeasonUtils.directory( '2010/11' )
16
- assert_equal '2010-11', SeasonUtils.directory( '2010/2011' )
17
- assert_equal '2010', SeasonUtils.directory( '2010' )
18
-
19
- assert_equal '2010s/2010-11', SeasonUtils.directory( '2010-11', format: 'long' )
20
- assert_equal '2010s/2010-11', SeasonUtils.directory( '2010-2011', format: 'long' )
21
- assert_equal '2010s/2010', SeasonUtils.directory( '2010', format: 'long' )
22
-
23
- assert_equal '1999-00', SeasonUtils.directory( '1999-00' )
24
- assert_equal '1999-00', SeasonUtils.directory( '1999-2000' )
25
- assert_equal '1990s/1999-00', SeasonUtils.directory( '1999-00', format: 'long' )
26
- assert_equal '1990s/1999-00', SeasonUtils.directory( '1999-2000', format: 'long' )
27
- end # method test_diretory
28
-
29
- end # class TestSeasonlUtils