sportdb-formats 1.0.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/lib/sportdb/formats/league/league_outline_reader.rb +24 -7
- data/lib/sportdb/formats/match/match_parser.rb +54 -93
- data/lib/sportdb/formats/match/match_parser_csv.rb +11 -4
- data/lib/sportdb/formats/parser_helper.rb +11 -2
- data/lib/sportdb/formats/structs/standings.rb +30 -9
- data/lib/sportdb/formats/version.rb +2 -2
- data/test/helper.rb +1 -0
- data/test/test_match_auto_relegation.rb +41 -0
- data/test/test_regex.rb +25 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216e15369403af5707b3d2c6d82fcd6c72e2712d
|
4
|
+
data.tar.gz: 5c73e0e7ce7309b2c8fb86e38d90d1d566f80688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8033e4db4d7b047b37ec8b3be61657d15df72b7a6c6295317ca8c9cd19c0f578f2ecd75c25cf11b0dcb9218c1ff3e8d2a8e0efb0c59ae235b568b353ef55c9d6
|
7
|
+
data.tar.gz: e5b510b45d4c28c6d83d6baa43ef954e78ae64af116c8305a983b5c54d2fda486425a793b48c8332dcf8cf5c441da37f7183602d50a7e07066049995b5940f0f
|
data/Manifest.txt
CHANGED
@@ -121,14 +121,31 @@ class LeagueOutlineReader ## todo/check - rename to LeaguePageReader / LeagueP
|
|
121
121
|
values
|
122
122
|
end
|
123
123
|
|
124
|
-
def check_stage( name )
|
125
|
-
known_stages = ['regular season',
|
126
|
-
'championship round',
|
127
|
-
'relegation round',
|
128
|
-
'play-offs'
|
129
|
-
]
|
130
124
|
|
131
|
-
|
125
|
+
# note: normalize names e.g. downcase and remove all non a-z chars (e.g. space, dash, etc.)
|
126
|
+
KNOWN_STAGES = [
|
127
|
+
'Regular Season',
|
128
|
+
'Regular Stage',
|
129
|
+
'Championship Round',
|
130
|
+
'Championship Playoff',
|
131
|
+
'Relegation Round',
|
132
|
+
'Relegation Playoff',
|
133
|
+
'Play-offs',
|
134
|
+
'Playoff Stage',
|
135
|
+
'Grunddurchgang',
|
136
|
+
'Finaldurchgang - Qualifikationsgruppe',
|
137
|
+
'Finaldurchgang - Qualifikation',
|
138
|
+
'Finaldurchgang - Meistergruppe',
|
139
|
+
'Finaldurchgang - Meister',
|
140
|
+
'EL Play-off',
|
141
|
+
'Europa League Play-off',
|
142
|
+
'Europa-League-Play-offs',
|
143
|
+
].map {|name| name.downcase.gsub( /[^a-z]/, '' ) }
|
144
|
+
|
145
|
+
|
146
|
+
def check_stage( name )
|
147
|
+
# note: normalize names e.g. downcase and remove all non a-z chars (e.g. space, dash, etc.)
|
148
|
+
if KNOWN_STAGES.include?( name.downcase.gsub( /[^a-z]/, '' ) )
|
132
149
|
## everything ok
|
133
150
|
else
|
134
151
|
puts "** !!! ERROR - no (league) stage match found for >#{name}<, add to (builtin) stages table; sorry"
|
@@ -82,10 +82,9 @@ class MatchParser ## simple match parser for team match schedules
|
|
82
82
|
# team1 team2 - match (will get new auto-matchday! not last round)
|
83
83
|
@last_round = nil
|
84
84
|
|
85
|
-
name
|
85
|
+
name = find_group_name!( line )
|
86
86
|
|
87
87
|
logger.debug " name: >#{name}<"
|
88
|
-
logger.debug " pos: >#{pos}<"
|
89
88
|
logger.debug " line: >#{line}<"
|
90
89
|
|
91
90
|
group = @groups[ name ]
|
@@ -104,7 +103,7 @@ class MatchParser ## simple match parser for team match schedules
|
|
104
103
|
@mapper_teams.map_teams!( line )
|
105
104
|
teams = @mapper_teams.find_teams!( line )
|
106
105
|
|
107
|
-
name
|
106
|
+
name = find_group_name!( line )
|
108
107
|
|
109
108
|
logger.debug " line: >#{line}<"
|
110
109
|
|
@@ -116,7 +115,7 @@ class MatchParser ## simple match parser for team match schedules
|
|
116
115
|
end
|
117
116
|
|
118
117
|
|
119
|
-
def
|
118
|
+
def find_group_name!( line )
|
120
119
|
## group pos - for now support single digit e.g 1,2,3 or letter e.g. A,B,C or HEX
|
121
120
|
## nb: (?:) = is for non-capturing group(ing)
|
122
121
|
|
@@ -125,37 +124,25 @@ class MatchParser ## simple match parser for team match schedules
|
|
125
124
|
|
126
125
|
## todo:
|
127
126
|
## check if Group A: or [Group A] works e.g. : or ] get matched by \b ???
|
128
|
-
regex =
|
127
|
+
regex = /\b
|
128
|
+
(?:
|
129
|
+
(Group | Gruppe | Grupo)
|
130
|
+
[ ]+
|
131
|
+
(\d+ | [A-Z]+)
|
132
|
+
)
|
133
|
+
\b/x
|
129
134
|
|
130
135
|
m = regex.match( line )
|
131
136
|
|
132
|
-
return
|
133
|
-
|
134
|
-
pos = case m[1]
|
135
|
-
when 'A' then 1
|
136
|
-
when 'B' then 2
|
137
|
-
when 'C' then 3
|
138
|
-
when 'D' then 4
|
139
|
-
when 'E' then 5
|
140
|
-
when 'F' then 6
|
141
|
-
when 'G' then 7
|
142
|
-
when 'H' then 8
|
143
|
-
when 'I' then 9
|
144
|
-
when 'J' then 10
|
145
|
-
when 'K' then 11
|
146
|
-
when 'L' then 12
|
147
|
-
when 'HEX' then 666 # HEX for Hexagonal - todo/check: map to something else ??
|
148
|
-
else m[1].to_i
|
149
|
-
end
|
137
|
+
return nil if m.nil?
|
150
138
|
|
151
139
|
name = m[0]
|
152
140
|
|
153
141
|
logger.debug " name: >#{name}<"
|
154
|
-
logger.debug " pos: >#{pos}<"
|
155
142
|
|
156
|
-
line.sub!(
|
143
|
+
line.sub!( name, '[GROUP.NAME]' )
|
157
144
|
|
158
|
-
|
145
|
+
name
|
159
146
|
end
|
160
147
|
|
161
148
|
|
@@ -180,7 +167,6 @@ class MatchParser ## simple match parser for team match schedules
|
|
180
167
|
end_date = end_date.to_date
|
181
168
|
|
182
169
|
|
183
|
-
pos = find_round_pos!( line )
|
184
170
|
name = find_round_def_name!( line )
|
185
171
|
# NB: use extracted round name for knockout check
|
186
172
|
knockout_flag = is_knockout_round?( name )
|
@@ -188,15 +174,11 @@ class MatchParser ## simple match parser for team match schedules
|
|
188
174
|
|
189
175
|
logger.debug " start_date: #{start_date}"
|
190
176
|
logger.debug " end_date: #{end_date}"
|
191
|
-
logger.debug " pos: #{pos}"
|
192
177
|
logger.debug " name: >#{name}<"
|
193
178
|
logger.debug " knockout_flag: #{knockout_flag}"
|
194
179
|
|
195
180
|
logger.debug " line: >#{line}<"
|
196
181
|
|
197
|
-
#######################################
|
198
|
-
# todo/fix: add auto flag is false !!!! - why? why not?
|
199
|
-
# todo/fix/check: add num if present!!!!
|
200
182
|
round = Import::Round.new( name: name,
|
201
183
|
start_date: start_date,
|
202
184
|
end_date: end_date,
|
@@ -208,52 +190,6 @@ class MatchParser ## simple match parser for team match schedules
|
|
208
190
|
|
209
191
|
|
210
192
|
|
211
|
-
def find_round_pos!( line )
|
212
|
-
# pass #1) extract optional round pos from line
|
213
|
-
# e.g. (1) - must start line
|
214
|
-
regex_pos = /^[ \t]*\((\d{1,3})\)[ \t]+/
|
215
|
-
|
216
|
-
# pass #2) find free standing number e.g. Matchday 3 or Round 5 or 3. Spieltag etc.
|
217
|
-
# note: /\b(\d{1,3})\b/
|
218
|
-
# will match -12
|
219
|
-
# thus, use space required - will NOT match -2 e.g. Group-2 Play-off
|
220
|
-
# note: allow 1. Runde n
|
221
|
-
# 1^ Giornata
|
222
|
-
regex_num = /(?:^|\s)(\d{1,3})(?:[.\^\s]|$)/
|
223
|
-
|
224
|
-
if line =~ regex_pos
|
225
|
-
logger.debug " pos: >#{$1}<"
|
226
|
-
|
227
|
-
line.sub!( regex_pos, '[ROUND.POS] ' ) ## NB: add back trailing space that got swallowed w/ regex -> [ \t]+
|
228
|
-
return $1.to_i
|
229
|
-
elsif line =~ regex_num
|
230
|
-
## assume number in name is pos (e.g. Jornada 3, 3 Runde etc.)
|
231
|
-
## NB: do NOT remove pos from string (will get removed by round name)
|
232
|
-
|
233
|
-
num = $1.to_i # note: clone capture; keep a copy (another regex follows; will redefine $1)
|
234
|
-
|
235
|
-
#### fix:
|
236
|
-
# use/make keywords required
|
237
|
-
# e.g. Round of 16 -> should NOT match 16!
|
238
|
-
# Spiel um Platz 3 (or 5) etc -> should NOT match 3!
|
239
|
-
# Round 16 - ok
|
240
|
-
# thus, check for required keywords
|
241
|
-
|
242
|
-
## quick hack for round of 16
|
243
|
-
# todo: mask match e.g. Round of xxx ... and try again - might include something
|
244
|
-
# reuse pattern for Group XX Replays for example
|
245
|
-
if line =~ /^\s*Round of \d{1,3}\b/
|
246
|
-
return nil
|
247
|
-
end
|
248
|
-
|
249
|
-
logger.debug " pos: >#{num}<"
|
250
|
-
return num
|
251
|
-
else
|
252
|
-
## fix: add logger.warn no round pos found in line
|
253
|
-
return nil
|
254
|
-
end
|
255
|
-
end # method find_round_pos!
|
256
|
-
|
257
193
|
def find_round_def_name!( line )
|
258
194
|
# assume everything before pipe (\) is the round name
|
259
195
|
# strip [ROUND.POS], todo:?? [ROUND.NAME2]
|
@@ -266,10 +202,6 @@ class MatchParser ## simple match parser for team match schedules
|
|
266
202
|
|
267
203
|
## cut-off everything after (including) pipe (|)
|
268
204
|
buf = buf[ 0...buf.index('|') ]
|
269
|
-
|
270
|
-
# e.g. remove [ROUND.POS], [ROUND.NAME2], [GROUP.NAME+POS] etc.
|
271
|
-
buf.gsub!( /\[[^\]]+\]/, '' ) ## fix: use helper for (re)use e.g. remove_match_placeholder/marker or similar?
|
272
|
-
# remove leading and trailing whitespace
|
273
205
|
buf.strip!
|
274
206
|
|
275
207
|
logger.debug " find_round_def_name! line-after: >>#{buf}<<"
|
@@ -280,20 +212,38 @@ class MatchParser ## simple match parser for team match schedules
|
|
280
212
|
buf
|
281
213
|
end
|
282
214
|
|
215
|
+
|
216
|
+
## split by or || or |||
|
217
|
+
## or ++ or +++
|
218
|
+
## or -- or ---
|
219
|
+
## or // or ///
|
220
|
+
## note: allow Final | First Leg as ONE name same as
|
221
|
+
## Final - First Leg or
|
222
|
+
## Final, First Leg
|
223
|
+
## for cut-off always MUST be more than two chars
|
224
|
+
##
|
225
|
+
## todo/check: find a better name than HEADER_SEP(ARATOR) - why? why not?
|
226
|
+
## todo/fix: move to parser utils and add a method split_name or such?
|
227
|
+
HEADER_SEP_RE = / [ ]* ## allow (strip) leading spaces
|
228
|
+
(?:\|{2,} |
|
229
|
+
\+{2,} |
|
230
|
+
-{2,} |
|
231
|
+
\/{2,}
|
232
|
+
)
|
233
|
+
[ ]* ## allow (strip) trailing spaces
|
234
|
+
/x
|
235
|
+
|
283
236
|
def find_round_header_name!( line )
|
284
237
|
# assume everything left is the round name
|
285
238
|
# extract all other items first (round name2, round pos, group name n pos, etc.)
|
286
239
|
|
287
|
-
## todo/fix:
|
288
|
-
## cleanup method
|
289
|
-
## use buf.index( '//' ) to split string (see found_round_def)
|
290
|
-
## why? simpler why not?
|
291
|
-
## - do we currently allow groups if name2 present? add example if it works?
|
292
|
-
|
293
240
|
buf = line.dup
|
294
241
|
logger.debug " find_round_header_name! line-before: >>#{buf}<<"
|
295
242
|
|
296
|
-
|
243
|
+
|
244
|
+
parts = buf.split( HEADER_SEP_RE )
|
245
|
+
buf = parts[0]
|
246
|
+
|
297
247
|
buf.strip! # remove leading and trailing whitespace
|
298
248
|
|
299
249
|
logger.debug " find_round_name! line-after: >>#{buf}<<"
|
@@ -306,19 +256,30 @@ class MatchParser ## simple match parser for team match schedules
|
|
306
256
|
buf
|
307
257
|
end
|
308
258
|
|
259
|
+
## quick hack- collect all "fillwords" by language!!!!
|
260
|
+
## change later and add to sportdb-langs!!!!
|
261
|
+
##
|
262
|
+
## strip all "fillwords" e.g.:
|
263
|
+
## Nachtrag/Postponed/Addition/Supplemento names
|
264
|
+
##
|
265
|
+
## todo/change: find a better name for ROUND_EXTRA_WORDS - why? why not?
|
266
|
+
ROUND_EXTRA_WORDS_RE = /\b(?:
|
267
|
+
Nachtrag | ## de
|
268
|
+
Postponed | ## en
|
269
|
+
Addition | ## en
|
270
|
+
Supplemento ## es
|
271
|
+
)
|
272
|
+
\b/ix
|
309
273
|
|
310
274
|
def parse_round_header( line )
|
311
275
|
logger.debug "parsing round header line: >#{line}<"
|
312
276
|
|
313
|
-
## todo/check/fix:
|
314
|
-
# make sure Round of 16 will not return pos 16 -- how? possible?
|
315
|
-
# add unit test too to verify
|
316
|
-
pos = find_round_pos!( line )
|
317
|
-
|
318
277
|
name = find_round_header_name!( line )
|
319
278
|
|
320
279
|
logger.debug " line: >#{line}<"
|
321
280
|
|
281
|
+
name = name.sub( ROUND_EXTRA_WORDS_RE, '' )
|
282
|
+
name = name.strip
|
322
283
|
|
323
284
|
round = @rounds[ name ]
|
324
285
|
if round.nil? ## auto-add / create if missing
|
@@ -167,7 +167,10 @@ module SportDb
|
|
167
167
|
|
168
168
|
|
169
169
|
## check if data present - if not skip (might be empty row)
|
170
|
-
|
170
|
+
## note: (old classic) csv reader returns nil for empty fields
|
171
|
+
## new modern csv reader ALWAYS returns strings (and empty strings for data not available (n/a))
|
172
|
+
if (team1.nil? || team1.empty?) &&
|
173
|
+
(team2.nil? || team2.empty?)
|
171
174
|
puts "*** WARN: skipping empty? row[#{i}] - no teams found:"
|
172
175
|
pp row
|
173
176
|
next
|
@@ -182,9 +185,11 @@ module SportDb
|
|
182
185
|
col = row[ headers_mapping[ :date ]]
|
183
186
|
col = col.strip # make sure not leading or trailing spaces left over
|
184
187
|
|
185
|
-
if col.empty? ||
|
186
|
-
|
187
|
-
|
188
|
+
if col.empty? ||
|
189
|
+
col =~ /^-{1,}$/ || # e.g. - or ---
|
190
|
+
col =~ /^\?{1,}$/ # e.g. ? or ???
|
191
|
+
## note: allow missing / unknown date for match
|
192
|
+
date = nil
|
188
193
|
else
|
189
194
|
## remove possible weekday or weeknumber e.g. (Fri) (4) etc.
|
190
195
|
col = col.sub( /\(W?\d{1,2}\)/, '' ) ## e.g. (W11), (4), (21) etc.
|
@@ -199,6 +204,8 @@ module SportDb
|
|
199
204
|
date_fmt = '%Y-%m-%d' # e.g. 1995-08-04
|
200
205
|
elsif col =~ /^\d{1,2} \w{3} \d{4}$/
|
201
206
|
date_fmt = '%d %b %Y' # e.g. 8 Jul 2017
|
207
|
+
elsif col =~ /^\w{3} \w{3} \d{1,2} \d{4}$/
|
208
|
+
date_fmt = '%a %b %d %Y' # e.g. Sat Aug 7 1993
|
202
209
|
else
|
203
210
|
puts "*** !!! wrong (unknown) date format >>#{col}<<; cannot continue; fix it; sorry"
|
204
211
|
## todo/fix: add to errors/warns list - why? why not?
|
@@ -18,10 +18,19 @@ module SportDb
|
|
18
18
|
|
19
19
|
|
20
20
|
def is_round?( line )
|
21
|
-
## note: =~
|
22
|
-
|
21
|
+
## note: =~ returns nil if not match found, and 0,1, etc for match
|
22
|
+
|
23
|
+
## note: allow "free standing" leg 1 and leg 2 too
|
24
|
+
## (e.g. Hinspiel, Rückspiel etc. used for now in Relegation, for example)
|
25
|
+
## note ONLY allowed if "free standing", that is, full line with nothing else
|
26
|
+
## use "custom" regex for special case for now
|
27
|
+
## avoids match HIN in PascHINg, for example (hin in german for leg 1)
|
28
|
+
line =~ SportDb.lang.regex_round ||
|
29
|
+
line =~ /^(#{SportDb.lang.leg1})$/i ||
|
30
|
+
line =~ /^(#{SportDb.lang.leg2})$/i
|
23
31
|
end
|
24
32
|
|
33
|
+
|
25
34
|
def is_knockout_round?( line )
|
26
35
|
|
27
36
|
## todo: check for adding ignore case for regex (e.g. 1st leg/1st Leg)
|
@@ -12,7 +12,7 @@ module SportDb
|
|
12
12
|
|
13
13
|
class Standings
|
14
14
|
|
15
|
-
class StandingsLine ## nested class StandinsLine
|
15
|
+
class StandingsLine ## nested class StandinsLine - todo/fix: change to Line - why? why not?
|
16
16
|
attr_accessor :rank, :team,
|
17
17
|
:played, :won, :lost, :drawn, ## -- total
|
18
18
|
:goals_for, :goals_against, :pts,
|
@@ -21,8 +21,13 @@ class Standings
|
|
21
21
|
:away_played, :away_won, :away_lost, :away_drawn, ## -- away
|
22
22
|
:away_goals_for, :away_goals_against, :away_pts
|
23
23
|
|
24
|
+
alias_method :team_name, :team ## note: team for now always a string
|
25
|
+
alias_method :pos, :rank ## rename back to use pos instead of rank - why? why not?
|
26
|
+
|
27
|
+
|
24
28
|
def initialize( team )
|
25
29
|
@rank = nil # use 0? why? why not?
|
30
|
+
## change rank back to pos - why? why not?
|
26
31
|
@team = team
|
27
32
|
@played = @home_played = @away_played = 0
|
28
33
|
@won = @home_won = @away_won = 0
|
@@ -49,7 +54,12 @@ class Standings
|
|
49
54
|
|
50
55
|
def update( match_or_matches )
|
51
56
|
## convenience - update all matches at once
|
52
|
-
|
57
|
+
## todo/check: check for ActiveRecord_Associations_CollectionProxy and than use to_a (to "force" array) - why? why not?
|
58
|
+
matches = if match_or_matches.is_a?(Array)
|
59
|
+
match_or_matches
|
60
|
+
else
|
61
|
+
[match_or_matches]
|
62
|
+
end
|
53
63
|
|
54
64
|
matches.each_with_index do |match,i| # note: index(i) starts w/ zero (0)
|
55
65
|
update_match( match )
|
@@ -171,19 +181,30 @@ class Standings
|
|
171
181
|
private
|
172
182
|
def update_match( m ) ## add a match
|
173
183
|
|
174
|
-
##
|
184
|
+
## note: always use team as string for now
|
185
|
+
## for now allow passing in of string OR struct - why? why not?
|
186
|
+
## todo/fix: change to m.team1_name and m.team2_name - why? why not?
|
187
|
+
team1 = m.team1.is_a?( String ) ? m.team1 : m.team1.name
|
188
|
+
team2 = m.team2.is_a?( String ) ? m.team2 : m.team2.name
|
189
|
+
|
190
|
+
score = m.score_str
|
191
|
+
|
192
|
+
## puts " #{team1} - #{team2} #{score}"
|
193
|
+
|
175
194
|
unless m.over?
|
176
|
-
puts " !!!! skipping match - not yet over (
|
195
|
+
puts " !!!! skipping match - not yet over (date in the future) => #{m.date}"
|
177
196
|
return
|
178
197
|
end
|
179
198
|
|
180
199
|
unless m.complete?
|
181
|
-
puts "!!! [calc_standings] skipping match #{
|
200
|
+
puts "!!! [calc_standings] skipping match #{team1} - #{team2} w/ past date #{m.date} - scores incomplete => #{score}"
|
182
201
|
return
|
183
202
|
end
|
184
203
|
|
185
|
-
|
186
|
-
|
204
|
+
|
205
|
+
|
206
|
+
line1 = @lines[ team1 ] || StandingsLine.new( team1 )
|
207
|
+
line2 = @lines[ team2 ] || StandingsLine.new( team2 )
|
187
208
|
|
188
209
|
line1.played += 1
|
189
210
|
line1.home_played += 1
|
@@ -236,8 +257,8 @@ private
|
|
236
257
|
puts "*** warn: [standings] skipping match with missing scores: #{m.inspect}"
|
237
258
|
end
|
238
259
|
|
239
|
-
@lines[
|
240
|
-
@lines[
|
260
|
+
@lines[ team1 ] = line1
|
261
|
+
@lines[ team2 ] = line2
|
241
262
|
end # method update_match
|
242
263
|
|
243
264
|
end # class Standings
|
data/test/helper.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_match_auto_relegation.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestMatchAutoRelegation < MiniTest::Test
|
12
|
+
|
13
|
+
def test_rel
|
14
|
+
txt = <<TXT
|
15
|
+
Hinspiel
|
16
|
+
[31.5.]
|
17
|
+
SC Wiener Neustadt 0-2 SKN St. Pölten
|
18
|
+
|
19
|
+
Rückspiel
|
20
|
+
[3.6.]
|
21
|
+
SKN St. Pölten 1-1 SC Wiener Neustadt
|
22
|
+
TXT
|
23
|
+
|
24
|
+
start = Date.new( 2017, 7, 1 )
|
25
|
+
SportDb::Import.config.lang = 'de'
|
26
|
+
|
27
|
+
teams, rounds, groups, round_defs, group_defs = SportDb::AutoConfParser.parse( txt, start: start )
|
28
|
+
|
29
|
+
puts "teams:"
|
30
|
+
pp teams
|
31
|
+
puts "rounds:"
|
32
|
+
pp rounds
|
33
|
+
puts "groups:"
|
34
|
+
pp groups
|
35
|
+
puts "round defs:"
|
36
|
+
pp round_defs
|
37
|
+
puts "group defs:"
|
38
|
+
pp group_defs
|
39
|
+
end
|
40
|
+
|
41
|
+
end # class TestMatchAutoRelegation
|
data/test/test_regex.rb
CHANGED
@@ -9,9 +9,27 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestRegex < MiniTest::Test
|
11
11
|
|
12
|
+
HEADER_SEP_RE = SportDb::MatchParser::HEADER_SEP_RE
|
13
|
+
|
14
|
+
def test_header_sep
|
15
|
+
assert_equal ['Round', 'Fr+Sa Dec 11+12'], 'Round // Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
16
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 /// Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
17
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 -- Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
18
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 --- Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
19
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 ++ Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
20
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 +++ Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
21
|
+
assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 || Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
|
22
|
+
|
23
|
+
assert_equal ['Final - Leg 1'], 'Final - Leg 1'.split( HEADER_SEP_RE )
|
24
|
+
assert_equal ['Final | Leg 1'], 'Final | Leg 1'.split( HEADER_SEP_RE )
|
25
|
+
assert_equal ['Final / Leg 1'], 'Final / Leg 1'.split( HEADER_SEP_RE )
|
26
|
+
assert_equal ['Final, Leg 1'], 'Final, Leg 1'.split( HEADER_SEP_RE )
|
27
|
+
end
|
28
|
+
|
29
|
+
|
12
30
|
ADDR_MARKER_RE = SportDb::Import::ClubReader::ADDR_MARKER_RE
|
13
31
|
B_TEAM_MARKER_RE = SportDb::Import::ClubReader::B_TEAM_MARKER_RE
|
14
|
-
|
32
|
+
|
15
33
|
def test_addr
|
16
34
|
assert '~ Wien' =~ ADDR_MARKER_RE
|
17
35
|
assert 'Wien ~' =~ ADDR_MARKER_RE
|
@@ -22,13 +40,13 @@ class TestRegex < MiniTest::Test
|
|
22
40
|
assert 'Fischhofgasse 12 /// 1100 Wien' =~ ADDR_MARKER_RE
|
23
41
|
|
24
42
|
assert_nil 'Fischhofgasse 12 + 1100 Wien' =~ ADDR_MARKER_RE
|
25
|
-
assert_nil 'Fischhofgasse 12++1100 Wien' =~ ADDR_MARKER_RE
|
43
|
+
assert_nil 'Fischhofgasse 12++1100 Wien' =~ ADDR_MARKER_RE ## todo/fix: make it a match!!! why? why not?
|
26
44
|
assert_nil 'Fischhofgasse 12 / 1100 Wien' =~ ADDR_MARKER_RE
|
27
|
-
assert_nil 'Fischhofgasse 12//1100 Wien' =~ ADDR_MARKER_RE
|
28
|
-
|
45
|
+
assert_nil 'Fischhofgasse 12//1100 Wien' =~ ADDR_MARKER_RE ## todo/fix: make it a match!!! why? why not?
|
46
|
+
|
29
47
|
assert_nil 'Atlanta United FC, 2017, Atlanta › Georgia' =~ ADDR_MARKER_RE
|
30
48
|
end
|
31
|
-
|
49
|
+
|
32
50
|
def test_b_team
|
33
51
|
assert 'b) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
34
52
|
assert '(b) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
@@ -38,12 +56,12 @@ class TestRegex < MiniTest::Test
|
|
38
56
|
assert '(ii.) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
39
57
|
assert '2) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
40
58
|
assert '(2) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
41
|
-
|
59
|
+
|
42
60
|
assert_nil '(3) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
43
61
|
assert_nil '(iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
44
62
|
assert_nil 'iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
45
63
|
assert_nil 'c) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
46
64
|
assert_nil '(c) Rapid Wien II' =~ B_TEAM_MARKER_RE
|
47
65
|
end
|
48
|
-
|
66
|
+
|
49
67
|
end # class TestRegex
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-formats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alphabets
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- test/test_match_auto.rb
|
183
183
|
- test/test_match_auto_champs.rb
|
184
184
|
- test/test_match_auto_euro.rb
|
185
|
+
- test/test_match_auto_relegation.rb
|
185
186
|
- test/test_match_auto_worldcup.rb
|
186
187
|
- test/test_match_champs.rb
|
187
188
|
- test/test_match_eng.rb
|