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.
- checksums.yaml +4 -4
- data/Manifest.txt +21 -0
- data/lib/sportdb/formats.rb +63 -0
- data/lib/sportdb/formats/country/country_index.rb +192 -0
- data/lib/sportdb/formats/country/country_reader.rb +122 -0
- data/lib/sportdb/formats/league/league_index.rb +174 -0
- data/lib/sportdb/formats/league/league_outline_reader.rb +141 -0
- data/lib/sportdb/formats/league/league_reader.rb +162 -0
- data/lib/sportdb/formats/team/club_index.rb +336 -0
- data/lib/sportdb/formats/team/club_reader.rb +350 -0
- data/lib/sportdb/formats/team/club_reader_props.rb +75 -0
- data/lib/sportdb/formats/team/national_team_index.rb +114 -0
- data/lib/sportdb/formats/team/team_index.rb +43 -0
- data/lib/sportdb/formats/team/wiki_reader.rb +108 -0
- data/lib/sportdb/formats/version.rb +1 -1
- data/test/helper.rb +72 -0
- data/test/test_club_index.rb +183 -0
- data/test/test_club_reader.rb +201 -0
- data/test/test_club_reader_props.rb +54 -0
- data/test/test_country_index.rb +63 -0
- data/test/test_country_reader.rb +59 -0
- data/test/test_league_index.rb +157 -0
- data/test/test_league_outline_reader.rb +55 -0
- data/test/test_league_reader.rb +72 -0
- data/test/test_regex.rb +49 -0
- data/test/test_wiki_reader.rb +77 -0
- metadata +22 -1
@@ -0,0 +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
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_club_reader_props.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestClubPropsReader < MiniTest::Test
|
11
|
+
|
12
|
+
ENG_CLUBS_PROPS_TXT =<<TXT
|
13
|
+
####################################
|
14
|
+
# English League Teams
|
15
|
+
#
|
16
|
+
# note: three letter codes (tags) taken from official premierleague.com site
|
17
|
+
|
18
|
+
Key, Name, Code
|
19
|
+
chelsea, Chelsea FC, CHE
|
20
|
+
arsenal, Arsenal FC, ARS
|
21
|
+
tottenham, Tottenham Hotspur, TOT
|
22
|
+
westham, West Ham United, WHU
|
23
|
+
crystalpalace, Crystal Palace, CRY
|
24
|
+
manutd, Manchester United, MUN
|
25
|
+
mancity, Manchester City, MCI
|
26
|
+
TXT
|
27
|
+
|
28
|
+
def test_parse_csv
|
29
|
+
recs = parse_csv( ENG_CLUBS_PROPS_TXT )
|
30
|
+
pp recs
|
31
|
+
|
32
|
+
assert_equal [{ key: 'chelsea', name: 'Chelsea FC', code: 'CHE' },
|
33
|
+
{ key: 'arsenal', name: 'Arsenal FC', code: 'ARS' }], recs[0..1]
|
34
|
+
end
|
35
|
+
|
36
|
+
CLUBS = SportDb::Import.catalog.clubs
|
37
|
+
|
38
|
+
def test_parse
|
39
|
+
SportDb::Import::ClubPropsReader.parse( ENG_CLUBS_PROPS_TXT )
|
40
|
+
|
41
|
+
m = CLUBS.match( 'Chelsea FC' )
|
42
|
+
club = m[0]
|
43
|
+
assert_equal 'chelsea', club.key
|
44
|
+
assert_equal 'Chelsea FC', club.name
|
45
|
+
assert_equal 'CHE', club.code
|
46
|
+
|
47
|
+
m = CLUBS.match( 'Arsenal FC' )
|
48
|
+
club = m[0]
|
49
|
+
assert_equal 'arsenal', club.key
|
50
|
+
assert_equal 'Arsenal FC', club.name
|
51
|
+
assert_equal 'ARS', club.code
|
52
|
+
end # method test_parse
|
53
|
+
|
54
|
+
end # class TestClubPropsProps
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_country_index.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestCountryIndex < MiniTest::Test
|
11
|
+
|
12
|
+
def test_countries
|
13
|
+
recs = SportDb::Import::CountryReader.read( "#{SportDb::Test.data_dir}/world/countries.txt" )
|
14
|
+
countries = SportDb::Import::CountryIndex.new( recs )
|
15
|
+
|
16
|
+
eng = countries[:eng]
|
17
|
+
assert_equal 'eng', eng.key
|
18
|
+
assert_equal 'England', eng.name
|
19
|
+
assert_equal 'ENG', eng.fifa
|
20
|
+
|
21
|
+
at = countries[:at]
|
22
|
+
assert_equal 'at', at.key
|
23
|
+
assert_equal 'Austria', at.name
|
24
|
+
assert_equal 'AUT', at.fifa
|
25
|
+
assert_equal ['Österreich [de]'], at.alt_names
|
26
|
+
|
27
|
+
assert at == countries['AT']
|
28
|
+
assert at == countries['at']
|
29
|
+
assert at == countries['AUT']
|
30
|
+
assert at == countries['aut']
|
31
|
+
assert at == countries[:aut]
|
32
|
+
|
33
|
+
assert at == countries[:austria]
|
34
|
+
assert at == countries['...A.u.s.t.r.i.a...']
|
35
|
+
assert at == countries['Österreich'] ## Austria in German [de]
|
36
|
+
|
37
|
+
assert at == countries.find_by_code( 'AT' )
|
38
|
+
assert at == countries.find_by_code( 'at' )
|
39
|
+
assert at == countries.find_by_code( 'AUT' )
|
40
|
+
assert at == countries.find_by_code( 'aut' )
|
41
|
+
assert at == countries.find_by_code( :aut )
|
42
|
+
|
43
|
+
assert at == countries.find_by_name( :austria )
|
44
|
+
assert at == countries.find_by_name( '...A.u.s.t.r.i.a...' )
|
45
|
+
assert at == countries.find_by_name( 'Österreich' ) ## Austria in German [de]
|
46
|
+
|
47
|
+
assert at == countries.parse( 'Österreich • Austria (at)' )
|
48
|
+
assert at == countries.parse( 'Österreich • Austria' )
|
49
|
+
assert at == countries.parse( 'Austria' )
|
50
|
+
assert at == countries.parse( 'at' ) ## (iso alpha2) country code
|
51
|
+
assert at == countries.parse( 'AUT' ) ## fifa code
|
52
|
+
|
53
|
+
|
54
|
+
de = countries[:de]
|
55
|
+
assert_equal 'de', de.key
|
56
|
+
assert_equal 'Germany', de.name
|
57
|
+
assert_equal 'GER', de.fifa
|
58
|
+
assert_equal ['Deutschland [de]'], de.alt_names
|
59
|
+
|
60
|
+
assert de == countries.parse( 'Deutschland (de) • Germany' )
|
61
|
+
end
|
62
|
+
|
63
|
+
end # class TestCountryIndex
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_country_reader.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestCountryReader < MiniTest::Test
|
11
|
+
|
12
|
+
def test_read
|
13
|
+
recs = SportDb::Import::CountryReader.read( "#{SportDb::Test.data_dir}/world/countries.txt" )
|
14
|
+
pp recs
|
15
|
+
|
16
|
+
assert_equal 232, recs.size
|
17
|
+
|
18
|
+
assert_equal 'Albania', recs[0].name
|
19
|
+
assert_equal 'ALB', recs[0].fifa
|
20
|
+
assert_equal 'al', recs[0].key
|
21
|
+
assert_equal ['fifa', 'uefa'], recs[0].tags
|
22
|
+
|
23
|
+
assert_equal 'Andorra', recs[1].name
|
24
|
+
assert_equal 'AND', recs[1].fifa
|
25
|
+
assert_equal 'ad', recs[1].key
|
26
|
+
assert_equal ['fifa', 'uefa'], recs[1].tags
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_parse
|
30
|
+
recs = SportDb::Import::CountryReader.parse( <<TXT )
|
31
|
+
#####
|
32
|
+
# FIFA countries and codes
|
33
|
+
|
34
|
+
# Key Name, FIFA
|
35
|
+
|
36
|
+
af Afghanistan, AFG, fifa › afc
|
37
|
+
al Albania, ALB, fifa › uefa
|
38
|
+
dz Algeria, ALG, fifa › caf
|
39
|
+
as American Samoa › US, ASA,
|
40
|
+
| Am. Samoa
|
41
|
+
TXT
|
42
|
+
|
43
|
+
pp recs
|
44
|
+
|
45
|
+
assert_equal 4, recs.size
|
46
|
+
assert_equal 'Afghanistan', recs[0].name
|
47
|
+
assert_equal 'AFG', recs[0].fifa
|
48
|
+
assert_equal 'af', recs[0].key
|
49
|
+
assert_equal [], recs[0].alt_names
|
50
|
+
assert_equal ['fifa', 'afc'], recs[0].tags
|
51
|
+
|
52
|
+
assert_equal 'American Samoa', recs[3].name
|
53
|
+
assert_equal 'ASA', recs[3].fifa
|
54
|
+
assert_equal 'as', recs[3].key
|
55
|
+
assert_equal ['Am. Samoa'], recs[3].alt_names
|
56
|
+
assert_equal [], recs[3].tags
|
57
|
+
end
|
58
|
+
|
59
|
+
end # class TestCountryReader
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_league_index.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestLeagueIndex < MiniTest::Test
|
11
|
+
|
12
|
+
def test_match
|
13
|
+
recs = SportDb::Import::LeagueReader.parse( <<TXT )
|
14
|
+
= England =
|
15
|
+
1 English Premier League
|
16
|
+
| ENG PL | England Premier League | Premier League
|
17
|
+
2 English Championship
|
18
|
+
| ENG CS | England Championship | Championship
|
19
|
+
3 English League One
|
20
|
+
| England League One | League One
|
21
|
+
4 English League Two
|
22
|
+
5 English National League
|
23
|
+
|
24
|
+
cup EFL Cup
|
25
|
+
| League Cup | Football League Cup
|
26
|
+
| ENG LC | England Liga Cup
|
27
|
+
|
28
|
+
= Scotland =
|
29
|
+
1 Scottish Premiership
|
30
|
+
2 Scottish Championship
|
31
|
+
3 Scottish League One
|
32
|
+
4 Scottish League Two
|
33
|
+
TXT
|
34
|
+
|
35
|
+
leagues = SportDb::Import::LeagueIndex.new
|
36
|
+
leagues.add( recs )
|
37
|
+
|
38
|
+
pp leagues.errors
|
39
|
+
|
40
|
+
leagues.dump_duplicates
|
41
|
+
|
42
|
+
m = leagues.match( 'English Premier League' )
|
43
|
+
assert_equal 'English Premier League', m[0].name
|
44
|
+
assert_equal 'eng.1', m[0].key
|
45
|
+
assert_equal 'England', m[0].country.name
|
46
|
+
assert_equal 'eng', m[0].country.key
|
47
|
+
|
48
|
+
m = leagues.match( 'english premier league' )
|
49
|
+
assert_equal 'English Premier League', m[0].name
|
50
|
+
assert_equal 'eng.1', m[0].key
|
51
|
+
assert_equal 'England', m[0].country.name
|
52
|
+
assert_equal 'eng', m[0].country.key
|
53
|
+
|
54
|
+
m = leagues.match( 'englishpremierleague' )
|
55
|
+
assert_equal 'English Premier League', m[0].name
|
56
|
+
assert_equal 'eng.1', m[0].key
|
57
|
+
assert_equal 'England', m[0].country.name
|
58
|
+
assert_equal 'eng', m[0].country.key
|
59
|
+
|
60
|
+
## note: all dots (.) get always removed
|
61
|
+
m = leagues.match( '...e.n.g.l.i.s.h.p.r.e.m.i.e.r.l.e.a.g.u.e...' )
|
62
|
+
assert_equal 'English Premier League', m[0].name
|
63
|
+
assert_equal 'eng.1', m[0].key
|
64
|
+
assert_equal 'England', m[0].country.name
|
65
|
+
assert_equal 'eng', m[0].country.key
|
66
|
+
|
67
|
+
## note: all spaces and dashes (-) get always removed
|
68
|
+
m = leagues.match( '--- e n g l i s h p r e m i e r l e a g u e ---' )
|
69
|
+
assert_equal 'English Premier League', m[0].name
|
70
|
+
assert_equal 'eng.1', m[0].key
|
71
|
+
assert_equal 'England', m[0].country.name
|
72
|
+
assert_equal 'eng', m[0].country.key
|
73
|
+
|
74
|
+
m = leagues.match( 'ENGLISH PREMIER LEAGUE' )
|
75
|
+
assert_equal 'English Premier League', m[0].name
|
76
|
+
assert_equal 'eng.1', m[0].key
|
77
|
+
assert_equal 'England', m[0].country.name
|
78
|
+
assert_equal 'eng', m[0].country.key
|
79
|
+
|
80
|
+
## check alt names
|
81
|
+
m = leagues.match( 'ENG PL' )
|
82
|
+
assert_equal 'English Premier League', m[0].name
|
83
|
+
assert_equal 'eng.1', m[0].key
|
84
|
+
assert_equal 'England', m[0].country.name
|
85
|
+
assert_equal 'eng', m[0].country.key
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_match_by
|
89
|
+
recs = SportDb::Import::LeagueReader.parse( <<TXT )
|
90
|
+
= Germany =
|
91
|
+
1 Bundesliga
|
92
|
+
|
93
|
+
= Austria =
|
94
|
+
1 Bundesliga
|
95
|
+
|
96
|
+
= England =
|
97
|
+
1 English Premier League
|
98
|
+
| Premier League
|
99
|
+
|
100
|
+
= Wales =
|
101
|
+
1 Welsh Premier League
|
102
|
+
| Premier League
|
103
|
+
TXT
|
104
|
+
|
105
|
+
leagues = SportDb::Import::LeagueIndex.new
|
106
|
+
leagues.add( recs )
|
107
|
+
|
108
|
+
pp leagues.errors
|
109
|
+
|
110
|
+
leagues.dump_duplicates
|
111
|
+
|
112
|
+
m = leagues.match( 'Bundesliga' )
|
113
|
+
assert_equal 2, m.size
|
114
|
+
|
115
|
+
m = leagues.match( 'AT' ) ## check auto-generated/added shortcut names
|
116
|
+
assert_equal 1, m.size
|
117
|
+
assert_equal 'Bundesliga', m[0].name
|
118
|
+
m = leagues.match( 'AT 1' )
|
119
|
+
assert_equal 1, m.size
|
120
|
+
assert_equal 'Bundesliga', m[0].name
|
121
|
+
m = leagues.match( 'AUT' )
|
122
|
+
assert_equal 1, m.size
|
123
|
+
assert_equal 'Bundesliga', m[0].name
|
124
|
+
m = leagues.match( 'AUT 1' )
|
125
|
+
assert_equal 1, m.size
|
126
|
+
assert_equal 'Bundesliga', m[0].name
|
127
|
+
m = leagues.match( 'Austria 1' )
|
128
|
+
assert_equal 1, m.size
|
129
|
+
assert_equal 'Bundesliga', m[0].name
|
130
|
+
|
131
|
+
|
132
|
+
m = leagues.match_by( name: 'Bundesliga', country: 'at' )
|
133
|
+
assert_equal 1, m.size
|
134
|
+
m = leagues.match_by( name: 'Bundesliga', country: 'de' )
|
135
|
+
assert_equal 1, m.size
|
136
|
+
|
137
|
+
|
138
|
+
m = leagues.match( 'Premier League' )
|
139
|
+
assert_equal 2, m.size
|
140
|
+
|
141
|
+
m = leagues.match( 'ENG' ) ## check auto-generated/added shortcut names
|
142
|
+
assert_equal 1, m.size
|
143
|
+
assert_equal 'English Premier League', m[0].name
|
144
|
+
m = leagues.match( 'ENG 1' )
|
145
|
+
assert_equal 1, m.size
|
146
|
+
assert_equal 'English Premier League', m[0].name
|
147
|
+
m = leagues.match( 'England 1' )
|
148
|
+
assert_equal 1, m.size
|
149
|
+
assert_equal 'English Premier League', m[0].name
|
150
|
+
|
151
|
+
m = leagues.match_by( name: 'Premier League', country: 'eng' )
|
152
|
+
assert_equal 1, m.size
|
153
|
+
m = leagues.match_by( name: 'Premier League', country: 'wal' )
|
154
|
+
assert_equal 1, m.size
|
155
|
+
end
|
156
|
+
|
157
|
+
end # class TestLeagueIndex
|