sportdb-formats 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_league_outline_reader.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestLeagueOutlineReader < MiniTest::Test
12
+
13
+ def test_parse
14
+ txt = <<TXT
15
+ = ENG PL 2019/20
16
+
17
+ line
18
+ line
19
+
20
+ = ENG CS 2019/20
21
+
22
+ line
23
+ line
24
+
25
+ = ENG PL 2020/1
26
+
27
+ line
28
+ line
29
+ TXT
30
+
31
+ secs = SportDb::LeagueOutlineReader.parse( txt )
32
+ pp secs
33
+
34
+ assert_equal 3, secs.size
35
+
36
+ league = secs[0][:league]
37
+ assert_equal 'English Premier League', league.name
38
+ assert_equal 'eng.1', league.key
39
+ assert_equal 'England', league.country.name
40
+ assert_equal 'eng', league.country.key
41
+
42
+ season = secs[0][:season]
43
+ assert_equal '2019/20', season.key
44
+
45
+ ## try with season filter
46
+ secs = SportDb::LeagueOutlineReader.parse( txt, season: '2020/21' )
47
+ pp secs
48
+
49
+ assert_equal 1, secs.size
50
+
51
+ season = secs[0][:season]
52
+ assert_equal '2020/21', season.key
53
+ end
54
+
55
+ end # class TestLeagueOutlineReader
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_league_reader.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestLeagueReader < MiniTest::Test
11
+
12
+ def test_parse_at
13
+ recs = SportDb::Import::LeagueReader.parse( <<TXT )
14
+ ==============================
15
+ = Austria
16
+ 1 Bundesliga
17
+ | AUT BL | Österreich Bundesliga
18
+ 2 2. Liga
19
+ | Österreich Zweite Liga
20
+
21
+ 3.o Regionalliga Ost
22
+ | AUT RLO | Österreich Regionalliga Ost
23
+ 3.m Regionalliga Mitte
24
+ | AUT RLM | Österreich Regionalliga Mitte
25
+ 3.sbg Regionalliga Salzburg
26
+ | RL SBG
27
+ 3.t Regionalliga Tirol
28
+ | RL TIR
29
+ TXT
30
+
31
+ pp recs
32
+
33
+ assert_equal 6, recs.size
34
+ assert_equal '2. Liga', recs[1].name
35
+ assert_equal 'at.2', recs[1].key
36
+ assert_equal 'Austria', recs[1].country.name
37
+ assert_equal 'at', recs[1].country.key
38
+
39
+ assert recs[0].alt_names_auto.include?( 'AT' )
40
+ assert recs[0].alt_names_auto.include?( 'AT 1' )
41
+ assert recs[0].alt_names_auto.include?( 'AUT 1' )
42
+ assert recs[0].alt_names_auto.include?( 'Austria 1' )
43
+
44
+ assert recs[1].alt_names_auto.include?( 'AT 2' )
45
+ assert recs[1].alt_names_auto.include?( 'AUT 2' )
46
+ assert recs[1].alt_names_auto.include?( 'Austria 2' )
47
+ end
48
+
49
+
50
+ def test_parse_us
51
+ recs = SportDb::Import::LeagueReader.parse( <<TXT )
52
+ =============================================
53
+ = United States
54
+ 1 Major League Soccer
55
+ | USA MLS | USA Major League Soccer
56
+ cup US Open Cup
57
+ | USA US Open Cup
58
+ TXT
59
+
60
+ pp recs
61
+
62
+ assert_equal 2, recs.size
63
+ assert_equal 'Major League Soccer', recs[0].name
64
+ assert_equal 'us.1', recs[0].key
65
+ assert_equal 'United States', recs[0].country.name
66
+ assert_equal 'us', recs[0].country.key
67
+
68
+ assert_equal 'US Open Cup', recs[1].name
69
+ assert_equal 'us.cup', recs[1].key
70
+ end
71
+
72
+ end # class TestLeagueReader
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_regex.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestRegex < MiniTest::Test
11
+
12
+ ADDR_MARKER_RE = SportDb::Import::ClubReader::ADDR_MARKER_RE
13
+ B_TEAM_MARKER_RE = SportDb::Import::ClubReader::B_TEAM_MARKER_RE
14
+
15
+ def test_addr
16
+ assert '~ Wien' =~ ADDR_MARKER_RE
17
+ assert 'Wien ~' =~ ADDR_MARKER_RE
18
+ assert 'Fischhofgasse 12 ~ 1100 Wien' =~ ADDR_MARKER_RE
19
+ assert 'Fischhofgasse 12 ++ 1100 Wien' =~ ADDR_MARKER_RE
20
+ assert 'Fischhofgasse 12 +++ 1100 Wien' =~ ADDR_MARKER_RE
21
+ assert 'Fischhofgasse 12 // 1100 Wien' =~ ADDR_MARKER_RE
22
+ assert 'Fischhofgasse 12 /// 1100 Wien' =~ ADDR_MARKER_RE
23
+
24
+ assert_nil 'Fischhofgasse 12 + 1100 Wien' =~ ADDR_MARKER_RE
25
+ assert_nil 'Fischhofgasse 12++1100 Wien' =~ ADDR_MARKER_RE
26
+ assert_nil 'Fischhofgasse 12 / 1100 Wien' =~ ADDR_MARKER_RE
27
+ assert_nil 'Fischhofgasse 12//1100 Wien' =~ ADDR_MARKER_RE
28
+
29
+ assert_nil 'Atlanta United FC, 2017, Atlanta › Georgia' =~ ADDR_MARKER_RE
30
+ end
31
+
32
+ def test_b_team
33
+ assert 'b) Rapid Wien II' =~ B_TEAM_MARKER_RE
34
+ assert '(b) Rapid Wien II' =~ B_TEAM_MARKER_RE
35
+ assert '(b.) Rapid Wien II' =~ B_TEAM_MARKER_RE
36
+ assert 'ii) Rapid Wien II' =~ B_TEAM_MARKER_RE
37
+ assert 'II) Rapid Wien II' =~ B_TEAM_MARKER_RE
38
+ assert '(ii.) Rapid Wien II' =~ B_TEAM_MARKER_RE
39
+ assert '2) Rapid Wien II' =~ B_TEAM_MARKER_RE
40
+ assert '(2) Rapid Wien II' =~ B_TEAM_MARKER_RE
41
+
42
+ assert_nil '(3) Rapid Wien II' =~ B_TEAM_MARKER_RE
43
+ assert_nil '(iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
44
+ assert_nil 'iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
45
+ assert_nil 'c) Rapid Wien II' =~ B_TEAM_MARKER_RE
46
+ assert_nil '(c) Rapid Wien II' =~ B_TEAM_MARKER_RE
47
+ end
48
+
49
+ end # class TestRegex
@@ -0,0 +1,77 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_wiki_reader.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestWikiReader < MiniTest::Test
11
+
12
+ def test_parse_at
13
+ recs = SportDb::Import::WikiReader.parse( <<TXT )
14
+ ===================================
15
+ = Albania
16
+
17
+ FK Partizani Tirana
18
+ KF Tirana
19
+ FK Kukësi
20
+ KF Laçi
21
+ TXT
22
+
23
+ pp recs
24
+
25
+ assert_equal 4, recs.size
26
+ assert_equal 'FK Partizani Tirana', recs[0].name
27
+ assert_equal 'Albania', recs[0].country.name
28
+ assert_equal 'al', recs[0].country.key
29
+ end
30
+
31
+
32
+ def test_parse_be
33
+ recs = SportDb::Import::WikiReader.parse( <<TXT )
34
+ ===========================
35
+ = Belgium
36
+
37
+ R.S.C._Anderlecht
38
+ Royal_Antwerp_F.C.
39
+ Cercle_Brugge_K.S.V.
40
+ R._Charleroi_S.C.
41
+ Club_Brugge_KV
42
+ TXT
43
+
44
+ pp recs
45
+
46
+ assert_equal 5, recs.size
47
+ assert_equal 'R.S.C. Anderlecht', recs[0].name
48
+ assert_equal 'Belgium', recs[0].country.name
49
+ assert_equal 'be', recs[0].country.key
50
+ end
51
+
52
+ def test_parse_world
53
+ recs = SportDb::Import::WikiReader.parse( <<TXT )
54
+ = Albania =
55
+
56
+ FK Partizani Tirana
57
+
58
+
59
+ = Belgium =
60
+
61
+ # some comments here
62
+ R.S.C._Anderlecht # some end-of-line comments here
63
+ TXT
64
+
65
+ pp recs
66
+
67
+ assert_equal 2, recs.size
68
+ assert_equal 'FK Partizani Tirana', recs[0].name
69
+ assert_equal 'Albania', recs[0].country.name
70
+ assert_equal 'al', recs[0].country.key
71
+
72
+ assert_equal 'R.S.C. Anderlecht', recs[1].name
73
+ assert_equal 'Belgium', recs[1].country.name
74
+ assert_equal 'be', recs[1].country.key
75
+ end
76
+
77
+ end # class TestWikiReader
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -123,9 +123,14 @@ files:
123
123
  - Rakefile
124
124
  - lib/sportdb/formats.rb
125
125
  - lib/sportdb/formats/config.rb
126
+ - lib/sportdb/formats/country/country_index.rb
127
+ - lib/sportdb/formats/country/country_reader.rb
126
128
  - lib/sportdb/formats/datafile.rb
127
129
  - lib/sportdb/formats/datafile_package.rb
128
130
  - lib/sportdb/formats/goals.rb
131
+ - lib/sportdb/formats/league/league_index.rb
132
+ - lib/sportdb/formats/league/league_outline_reader.rb
133
+ - lib/sportdb/formats/league/league_reader.rb
129
134
  - lib/sportdb/formats/match/conf_parser.rb
130
135
  - lib/sportdb/formats/match/mapper.rb
131
136
  - lib/sportdb/formats/match/mapper_teams.rb
@@ -148,13 +153,27 @@ files:
148
153
  - lib/sportdb/formats/structs/standings.rb
149
154
  - lib/sportdb/formats/structs/team.rb
150
155
  - lib/sportdb/formats/structs/team_usage.rb
156
+ - lib/sportdb/formats/team/club_index.rb
157
+ - lib/sportdb/formats/team/club_reader.rb
158
+ - lib/sportdb/formats/team/club_reader_props.rb
159
+ - lib/sportdb/formats/team/national_team_index.rb
160
+ - lib/sportdb/formats/team/team_index.rb
161
+ - lib/sportdb/formats/team/wiki_reader.rb
151
162
  - lib/sportdb/formats/version.rb
152
163
  - test/helper.rb
164
+ - test/test_club_index.rb
165
+ - test/test_club_reader.rb
166
+ - test/test_club_reader_props.rb
153
167
  - test/test_clubs.rb
154
168
  - test/test_conf.rb
169
+ - test/test_country_index.rb
170
+ - test/test_country_reader.rb
155
171
  - test/test_csv_reader.rb
156
172
  - test/test_datafile.rb
157
173
  - test/test_goals.rb
174
+ - test/test_league_index.rb
175
+ - test/test_league_outline_reader.rb
176
+ - test/test_league_reader.rb
158
177
  - test/test_match.rb
159
178
  - test/test_match_auto.rb
160
179
  - test/test_match_auto_champs.rb
@@ -168,8 +187,10 @@ files:
168
187
  - test/test_outline_reader.rb
169
188
  - test/test_package.rb
170
189
  - test/test_package_match.rb
190
+ - test/test_regex.rb
171
191
  - test/test_scores.rb
172
192
  - test/test_season.rb
193
+ - test/test_wiki_reader.rb
173
194
  homepage: https://github.com/sportdb/sport.db
174
195
  licenses:
175
196
  - Public Domain