sportdb-formats 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sportdb/formats/country/country_reader.rb +142 -142
- data/lib/sportdb/formats/datafile.rb +59 -59
- data/lib/sportdb/formats/event/event_index.rb +141 -141
- data/lib/sportdb/formats/event/event_reader.rb +183 -183
- data/lib/sportdb/formats/league/league_outline_reader.rb +1 -0
- data/lib/sportdb/formats/league/league_reader.rb +168 -168
- data/lib/sportdb/formats/match/match_parser_auto_conf.rb +202 -202
- data/lib/sportdb/formats/package.rb +374 -374
- data/lib/sportdb/formats/team/club_index_history.rb +134 -134
- data/lib/sportdb/formats/team/club_reader.rb +350 -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 +1 -1
- data/test/test_club_index_history.rb +107 -107
- data/test/test_club_reader.rb +201 -201
- data/test/test_club_reader_history.rb +212 -212
- data/test/test_country_reader.rb +89 -89
- data/test/test_league_outline_reader.rb +55 -55
- data/test/test_league_reader.rb +72 -72
- data/test/test_outline_reader.rb +31 -31
- data/test/test_regex.rb +67 -67
- data/test/test_wiki_reader.rb +77 -77
- metadata +12 -6
@@ -1,107 +1,107 @@
|
|
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
|
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
CHANGED
@@ -1,201 +1,201 @@
|
|
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
|
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
|