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
@@ -1,212 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_club_reader_history.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestClubHistoryReader < MiniTest::Test
|
12
|
-
|
13
|
-
def test_parse_eng
|
14
|
-
txt =<<TXT
|
15
|
-
= England
|
16
|
-
|
17
|
-
## note: use history log by season (instead of by year) - why? why not?
|
18
|
-
##
|
19
|
-
## note/warn/remember !! a line starting with arrow (=>)
|
20
|
-
## will get turned into a heading 1!!!
|
21
|
-
## as an ascii-alternative to ⇒ use >> or -> or ??? - why? why not?
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
== 1958/9
|
26
|
-
RENAME Scunthorpe & Lindsey United FC, Scunthorpe ⇒ Scunthorpe United FC
|
27
|
-
|
28
|
-
== 1946/7
|
29
|
-
RENAME Clapton Orient FC, London ⇒ Leyton Orient FC
|
30
|
-
|
31
|
-
== 1945/6
|
32
|
-
RENAME Birmingham FC, Birmingham ⇒ Birmingham City FC
|
33
|
-
|
34
|
-
== 1930/1
|
35
|
-
MOVE South Shields FC, South Shields ⇒ Gateshead FC, Gateshead
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
== 1929/30
|
40
|
-
RENAME The Wednesday FC, Sheffield ⇒ Sheffield Wednesday
|
41
|
-
|
42
|
-
== 1927/8
|
43
|
-
RENAME The Arsenal FC, London ⇒ Arsenal FC
|
44
|
-
|
45
|
-
== 1925/6
|
46
|
-
RENAME Millwall Athletic FC, London ⇒ Millwall FC
|
47
|
-
Stoke FC, Stoke-on-Trent ⇒ Stoke City FC
|
48
|
-
|
49
|
-
MERGE Rotherham County FC, Rotherham
|
50
|
-
Rotherham Town FC, Rotherham
|
51
|
-
⇒ Rotherham United FC
|
52
|
-
|
53
|
-
== 1914/5
|
54
|
-
RENAME Woolwich Arsenal FC, London ⇒ The Arsenal FC
|
55
|
-
|
56
|
-
|
57
|
-
== 1911/2
|
58
|
-
REFORM Burslem Port Vale FC, Burslem ⇒ Port Vale FC, Stoke-on-Trent
|
59
|
-
## the towns of Burslem having been merged in 1910 with the towns of Fenton, Hanley,
|
60
|
-
## Longton, Stoke-upon-Trent and Tunstall as the city of Stoke-on-Trent
|
61
|
-
|
62
|
-
|
63
|
-
== 1909/10
|
64
|
-
RENAME Chesterfield Town FC, Chesterfield ⇒ Chesterfield FC
|
65
|
-
|
66
|
-
|
67
|
-
== 1905/6
|
68
|
-
RENAME Chesterfield FC, Chesterfield ⇒ Chesterfield Town FC
|
69
|
-
Small Heath FC, Birmingham ⇒ Birmingham FC
|
70
|
-
|
71
|
-
== 1902/3
|
72
|
-
REFORM Newton Heath FC, Manchester ⇒ Manchester United
|
73
|
-
|
74
|
-
== 1901/2
|
75
|
-
MERGE Burton Swifts FC, Burton-upon-Trent
|
76
|
-
Burton Wanderers FC, Burton-upon-Trent
|
77
|
-
⇒ Burton United FC
|
78
|
-
|
79
|
-
BANKRUPT Newton Heath FC, Manchester
|
80
|
-
|
81
|
-
|
82
|
-
== 1899/00
|
83
|
-
RENAME Barnsley St. Peter's FC, Barnsley ⇒ Barnsley FC
|
84
|
-
|
85
|
-
MERGE Blackpool FC, Blackpool
|
86
|
-
South Shore FC, Blackpool
|
87
|
-
⇒ Blackpool FC
|
88
|
-
|
89
|
-
== 1898/9
|
90
|
-
RENAME Glossop North End FC, Glossop ⇒ Glossop FC
|
91
|
-
|
92
|
-
|
93
|
-
== 1895/6
|
94
|
-
RENAME Walsall Town Swifts FC, Walsall ⇒ Walsall FC
|
95
|
-
|
96
|
-
|
97
|
-
== 1894/5
|
98
|
-
REFORM Ardwick FC, Manchester ⇒ Manchester City FC
|
99
|
-
|
100
|
-
== 1893/4
|
101
|
-
BANKRUPT Ardwick FC, Manchester
|
102
|
-
|
103
|
-
MERGE Newcastle West End FC, Newcastle-upon-Tyne
|
104
|
-
Newcastle East End FC, Newcastle-upon-Tyne
|
105
|
-
⇒ Newcastle United FC
|
106
|
-
|
107
|
-
== 1892/3
|
108
|
-
RENAME Royal Arsenal FC, London ⇒ Woolwich Arsenal FC
|
109
|
-
TXT
|
110
|
-
|
111
|
-
recs = SportDb::Import::ClubHistoryReader.parse( txt )
|
112
|
-
|
113
|
-
pp recs
|
114
|
-
|
115
|
-
exp = [["RENAME", "1958/59",
|
116
|
-
["Scunthorpe & Lindsey United FC, Scunthorpe", "eng"],
|
117
|
-
["Scunthorpe United FC", "eng"]],
|
118
|
-
["RENAME", "1946/47",
|
119
|
-
["Clapton Orient FC, London", "eng"],
|
120
|
-
["Leyton Orient FC", "eng"]],
|
121
|
-
["RENAME", "1945/46",
|
122
|
-
["Birmingham FC, Birmingham", "eng"],
|
123
|
-
["Birmingham City FC", "eng"]],
|
124
|
-
["MOVE", "1930/31",
|
125
|
-
["South Shields FC, South Shields", "eng"],
|
126
|
-
["Gateshead FC, Gateshead", "eng"]],
|
127
|
-
["RENAME",
|
128
|
-
"1929/30",
|
129
|
-
["The Wednesday FC, Sheffield", "eng"],
|
130
|
-
["Sheffield Wednesday", "eng"]],
|
131
|
-
["RENAME",
|
132
|
-
"1927/28",
|
133
|
-
["The Arsenal FC, London", "eng"],
|
134
|
-
["Arsenal FC", "eng"]],
|
135
|
-
["RENAME",
|
136
|
-
"1925/26",
|
137
|
-
["Millwall Athletic FC, London", "eng"],
|
138
|
-
["Millwall FC", "eng"]],
|
139
|
-
["RENAME",
|
140
|
-
"1925/26",
|
141
|
-
["Stoke FC, Stoke-on-Trent", "eng"],
|
142
|
-
["Stoke City FC", "eng"]],
|
143
|
-
["MERGE",
|
144
|
-
"1925/26",
|
145
|
-
[["Rotherham County FC, Rotherham", "eng"],
|
146
|
-
["Rotherham Town FC, Rotherham", "eng"]],
|
147
|
-
["Rotherham United FC", "eng"]],
|
148
|
-
["RENAME",
|
149
|
-
"1914/15",
|
150
|
-
["Woolwich Arsenal FC, London", "eng"],
|
151
|
-
["The Arsenal FC", "eng"]],
|
152
|
-
["REFORM",
|
153
|
-
"1911/12",
|
154
|
-
["Burslem Port Vale FC, Burslem", "eng"],
|
155
|
-
["Port Vale FC, Stoke-on-Trent", "eng"]],
|
156
|
-
["RENAME",
|
157
|
-
"1909/10",
|
158
|
-
["Chesterfield Town FC, Chesterfield", "eng"],
|
159
|
-
["Chesterfield FC", "eng"]],
|
160
|
-
["RENAME",
|
161
|
-
"1905/06",
|
162
|
-
["Chesterfield FC, Chesterfield", "eng"],
|
163
|
-
["Chesterfield Town FC", "eng"]],
|
164
|
-
["RENAME",
|
165
|
-
"1905/06",
|
166
|
-
["Small Heath FC, Birmingham", "eng"],
|
167
|
-
["Birmingham FC", "eng"]],
|
168
|
-
["REFORM",
|
169
|
-
"1902/03",
|
170
|
-
["Newton Heath FC, Manchester", "eng"],
|
171
|
-
["Manchester United", "eng"]],
|
172
|
-
["MERGE",
|
173
|
-
"1901/02",
|
174
|
-
[["Burton Swifts FC, Burton-upon-Trent", "eng"],
|
175
|
-
["Burton Wanderers FC, Burton-upon-Trent", "eng"]],
|
176
|
-
["Burton United FC", "eng"]],
|
177
|
-
["BANKRUPT", "1901/02", ["Newton Heath FC, Manchester", "eng"]],
|
178
|
-
["RENAME",
|
179
|
-
"1899/00",
|
180
|
-
["Barnsley St. Peter's FC, Barnsley", "eng"],
|
181
|
-
["Barnsley FC", "eng"]],
|
182
|
-
["MERGE",
|
183
|
-
"1899/00",
|
184
|
-
[["Blackpool FC, Blackpool", "eng"], ["South Shore FC, Blackpool", "eng"]],
|
185
|
-
["Blackpool FC", "eng"]],
|
186
|
-
["RENAME",
|
187
|
-
"1898/99",
|
188
|
-
["Glossop North End FC, Glossop", "eng"],
|
189
|
-
["Glossop FC", "eng"]],
|
190
|
-
["RENAME",
|
191
|
-
"1895/96",
|
192
|
-
["Walsall Town Swifts FC, Walsall", "eng"],
|
193
|
-
["Walsall FC", "eng"]],
|
194
|
-
["REFORM",
|
195
|
-
"1894/95",
|
196
|
-
["Ardwick FC, Manchester", "eng"],
|
197
|
-
["Manchester City FC", "eng"]],
|
198
|
-
["BANKRUPT", "1893/94", ["Ardwick FC, Manchester", "eng"]],
|
199
|
-
["MERGE",
|
200
|
-
"1893/94",
|
201
|
-
[["Newcastle West End FC, Newcastle-upon-Tyne", "eng"],
|
202
|
-
["Newcastle East End FC, Newcastle-upon-Tyne", "eng"]],
|
203
|
-
["Newcastle United FC", "eng"]],
|
204
|
-
["RENAME",
|
205
|
-
"1892/93",
|
206
|
-
["Royal Arsenal FC, London", "eng"],
|
207
|
-
["Woolwich Arsenal FC", "eng"]]]
|
208
|
-
|
209
|
-
assert_equal exp, recs
|
210
|
-
end
|
211
|
-
|
212
|
-
end # class TestClubHistoryReader
|
@@ -1,54 +0,0 @@
|
|
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
|
data/test/test_country_index.rb
DELETED
@@ -1,63 +0,0 @@
|
|
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.code
|
20
|
-
|
21
|
-
at = countries[:at]
|
22
|
-
assert_equal 'at', at.key
|
23
|
-
assert_equal 'Austria', at.name
|
24
|
-
assert_equal 'AUT', at.code
|
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) country code
|
52
|
-
|
53
|
-
|
54
|
-
de = countries[:de]
|
55
|
-
assert_equal 'de', de.key
|
56
|
-
assert_equal 'Germany', de.name
|
57
|
-
assert_equal 'GER', de.code
|
58
|
-
assert_equal ['Deutschland [de]'], de.alt_names
|
59
|
-
|
60
|
-
assert de == countries.parse( 'Deutschland (de) • Germany' )
|
61
|
-
end
|
62
|
-
|
63
|
-
end # class TestCountryIndex
|
data/test/test_country_reader.rb
DELETED
@@ -1,89 +0,0 @@
|
|
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].code
|
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].code
|
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].code
|
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].code
|
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
|
-
def test_parse_historic
|
60
|
-
recs = SportDb::Import::CountryReader.parse( <<TXT )
|
61
|
-
###########################################
|
62
|
-
# Former national teams
|
63
|
-
# with former FIFA country codes etc.
|
64
|
-
-1992 Czechoslovakia, TCH ⇒ Czech Republic
|
65
|
-
|
66
|
-
-1991 Soviet Union, URS ⇒ Russia
|
67
|
-
|
68
|
-
-1989 West Germany, FRG => Germany
|
69
|
-
-1989 East Germany, GDR => Germany
|
70
|
-
TXT
|
71
|
-
|
72
|
-
pp recs
|
73
|
-
|
74
|
-
assert_equal 4, recs.size
|
75
|
-
assert_equal 'Czechoslovakia (-1992)', recs[0].name
|
76
|
-
assert_equal 'TCH', recs[0].code
|
77
|
-
assert_equal 'czechoslovakia', recs[0].key
|
78
|
-
assert_equal [], recs[0].alt_names
|
79
|
-
assert_equal [], recs[0].tags
|
80
|
-
|
81
|
-
assert_equal 'East Germany (-1989)', recs[3].name
|
82
|
-
assert_equal 'GDR', recs[3].code
|
83
|
-
assert_equal 'eastgermany', recs[3].key
|
84
|
-
assert_equal [], recs[3].alt_names
|
85
|
-
assert_equal [], recs[3].tags
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
end # class TestCountryReader
|
data/test/test_datafile.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_datafile.rb
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require 'helper'
|
10
|
-
|
11
|
-
class TestDatafile < MiniTest::Test
|
12
|
-
|
13
|
-
|
14
|
-
def test_exclude
|
15
|
-
assert Datafile::Package.match_exclude?( '.build/' )
|
16
|
-
assert Datafile::Package.match_exclude?( '.git/' )
|
17
|
-
assert Datafile::Package.exclude?( '.build/' )
|
18
|
-
assert Datafile::Package.exclude?( '.git/' )
|
19
|
-
|
20
|
-
|
21
|
-
assert Datafile::Package.match_exclude?( '/.build/' )
|
22
|
-
assert Datafile::Package.match_exclude?( '/.git/' )
|
23
|
-
|
24
|
-
assert Datafile::Package.match_exclude?( '.build/leagues.txt' )
|
25
|
-
assert Datafile::Package.match_exclude?( '.git/leagues.txt' )
|
26
|
-
|
27
|
-
assert Datafile::Package.match_exclude?( '/.build/leagues.txt' )
|
28
|
-
assert Datafile::Package.match_exclude?( '/.git/leagues.txt' )
|
29
|
-
end
|
30
|
-
end # class TestDatafile
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_datafile_package.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestDatafilePackage < MiniTest::Test
|
12
|
-
|
13
|
-
def test_read
|
14
|
-
[Datafile::DirPackage.new( '../../../openfootball/england' ),
|
15
|
-
Datafile::ZipPackage.new( 'tmp/england-master.zip' )
|
16
|
-
].each do |eng|
|
17
|
-
assert eng.find( '2015-16/.conf.txt' ).read.start_with?( '= English Premier League 2015/16' )
|
18
|
-
assert eng.find( '2017-18/.conf.txt' ).read.start_with?( '= English Premier League 2017/18' )
|
19
|
-
assert eng.find( '2015-16/1-premierleague.txt' ).read.start_with?( '= English Premier League 2015/16' )
|
20
|
-
end
|
21
|
-
|
22
|
-
[Datafile::DirPackage.new( '../../../openfootball/austria' ),
|
23
|
-
Datafile::ZipPackage.new( 'tmp/austria-master.zip' )
|
24
|
-
].each do |at|
|
25
|
-
assert at.find( '2018-19/.conf.txt' ).read.start_with?( '= Österr. Bundesliga 2018/19' )
|
26
|
-
end
|
27
|
-
|
28
|
-
puts "DirPackage:"
|
29
|
-
pack = Datafile::DirPackage.new( '../../../openfootball/austria' )
|
30
|
-
puts pack.name
|
31
|
-
puts " entries:"
|
32
|
-
pack.each( pattern: /\.txt$/ ) do |entry|
|
33
|
-
puts entry.name
|
34
|
-
end
|
35
|
-
|
36
|
-
puts "ZipPackage:"
|
37
|
-
pack = Datafile::ZipPackage.new( 'tmp/austria-master.zip' )
|
38
|
-
puts pack.name
|
39
|
-
puts " entries:"
|
40
|
-
pack.each( pattern: /\.txt$/ ) do |entry|
|
41
|
-
puts entry.name
|
42
|
-
end
|
43
|
-
|
44
|
-
end # method test_read
|
45
|
-
|
46
|
-
end # class TestDatafilePackage
|
data/test/test_goals.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_goals.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestGoals < MiniTest::Test
|
11
|
-
|
12
|
-
|
13
|
-
def test_world_cup_1930
|
14
|
-
line = " [L. Laurent 19' Langiller 40' Maschinot 43', 87'; Carreño 70']"
|
15
|
-
|
16
|
-
assert_equal [
|
17
|
-
SportDb::GoalStruct.new(
|
18
|
-
name: 'L. Laurent',
|
19
|
-
minute: 19,
|
20
|
-
offset: 0,
|
21
|
-
owngoal: false,
|
22
|
-
penalty: false,
|
23
|
-
score1: 1,
|
24
|
-
score2: 0,
|
25
|
-
team: 1),
|
26
|
-
SportDb::GoalStruct.new(
|
27
|
-
name: 'Langiller',
|
28
|
-
minute: 40,
|
29
|
-
offset: 0,
|
30
|
-
owngoal: false,
|
31
|
-
penalty: false,
|
32
|
-
score1: 2,
|
33
|
-
score2: 0,
|
34
|
-
team: 1),
|
35
|
-
SportDb::GoalStruct.new(
|
36
|
-
name: 'Maschinot',
|
37
|
-
minute: 43,
|
38
|
-
offset: 0,
|
39
|
-
owngoal: false,
|
40
|
-
penalty: false,
|
41
|
-
score1: 3,
|
42
|
-
score2: 0,
|
43
|
-
team: 1),
|
44
|
-
SportDb::GoalStruct.new(
|
45
|
-
name: 'Carreño',
|
46
|
-
minute: 70,
|
47
|
-
offset: 0,
|
48
|
-
owngoal: false,
|
49
|
-
penalty: false,
|
50
|
-
score1: 3,
|
51
|
-
score2: 1,
|
52
|
-
team: 2),
|
53
|
-
SportDb::GoalStruct.new(
|
54
|
-
name: 'Maschinot',
|
55
|
-
minute: 87,
|
56
|
-
offset: 0,
|
57
|
-
owngoal: false,
|
58
|
-
penalty: false,
|
59
|
-
score1: 4,
|
60
|
-
score2: 1,
|
61
|
-
team: 1)], parse_goals( line )
|
62
|
-
|
63
|
-
|
64
|
-
line = " [Monti 81'] "
|
65
|
-
assert_equal [
|
66
|
-
SportDb::GoalStruct.new(
|
67
|
-
name: 'Monti',
|
68
|
-
minute: 81,
|
69
|
-
offset: 0,
|
70
|
-
owngoal: false,
|
71
|
-
penalty: false,
|
72
|
-
score1: 1,
|
73
|
-
score2: 0,
|
74
|
-
team: 1)], parse_goals( line )
|
75
|
-
|
76
|
-
|
77
|
-
line = " [Vidal 3', 65' M. Rosas 51' (o.g.)]"
|
78
|
-
assert_equal [
|
79
|
-
SportDb::GoalStruct.new(
|
80
|
-
name: 'Vidal',
|
81
|
-
minute: 3,
|
82
|
-
offset: 0,
|
83
|
-
owngoal: false,
|
84
|
-
penalty: false,
|
85
|
-
score1: 1,
|
86
|
-
score2: 0,
|
87
|
-
team: 1),
|
88
|
-
SportDb::GoalStruct.new(
|
89
|
-
name: 'M. Rosas',
|
90
|
-
minute: 51,
|
91
|
-
offset: 0,
|
92
|
-
owngoal: true,
|
93
|
-
penalty: false,
|
94
|
-
score1: 2,
|
95
|
-
score2: 0,
|
96
|
-
team: 1),
|
97
|
-
SportDb::GoalStruct.new(
|
98
|
-
name: 'Vidal',
|
99
|
-
minute: 65,
|
100
|
-
offset: 0,
|
101
|
-
owngoal: false,
|
102
|
-
penalty: false,
|
103
|
-
score1: 3,
|
104
|
-
score2: 0,
|
105
|
-
team: 1)], parse_goals( line )
|
106
|
-
end
|
107
|
-
|
108
|
-
private
|
109
|
-
def parse_goals( line )
|
110
|
-
SportDb::GoalsFinder.new.find!( line )
|
111
|
-
end
|
112
|
-
|
113
|
-
end # class TestGoals
|