sportdb-formats 1.1.6 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +2 -0
- data/Manifest.txt +4 -25
- data/Rakefile +1 -1
- data/lib/sportdb/formats/country/country_reader.rb +142 -142
- data/lib/sportdb/formats/datafile.rb +59 -59
- data/lib/sportdb/formats/event/event_reader.rb +184 -183
- data/lib/sportdb/formats/goals.rb +53 -9
- data/lib/sportdb/formats/ground/ground_reader.rb +289 -0
- data/lib/sportdb/formats/league/league_reader.rb +152 -168
- data/lib/sportdb/formats/lines_reader.rb +47 -0
- data/lib/sportdb/formats/match/match_parser.rb +130 -13
- data/lib/sportdb/formats/match/match_parser_auto_conf.rb +270 -202
- data/lib/sportdb/formats/outline_reader.rb +0 -1
- data/lib/sportdb/formats/package.rb +394 -374
- data/lib/sportdb/formats/search/sport.rb +357 -0
- data/lib/sportdb/formats/search/world.rb +139 -0
- data/lib/sportdb/formats/team/club_index_history.rb +134 -134
- data/lib/sportdb/formats/team/club_reader.rb +318 -350
- data/lib/sportdb/formats/team/club_reader_history.rb +203 -203
- data/lib/sportdb/formats/team/wiki_reader.rb +108 -108
- data/lib/sportdb/formats/version.rb +4 -7
- data/lib/sportdb/formats.rb +60 -27
- metadata +13 -35
- data/lib/sportdb/formats/country/country_index.rb +0 -192
- data/lib/sportdb/formats/event/event_index.rb +0 -141
- data/lib/sportdb/formats/league/league_index.rb +0 -178
- data/lib/sportdb/formats/team/club_index.rb +0 -338
- data/lib/sportdb/formats/team/national_team_index.rb +0 -114
- data/lib/sportdb/formats/team/team_index.rb +0 -43
- data/test/helper.rb +0 -132
- data/test/test_club_index.rb +0 -183
- data/test/test_club_index_history.rb +0 -107
- data/test/test_club_reader.rb +0 -201
- data/test/test_club_reader_history.rb +0 -212
- data/test/test_club_reader_props.rb +0 -54
- data/test/test_country_index.rb +0 -63
- data/test/test_country_reader.rb +0 -89
- data/test/test_datafile.rb +0 -30
- data/test/test_datafile_package.rb +0 -46
- data/test/test_goals.rb +0 -113
- data/test/test_league_index.rb +0 -157
- data/test/test_league_outline_reader.rb +0 -55
- data/test/test_league_reader.rb +0 -72
- data/test/test_outline_reader.rb +0 -31
- data/test/test_package.rb +0 -78
- data/test/test_package_match.rb +0 -102
- data/test/test_regex.rb +0 -67
- data/test/test_wiki_reader.rb +0 -77
data/test/helper.rb
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
## note: use the local version of gems
|
2
|
-
$LOAD_PATH.unshift( File.expand_path( '../date-formats/lib' ))
|
3
|
-
$LOAD_PATH.unshift( File.expand_path( '../score-formats/lib' ))
|
4
|
-
$LOAD_PATH.unshift( File.expand_path( '../sportdb-langs/lib' ))
|
5
|
-
$LOAD_PATH.unshift( File.expand_path( '../sportdb-structs/lib' ))
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
## minitest setup
|
10
|
-
require 'minitest/autorun'
|
11
|
-
|
12
|
-
|
13
|
-
## our own code
|
14
|
-
require 'sportdb/formats'
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
module SportDb
|
19
|
-
module Import
|
20
|
-
|
21
|
-
class TestCatalog
|
22
|
-
def build_country_index
|
23
|
-
recs = CountryReader.read( "#{Test.data_dir}/world/countries.txt" )
|
24
|
-
index = CountryIndex.new( recs )
|
25
|
-
index
|
26
|
-
end
|
27
|
-
|
28
|
-
def build_league_index
|
29
|
-
recs = SportDb::Import::LeagueReader.parse( <<TXT )
|
30
|
-
= England =
|
31
|
-
1 English Premier League
|
32
|
-
| ENG PL | England Premier League | Premier League
|
33
|
-
2 English Championship
|
34
|
-
| ENG CS | England Championship | Championship
|
35
|
-
3 English League One
|
36
|
-
| England League One | League One
|
37
|
-
4 English League Two
|
38
|
-
5 English National League
|
39
|
-
|
40
|
-
cup EFL Cup
|
41
|
-
| League Cup | Football League Cup
|
42
|
-
| ENG LC | England Liga Cup
|
43
|
-
|
44
|
-
= Scotland =
|
45
|
-
1 Scottish Premiership
|
46
|
-
2 Scottish Championship
|
47
|
-
3 Scottish League One
|
48
|
-
4 Scottish League Two
|
49
|
-
TXT
|
50
|
-
|
51
|
-
leagues = SportDb::Import::LeagueIndex.new
|
52
|
-
leagues.add( recs )
|
53
|
-
leagues
|
54
|
-
end
|
55
|
-
|
56
|
-
def build_club_index
|
57
|
-
recs = ClubReader.parse( <<TXT )
|
58
|
-
= England
|
59
|
-
|
60
|
-
Chelsea FC
|
61
|
-
Tottenham Hotspur
|
62
|
-
West Ham United
|
63
|
-
Crystal Palace
|
64
|
-
|
65
|
-
### note add move entires for testing club name history
|
66
|
-
Manchester United FC
|
67
|
-
| Manchester United
|
68
|
-
| Newton Heath FC
|
69
|
-
|
70
|
-
Manchester City FC
|
71
|
-
| Manchester City
|
72
|
-
| Ardwick FC
|
73
|
-
|
74
|
-
Arsenal FC
|
75
|
-
| The Arsenal FC
|
76
|
-
| Woolwich Arsenal FC
|
77
|
-
| Royal Arsenal FC
|
78
|
-
|
79
|
-
Gateshead FC
|
80
|
-
| South Shields FC
|
81
|
-
|
82
|
-
Sheffield Wednesday
|
83
|
-
| The Wednesday FC
|
84
|
-
|
85
|
-
Port Vale FC
|
86
|
-
| Burslem Port Vale FC
|
87
|
-
|
88
|
-
Chesterfield FC
|
89
|
-
| Chesterfield Town FC
|
90
|
-
|
91
|
-
Birmingham FC
|
92
|
-
| Small Heath FC
|
93
|
-
|
94
|
-
Burton Swifts FC
|
95
|
-
Burton Wanderers FC
|
96
|
-
Burton United FC
|
97
|
-
|
98
|
-
Blackpool FC
|
99
|
-
South Shore FC
|
100
|
-
|
101
|
-
Glossop FC
|
102
|
-
| Glossop North End FC
|
103
|
-
|
104
|
-
Walsall FC
|
105
|
-
| Walsall Town Swifts FC
|
106
|
-
|
107
|
-
|
108
|
-
Newcastle West End FC
|
109
|
-
Newcastle East End FC
|
110
|
-
Newcastle United FC
|
111
|
-
TXT
|
112
|
-
|
113
|
-
index = ClubIndex.new
|
114
|
-
index.add( recs )
|
115
|
-
index
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
def countries() @countries ||= build_country_index; end
|
120
|
-
def leagues() @leagues ||= build_league_index; end
|
121
|
-
def clubs() @clubs ||= build_club_index; end
|
122
|
-
end
|
123
|
-
|
124
|
-
configure do |config|
|
125
|
-
config.catalog = TestCatalog.new
|
126
|
-
end
|
127
|
-
|
128
|
-
end # module Import
|
129
|
-
end # module SportDb
|
130
|
-
|
131
|
-
|
132
|
-
|
data/test/test_club_index.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_club_index.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestClubIndex < MiniTest::Test
|
11
|
-
|
12
|
-
def test_match
|
13
|
-
|
14
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
15
|
-
=================================
|
16
|
-
= Austria
|
17
|
-
|
18
|
-
== Wien ==
|
19
|
-
|
20
|
-
FK Austria Wien, Wien (Favoriten)
|
21
|
-
| Austria Vienna | Austria Wien
|
22
|
-
SK Rapid Wien, Wien (Hütteldorf)
|
23
|
-
| Rapid Vienna | Rapid Wien
|
24
|
-
|
25
|
-
|
26
|
-
====================================
|
27
|
-
= England
|
28
|
-
|
29
|
-
Arsenal FC, 1886, @ Emirates Stadium, London ## Greater London
|
30
|
-
| Arsenal | FC Arsenal
|
31
|
-
Chelsea FC, 1905, @ Stamford Bridge, London ## Greater London
|
32
|
-
| Chelsea | FC Chelsea
|
33
|
-
|
34
|
-
|
35
|
-
=====================================
|
36
|
-
= Russia
|
37
|
-
|
38
|
-
Arsenal Tula, Tula
|
39
|
-
| Arsenal | FC Arsenal Tula
|
40
|
-
|
41
|
-
|
42
|
-
===========================
|
43
|
-
= Argentina
|
44
|
-
|
45
|
-
== Buenos Aires ==
|
46
|
-
|
47
|
-
Arsenal de Sarandí, Sarandí › Buenos Aires # Sarandí es una ciudad de la Zona Sur del Gran Buenos Aires
|
48
|
-
| Arsenal | Arsenal Sarandi
|
49
|
-
| Arsenal FC | Arsenal Fútbol Club
|
50
|
-
TXT
|
51
|
-
|
52
|
-
clubs = SportDb::Import::ClubIndex.new
|
53
|
-
clubs.add( recs )
|
54
|
-
|
55
|
-
pp clubs.errors
|
56
|
-
|
57
|
-
clubs.dump_duplicates
|
58
|
-
|
59
|
-
m = clubs.match( 'Rapid Wien' )
|
60
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
61
|
-
assert_equal 'Austria', m[0].country.name
|
62
|
-
assert_equal 'Wien', m[0].city
|
63
|
-
|
64
|
-
m = clubs.match( 'rapid wien' )
|
65
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
66
|
-
assert_equal 'Austria', m[0].country.name
|
67
|
-
assert_equal 'Wien', m[0].city
|
68
|
-
|
69
|
-
## note: all dots (.) get always removed
|
70
|
-
m = clubs.match( '...r.a.p.i.d w.i.e.n...' )
|
71
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
72
|
-
assert_equal 'Austria', m[0].country.name
|
73
|
-
assert_equal 'Wien', m[0].city
|
74
|
-
|
75
|
-
## note: all spaces and dashes (-) get always removed
|
76
|
-
m = clubs.match( '--- r a p i d w i e n ---' )
|
77
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
78
|
-
assert_equal 'Austria', m[0].country.name
|
79
|
-
assert_equal 'Wien', m[0].city
|
80
|
-
|
81
|
-
m = clubs.match( 'RAPID WIEN' )
|
82
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
83
|
-
assert_equal 'Austria', m[0].country.name
|
84
|
-
assert_equal 'Wien', m[0].city
|
85
|
-
|
86
|
-
|
87
|
-
c = clubs[ 'SK Rapid Wien' ] ## check canoncial name match (only)
|
88
|
-
assert_equal 'SK Rapid Wien', c.name
|
89
|
-
assert_equal 'Austria', c.country.name
|
90
|
-
assert_equal 'Wien', c.city
|
91
|
-
|
92
|
-
|
93
|
-
m = clubs.match( 'Arsenal' )
|
94
|
-
assert_equal 3, m.size
|
95
|
-
|
96
|
-
m = clubs.match( 'ARSENAL' )
|
97
|
-
assert_equal 3, m.size
|
98
|
-
|
99
|
-
m = clubs.match_by( name: 'Arsenal', country: 'eng' )
|
100
|
-
assert_equal 1, m.size
|
101
|
-
assert_equal 'Arsenal FC', m[0].name
|
102
|
-
assert_equal 'England', m[0].country.name
|
103
|
-
assert_equal 'London', m[0].city
|
104
|
-
|
105
|
-
club = clubs.find_by!( name: 'Arsenal', country: 'eng' )
|
106
|
-
assert_equal 'Arsenal FC', club.name
|
107
|
-
assert_equal 'England', club.country.name
|
108
|
-
assert_equal 'London', club.city
|
109
|
-
|
110
|
-
|
111
|
-
m = clubs.match_by( name: 'Arsenal', country: 'ar' )
|
112
|
-
assert_equal 1, m.size
|
113
|
-
assert_equal 'Arsenal de Sarandí', m[0].name
|
114
|
-
assert_equal 'Argentina', m[0].country.name
|
115
|
-
assert_equal 'Sarandí', m[0].city
|
116
|
-
|
117
|
-
club = clubs.find_by!( name: 'Arsenal', country: 'ar' )
|
118
|
-
assert_equal 'Arsenal de Sarandí', club.name
|
119
|
-
assert_equal 'Argentina', club.country.name
|
120
|
-
assert_equal 'Sarandí', club.city
|
121
|
-
|
122
|
-
|
123
|
-
m = clubs.match_by( name: 'Arsenal', country: 'ru' )
|
124
|
-
assert_equal 1, m.size
|
125
|
-
assert_equal 'Arsenal Tula', m[0].name
|
126
|
-
assert_equal 'Russia', m[0].country.name
|
127
|
-
assert_equal 'Tula', m[0].city
|
128
|
-
|
129
|
-
|
130
|
-
m = clubs.match( 'Arsenal FC' )
|
131
|
-
assert_equal 2, m.size
|
132
|
-
|
133
|
-
m = clubs.match( 'Arsenal F.C.' )
|
134
|
-
assert_equal 2, m.size
|
135
|
-
|
136
|
-
m = clubs.match( '...A.r.s.e.n.a.l... F.C...' )
|
137
|
-
assert_equal 2, m.size
|
138
|
-
end
|
139
|
-
|
140
|
-
|
141
|
-
def test_wikipedia # test wikipedia names and links/urls
|
142
|
-
|
143
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
144
|
-
==================================
|
145
|
-
= Belgium
|
146
|
-
|
147
|
-
== Brussels ==
|
148
|
-
|
149
|
-
RSC Anderlecht, 1908, Brussels ## use (just) Anderlecht or Brussel-Anderlecht ??
|
150
|
-
| Anderlecht | R.S.C. Anderlecht | Royal Sporting Club Anderlecht
|
151
|
-
|
152
|
-
== West-Vlaanderen › Vlaanderen ==
|
153
|
-
|
154
|
-
Club Brugge, 1891, Brugge › West-Vlaanderen › Vlaanderen
|
155
|
-
| Club Brugge KV | Club Brugge Koninklijke Voetbalvereniging
|
156
|
-
TXT
|
157
|
-
|
158
|
-
|
159
|
-
clubs = SportDb::Import::ClubIndex.new
|
160
|
-
clubs.add( recs )
|
161
|
-
|
162
|
-
recs = SportDb::Import::WikiReader.parse( <<TXT )
|
163
|
-
==================================
|
164
|
-
= Belgium
|
165
|
-
|
166
|
-
R.S.C. Anderlecht
|
167
|
-
Club Brugge KV
|
168
|
-
TXT
|
169
|
-
clubs.add_wiki( recs )
|
170
|
-
|
171
|
-
|
172
|
-
m = clubs.match( 'Club Brugge KV' )
|
173
|
-
assert_equal 1, m.size
|
174
|
-
assert_equal 'Club Brugge KV', m[0].wikipedia
|
175
|
-
assert_equal 'https://en.wikipedia.org/wiki/Club_Brugge_KV', m[0].wikipedia_url
|
176
|
-
|
177
|
-
m = clubs.match( 'RSC Anderlecht' )
|
178
|
-
assert_equal 1, m.size
|
179
|
-
assert_equal 'R.S.C. Anderlecht', m[0].wikipedia
|
180
|
-
assert_equal 'https://en.wikipedia.org/wiki/R.S.C._Anderlecht', m[0].wikipedia_url
|
181
|
-
end
|
182
|
-
|
183
|
-
end # class TestClubIndex
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_club_index_history.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestClubHistoryIndex < MiniTest::Test
|
11
|
-
|
12
|
-
def test_eng
|
13
|
-
txt =<<TXT
|
14
|
-
= England
|
15
|
-
|
16
|
-
## note: use history log by season (instead of by year) - why? why not?
|
17
|
-
##
|
18
|
-
## note/warn/remember !! a line starting with arrow (=>)
|
19
|
-
## will get turned into a heading 1!!!
|
20
|
-
## as an ascii-alternative to ⇒ use >> or -> or ??? - why? why not?
|
21
|
-
|
22
|
-
== 1930/1
|
23
|
-
MOVE South Shields FC, South Shields ⇒ Gateshead FC, Gateshead
|
24
|
-
|
25
|
-
|
26
|
-
== 1929/30
|
27
|
-
RENAME The Wednesday FC, Sheffield ⇒ Sheffield Wednesday
|
28
|
-
|
29
|
-
== 1927/8
|
30
|
-
RENAME The Arsenal FC, London ⇒ Arsenal FC
|
31
|
-
|
32
|
-
|
33
|
-
== 1914/5
|
34
|
-
RENAME Woolwich Arsenal FC, London ⇒ The Arsenal FC
|
35
|
-
|
36
|
-
|
37
|
-
== 1911/2
|
38
|
-
REFORM Burslem Port Vale FC, Burslem ⇒ Port Vale FC, Stoke-on-Trent
|
39
|
-
## the towns of Burslem having been merged in 1910 with the towns of Fenton, Hanley,
|
40
|
-
## Longton, Stoke-upon-Trent and Tunstall as the city of Stoke-on-Trent
|
41
|
-
|
42
|
-
|
43
|
-
== 1909/10
|
44
|
-
RENAME Chesterfield Town FC, Chesterfield ⇒ Chesterfield FC
|
45
|
-
|
46
|
-
|
47
|
-
== 1905/6
|
48
|
-
RENAME Chesterfield FC, Chesterfield ⇒ Chesterfield Town FC
|
49
|
-
Small Heath FC, Birmingham ⇒ Birmingham FC
|
50
|
-
|
51
|
-
== 1902/3
|
52
|
-
REFORM Newton Heath FC, Manchester ⇒ Manchester United
|
53
|
-
|
54
|
-
== 1901/2
|
55
|
-
MERGE Burton Swifts FC, Burton-upon-Trent
|
56
|
-
Burton Wanderers FC, Burton-upon-Trent
|
57
|
-
⇒ Burton United FC
|
58
|
-
|
59
|
-
BANKRUPT Newton Heath FC, Manchester
|
60
|
-
|
61
|
-
|
62
|
-
== 1899/00
|
63
|
-
MERGE Blackpool FC, Blackpool
|
64
|
-
South Shore FC, Blackpool
|
65
|
-
⇒ Blackpool FC
|
66
|
-
|
67
|
-
== 1898/9
|
68
|
-
RENAME Glossop North End FC, Glossop ⇒ Glossop FC
|
69
|
-
|
70
|
-
|
71
|
-
== 1895/6
|
72
|
-
RENAME Walsall Town Swifts FC, Walsall ⇒ Walsall FC
|
73
|
-
|
74
|
-
|
75
|
-
== 1894/5
|
76
|
-
REFORM Ardwick FC, Manchester ⇒ Manchester City FC
|
77
|
-
|
78
|
-
== 1893/4
|
79
|
-
BANKRUPT Ardwick FC, Manchester
|
80
|
-
|
81
|
-
MERGE Newcastle West End FC, Newcastle-upon-Tyne
|
82
|
-
Newcastle East End FC, Newcastle-upon-Tyne
|
83
|
-
⇒ Newcastle United FC
|
84
|
-
|
85
|
-
== 1892/3
|
86
|
-
RENAME Royal Arsenal FC, London ⇒ Woolwich Arsenal FC
|
87
|
-
TXT
|
88
|
-
|
89
|
-
recs = SportDb::Import::ClubHistoryReader.parse( txt )
|
90
|
-
|
91
|
-
history = SportDb::Import::ClubHistoryIndex.new
|
92
|
-
history.add( recs )
|
93
|
-
|
94
|
-
pp history.errors
|
95
|
-
pp history.mappings
|
96
|
-
|
97
|
-
# [[1927/28, ["RENAME", [["The Arsenal FC, London", "eng"], ["Arsenal FC", "eng"]]]],
|
98
|
-
# [1914/15, ["RENAME", [["Woolwich Arsenal FC, London", "eng"], ["The Arsenal FC", "eng"]]]],
|
99
|
-
# [1892/93, ["RENAME", [["Royal Arsenal FC, London", "eng"], ["Woolwich Arsenal FC", "eng"]]]]],
|
100
|
-
assert_equal 'Arsenal FC', history.find_name_by( name: 'Arsenal FC', season: '2000/1' )
|
101
|
-
assert_equal 'Arsenal FC', history.find_name_by( name: 'Arsenal FC', season: '1927/8' )
|
102
|
-
assert_equal 'The Arsenal FC', history.find_name_by( name: 'Arsenal FC', season: '1926/7' )
|
103
|
-
assert_equal 'Woolwich Arsenal FC', history.find_name_by( name: 'Arsenal FC', season: '1913/4' )
|
104
|
-
assert_equal 'Royal Arsenal FC', history.find_name_by( name: 'Arsenal FC', season: '1891/2' )
|
105
|
-
end
|
106
|
-
|
107
|
-
end # class TestClubHistoryIndex
|
data/test/test_club_reader.rb
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_club_reader.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestClubReader < MiniTest::Test
|
11
|
-
|
12
|
-
def test_parse_ii ## test club/team B/II
|
13
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
14
|
-
= Austria
|
15
|
-
|
16
|
-
FK Austria Wien, Wien
|
17
|
-
| Austria Vienna | Austria Wien
|
18
|
-
Fischhofgasse 12 ~ 1100 Wien ## address line style a
|
19
|
-
Fischhofgasse 12 ++ 1100 Wien ## address line style b
|
20
|
-
Fischhofgasse 12 // 1100 Wien ## address line style c
|
21
|
-
(ii) Young Violets Austria Wien
|
22
|
-
| Young Violets A. W.
|
23
|
-
|
24
|
-
SK Rapid Wien, Wien
|
25
|
-
| Rapid Vienna | Rapid Wien
|
26
|
-
Keisslergasse 3 ~ 1140 Wien ## address line style a
|
27
|
-
Keisslergasse 3 +++ 1140 Wien ## address line style b
|
28
|
-
Keisslergasse 3 /// 1140 Wien ## address line style c
|
29
|
-
(2) SK Rapid Wien II
|
30
|
-
| Rapid Wien Am.
|
31
|
-
TXT
|
32
|
-
|
33
|
-
pp recs
|
34
|
-
|
35
|
-
assert_equal 4, recs.size
|
36
|
-
assert_equal 'FK Austria Wien', recs[0].name
|
37
|
-
assert_equal 'Young Violets Austria Wien', recs[0].b.name
|
38
|
-
assert_equal 'Wien', recs[0].city
|
39
|
-
assert recs[0].a?
|
40
|
-
assert recs[0].b? == false
|
41
|
-
|
42
|
-
assert_equal 'Young Violets Austria Wien', recs[1].name
|
43
|
-
assert_equal 'FK Austria Wien', recs[1].a.name
|
44
|
-
assert_equal 'Wien', recs[1].city
|
45
|
-
assert recs[1].a? == false
|
46
|
-
assert recs[1].b?
|
47
|
-
|
48
|
-
|
49
|
-
assert_equal 'SK Rapid Wien', recs[2].name
|
50
|
-
assert_equal 'SK Rapid Wien II', recs[2].b.name
|
51
|
-
assert_equal 'Wien', recs[2].city
|
52
|
-
assert recs[2].a?
|
53
|
-
assert recs[2].b? == false
|
54
|
-
|
55
|
-
assert_equal 'SK Rapid Wien II', recs[3].name
|
56
|
-
assert_equal 'SK Rapid Wien', recs[3].a.name
|
57
|
-
assert_equal 'Wien', recs[3].city
|
58
|
-
assert recs[3].a? == false
|
59
|
-
assert recs[3].b?
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_parse_at
|
63
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
64
|
-
==================================
|
65
|
-
= Austria
|
66
|
-
|
67
|
-
FK Austria Wien, Wien
|
68
|
-
| Austria Vienna | Austria Wien
|
69
|
-
SK Rapid Wien, Wien
|
70
|
-
| Rapid Vienna | Rapid Wien
|
71
|
-
Wiener Sport-Club, Wien
|
72
|
-
TXT
|
73
|
-
|
74
|
-
pp recs
|
75
|
-
|
76
|
-
assert_equal 3, recs.size
|
77
|
-
assert_equal 'FK Austria Wien', recs[0].name
|
78
|
-
assert_equal 'Wien', recs[0].city
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_parse_us
|
82
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
83
|
-
==================================================
|
84
|
-
= United States
|
85
|
-
|
86
|
-
#######################################
|
87
|
-
# Major League Soccer (MLS) teams
|
88
|
-
|
89
|
-
Atlanta United FC, 2017, Atlanta › Georgia
|
90
|
-
| Atlanta United
|
91
|
-
Chicago Fire, 1998, Bridgeview › Illinois
|
92
|
-
FC Dallas, 1996, Frisco › Texas ## note: FC Dallas named >Dallas Burn< from 1996-2004
|
93
|
-
|
94
|
-
##################################
|
95
|
-
# Defunct / Historic
|
96
|
-
Miami Fusion (1998-2001), Fort Lauderdale › Florida
|
97
|
-
CD Chivas USA (2005-2014), Carson › California
|
98
|
-
| Chivas USA
|
99
|
-
TXT
|
100
|
-
|
101
|
-
pp recs
|
102
|
-
|
103
|
-
assert_equal 5, recs.size
|
104
|
-
assert_equal 'Atlanta United FC', recs[0].name
|
105
|
-
assert_equal 2017, recs[0].year
|
106
|
-
assert_equal 'Atlanta', recs[0].city
|
107
|
-
assert_equal ['Georgia'], recs[0].geos
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
def test_parse_years
|
112
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
113
|
-
= United States
|
114
|
-
FC Dallas (1996-), Frisco › Texas
|
115
|
-
Miami Fusion (1998-2001), Fort Lauderdale › Florida
|
116
|
-
CD Chivas USA (-2014), Carson › California
|
117
|
-
TXT
|
118
|
-
|
119
|
-
pp recs
|
120
|
-
|
121
|
-
assert_equal 3, recs.size
|
122
|
-
assert_equal 1996, recs[0].year
|
123
|
-
assert_equal false, recs[0].historic?
|
124
|
-
assert_equal false, recs[0].past?
|
125
|
-
|
126
|
-
assert_equal 1998, recs[1].year
|
127
|
-
assert_equal 2001, recs[1].year_end
|
128
|
-
assert_equal true, recs[1].historic?
|
129
|
-
assert_equal true, recs[1].past?
|
130
|
-
|
131
|
-
assert_equal 2014, recs[2].year_end
|
132
|
-
assert_equal true, recs[2].historic?
|
133
|
-
assert_equal true, recs[2].past?
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_parse_geos
|
137
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
138
|
-
= England
|
139
|
-
== Greater London
|
140
|
-
|
141
|
-
Fulham FC, 1879, @ Craven Cottage, London (Fulham) › Greater London
|
142
|
-
| Fulham | FC Fulham
|
143
|
-
Charlton Athletic FC, @ The Valley, London (Charlton) › Greater London
|
144
|
-
| Charlton | Charlton Athletic
|
145
|
-
|
146
|
-
= Deutschland
|
147
|
-
== Hamburg
|
148
|
-
|
149
|
-
St. Pauli, Hamburg (St. Pauli)
|
150
|
-
TXT
|
151
|
-
|
152
|
-
pp recs
|
153
|
-
|
154
|
-
assert_equal 3, recs.size
|
155
|
-
assert_equal 'London', recs[0].city
|
156
|
-
assert_equal 'Fulham', recs[0].district
|
157
|
-
assert_equal ['Greater London'], recs[0].geos
|
158
|
-
assert_equal 'England', recs[0].country.name
|
159
|
-
assert_equal 'eng', recs[0].country.key
|
160
|
-
|
161
|
-
assert_equal 'London', recs[1].city
|
162
|
-
assert_equal 'Charlton', recs[1].district
|
163
|
-
assert_equal ['Greater London'], recs[1].geos
|
164
|
-
assert_equal 'England', recs[1].country.name
|
165
|
-
assert_equal 'eng', recs[1].country.key
|
166
|
-
|
167
|
-
assert_equal 'Hamburg', recs[2].city
|
168
|
-
assert_equal 'St. Pauli', recs[2].district
|
169
|
-
assert_equal ['Hamburg'], recs[2].geos
|
170
|
-
assert_equal 'Germany', recs[2].country.name
|
171
|
-
assert_equal 'de', recs[2].country.key
|
172
|
-
end
|
173
|
-
|
174
|
-
|
175
|
-
def test_parse_headings
|
176
|
-
recs = SportDb::Import::ClubReader.parse( <<TXT )
|
177
|
-
==============
|
178
|
-
====
|
179
|
-
===========
|
180
|
-
## note: Heading 1 - always expects / requires country as text for now
|
181
|
-
= Austria
|
182
|
-
= Austria ==================
|
183
|
-
== Heading 2
|
184
|
-
== Heading 2 =========
|
185
|
-
=== Heading 3
|
186
|
-
=== Heading 3 ===============
|
187
|
-
=== Heading 3 # with end-of-line comment
|
188
|
-
=== Heading 3 ## with end-of-line comment
|
189
|
-
=== Heading 3 ========= # with end-of-line comment
|
190
|
-
== Heading 2
|
191
|
-
==== Heading 4
|
192
|
-
= ?????
|
193
|
-
== ???
|
194
|
-
TXT
|
195
|
-
|
196
|
-
pp recs
|
197
|
-
|
198
|
-
assert_equal 0, recs.size
|
199
|
-
end
|
200
|
-
|
201
|
-
end # class TestClubReader
|