sportdb-models 1.18.4 → 1.18.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a98ed66ad51aa02af40583f83dc46e04a56c3dad
4
- data.tar.gz: 54b2c7f2b26daac5922a05c782abba79bd932bd1
3
+ metadata.gz: 54708fea040f5de13230b7e12432946df3a7d91c
4
+ data.tar.gz: 1ecebd1aa8c1052f7ffbbd12dd0588fbd174b56e
5
5
  SHA512:
6
- metadata.gz: a3313deac8439d0c4edf848c8ffc99eaab7bc792a598ba53cf0a9a419c7baac7b65ce62a50409e7a4de4c6a24c43350ecaa52fc52855ce822e1a853e6da12a3b
7
- data.tar.gz: f6d31b12c5f78fbb9b53ed8ff5e7b4aef45ad0faf97262b5b92fbe95dd9bcdca1b001bc01dc3e83a3ccd14cac2a3b535c123c9f48a6e2c9eefeaff5c16c486d9
6
+ metadata.gz: eda15ddd287189de9c2610dd511e66138974ac92782735148a2a9e73d699627f0e80cac443e89fa954e24648345f9b0f266c417388532ab145528a032cc93786
7
+ data.tar.gz: 15ebaebd875ca30aed2ab6b7565a34e816f9c155e2f3d1b3e9d12e932e6d6d4a27c126580c269084108896ce42b799b19f64314fc6a714b2f71d008fd01692ca
@@ -4,8 +4,6 @@ README.md
4
4
  Rakefile
5
5
  lib/sportdb/calc.rb
6
6
  lib/sportdb/deleter.rb
7
- lib/sportdb/finders/goals.rb
8
- lib/sportdb/finders/scores.rb
9
7
  lib/sportdb/indexers/team.rb
10
8
  lib/sportdb/mapper_teams.rb
11
9
  lib/sportdb/matcher.rb
@@ -149,7 +147,6 @@ test/test_round_auto.rb
149
147
  test/test_round_def.rb
150
148
  test/test_round_header.rb
151
149
  test/test_rsssf_reader.rb
152
- test/test_scores.rb
153
150
  test/test_squad_club_reader.rb
154
151
  test/test_squad_national_team_reader.rb
155
152
  test/test_standings.rb
@@ -54,7 +54,6 @@ require 'sportdb/models/utils' # e.g. GameCursor
54
54
 
55
55
  require 'sportdb/schema' # NB: requires sportdb/models (include SportDB::Models)
56
56
 
57
- require 'sportdb/finders/scores'
58
57
 
59
58
  require 'sportdb/utils'
60
59
  require 'sportdb/utils_date'
@@ -70,8 +69,6 @@ require 'sportdb/standings'
70
69
  require 'sportdb/mapper_teams'
71
70
 
72
71
 
73
- require 'sportdb/finders/goals' # no: requires FixturesHelpers
74
-
75
72
  require 'sportdb/readers/assoc'
76
73
  require 'sportdb/readers/event' ## old event reader (remove later??)
77
74
  require 'sportdb/readers/event_table' ## new "standard" event reader
@@ -4,7 +4,7 @@ module SportDb
4
4
 
5
5
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 18
7
- PATCH = 4
7
+ PATCH = 5
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -3,8 +3,6 @@
3
3
  ###
4
4
  # to run use
5
5
  # ruby -I ./lib -I ./test test/test_goals.rb
6
- # or better
7
- # rake -I ./lib test
8
6
 
9
7
 
10
8
  require 'helper'
@@ -33,7 +31,7 @@ class TestGoals < MiniTest::Test
33
31
  ['uy', 'Uruguay', 'URU' ],
34
32
  ['pe', 'Peru', 'PER' ],
35
33
  ['py', 'Paraguay', 'PAR' ],
36
-
34
+
37
35
  ['mx', 'Mexico', 'MEX' ],
38
36
  ['us', 'United States', 'USA' ],
39
37
  ['ht', 'Haiti', 'HAI' ],
@@ -46,7 +44,7 @@ class TestGoals < MiniTest::Test
46
44
  ['bg', 'Bulgaria', 'BUL' ],
47
45
  ['cz', 'Czech Republic', 'CZE' ],
48
46
  ['en', 'England', 'ENG' ],
49
- ['de', 'Germany', 'GER' ],
47
+ ['de', 'Germany', 'GER' ],
50
48
  ['hu', 'Hungary', 'HUN' ],
51
49
  ['it', 'Italy', 'ITA' ],
52
50
  ['ru', 'Russia', 'RUS' ],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.4
4
+ version: 1.18.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-26 00:00:00.000000000 Z
11
+ date: 2019-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: worlddb-models
@@ -95,8 +95,6 @@ files:
95
95
  - Rakefile
96
96
  - lib/sportdb/calc.rb
97
97
  - lib/sportdb/deleter.rb
98
- - lib/sportdb/finders/goals.rb
99
- - lib/sportdb/finders/scores.rb
100
98
  - lib/sportdb/indexers/team.rb
101
99
  - lib/sportdb/mapper_teams.rb
102
100
  - lib/sportdb/matcher.rb
@@ -240,7 +238,6 @@ files:
240
238
  - test/test_round_def.rb
241
239
  - test/test_round_header.rb
242
240
  - test/test_rsssf_reader.rb
243
- - test/test_scores.rb
244
241
  - test/test_squad_club_reader.rb
245
242
  - test/test_squad_national_team_reader.rb
246
243
  - test/test_standings.rb
@@ -1,260 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
-
6
-
7
- class GoalsPlayerStruct
8
- ##
9
- # note: player with own goal (o.g) gets listed on other team
10
- # (thus, player might have two entries if also scored for its own team)
11
- #
12
- attr_accessor :name
13
- attr_accessor :minutes # ary of minutes e.g. 30', 45+2', 72'
14
-
15
- def initialize
16
- @minutes = []
17
- end
18
- end
19
-
20
-
21
- class GoalsMinuteStruct
22
- attr_accessor :minute, :offset
23
- attr_accessor :penalty, :owngoal # flags
24
-
25
- def initialize
26
- @offset = 0
27
- @penalty = false
28
- @owngoal = false
29
- end
30
- end
31
-
32
-
33
- class GoalStruct
34
- ######
35
- # flat struct for goals - one entry per goals
36
- attr_accessor :name
37
- attr_accessor :team # 1 or 2 ? check/todo: add team1 or team2 flag?
38
- attr_accessor :minute, :offset
39
- attr_accessor :penalty, :owngoal
40
- attr_accessor :score1, :score2 # gets calculated
41
-
42
- ## add pos for sequence number? e.g. 1,2,3,4 (1st goald, 2nd goal, etc.) ???
43
-
44
- def initialize
45
- # do nothing
46
- end
47
- end
48
-
49
-
50
-
51
- # todo: find a better name? to avoid confusing w/ GoalsParser? use MatchGoalsParser or similar?
52
- class GoalsFinder
53
- include LogUtils::Logging
54
- include FixtureHelpers # e.g. cut_off_end_of_line_comment!
55
-
56
- def initialize
57
- # nothing here for now
58
- end
59
-
60
- def find!( line, opts={} )
61
- # remove end-of-line comments
62
- # - move to textutils ?? why? why not??
63
- cut_off_end_of_line_comment!( line ) ## note: func defined in utils.rb (FixtureHelpers)
64
-
65
- # remove [] if presents e.g. [Neymar 12']
66
- line = line.gsub( /[\[\]]/, '' )
67
- # remove (single match) if line starts w/ - (allow spaces) e.g. [-;Neymar 12'] or [ - ;Neymar 12']
68
- line = line.sub( /^[ ]*-[ ]*/, '' )
69
-
70
- # split into left hand side (lhs) for team1 and
71
- # right hand side (rhs) for team2
72
-
73
- values = line.split( ';' )
74
-
75
- # note: allow empty right hand side (e.g. team2 did NOT score any goals e.g. 3-0 etc.)
76
- lhs = values[0]
77
- rhs = values[1]
78
-
79
- lhs = lhs.strip unless lhs.nil?
80
- rhs = rhs.strip unless rhs.nil?
81
-
82
- parser = GoalsParser.new
83
- ## todo/check: only call if not nil?
84
-
85
- logger.debug " lhs (team1): >#{lhs}<"
86
- lhs_data = parser.parse!( lhs )
87
- pp lhs_data
88
-
89
- logger.debug " rhs (team2): >#{rhs}<"
90
- rhs_data = parser.parse!( rhs )
91
- pp rhs_data
92
-
93
- ### merge into flat goal structs
94
- goals = []
95
- lhs_data.each do |player|
96
- player.minutes.each do |minute|
97
- goal = GoalStruct.new
98
- goal.name = player.name
99
- goal.team = 1
100
- goal.minute = minute.minute
101
- goal.offset = minute.offset
102
- goal.penalty = minute.penalty
103
- goal.owngoal = minute.owngoal
104
- goals << goal
105
- end
106
- end
107
-
108
- rhs_data.each do |player|
109
- player.minutes.each do |minute|
110
- goal = GoalStruct.new
111
- goal.name = player.name
112
- goal.team = 2
113
- goal.minute = minute.minute
114
- goal.offset = minute.offset
115
- goal.penalty = minute.penalty
116
- goal.owngoal = minute.owngoal
117
- goals << goal
118
- end
119
- end
120
-
121
-
122
- # sort by minute + offset
123
- goals = goals.sort do |l,r|
124
- res = l.minute <=> r.minute
125
- if res == 0
126
- res = l.offset <=> r.offset # pass 2: sort by offset
127
- end
128
- res
129
- end
130
-
131
- ## calc score1,score2
132
- score1 = 0
133
- score2 = 0
134
- goals.each do |goal|
135
- if goal.team == 1
136
- score1 += 1
137
- elsif goal.team == 2
138
- score2 += 1
139
- else
140
- # todo: should not happen: issue warning
141
- end
142
- goal.score1 = score1
143
- goal.score2 = score2
144
- end
145
-
146
- logger.debug " #{goals.size} goals:"
147
- pp goals
148
-
149
- goals
150
- end
151
-
152
- end # class GoalsFinder
153
-
154
-
155
- class GoalsParser
156
- include LogUtils::Logging
157
-
158
-
159
- # note: use ^ for start of string only!!!
160
- # - for now slurp everything up to digits (inlc. spaces - use strip to remove)
161
- # todo/check: use/rename to NAME_UNTIL_REGEX ??? ( add lookahead for spaces?)
162
- NAME_REGEX = /^
163
- [^0-9]+
164
- /x
165
-
166
-
167
- # todo/check: change to MINUTE_REGEX ??
168
- # add MINUTE_SKIP_REGEX or MINUTE_SEP_REGEX /^[ ,]+/
169
- # todo/fix: split out penalty and owngoal flag in PATTERN constant for reuse
170
- MINUTES_REGEX = /^ # note: use ^ for start of string only!!!
171
- (?<minute>[0-9]{1,3})
172
- (?:\+
173
- (?<offset>[1-9]{1})
174
- )?
175
- '
176
- (?:[ ]*
177
- \(
178
- (?<type>P|pen\.|o\.g\.)
179
- \)
180
- )?
181
- /x
182
-
183
-
184
-
185
- def initialize
186
- # nothing here for now
187
- end
188
-
189
- def parse!( line, opts={} )
190
-
191
- ## for now assume
192
- ## everything up-to 0-9 and , and () is part of player name
193
-
194
- ## try parsing lhs
195
- ## todo: check for empty - remove (make it same as empty string)
196
-
197
- players = []
198
-
199
- name = get_player_name!( line )
200
- while name
201
- logger.debug " found player name >#{name}< - remaining >#{line}<"
202
-
203
- player = GoalsPlayerStruct.new
204
- player.name = name
205
-
206
- minute_hash = get_minute_hash!( line )
207
- while minute_hash
208
- logger.debug " found minutes >#{minute_hash.inspect}< - remaining >#{line}<"
209
-
210
- minute = GoalsMinuteStruct.new
211
- minute.minute = minute_hash[:minute].to_i
212
- minute.offset = minute_hash[:offset].to_i if minute_hash[:offset]
213
- if minute_hash[:type]
214
- minute.owngoal = true if minute_hash[:type] =~ /o\.g\./
215
- minute.penalty = true if minute_hash[:type] =~ /P|pen\./
216
- end
217
- player.minutes << minute
218
-
219
- # remove commas and spaces (note: use ^ for start of string only!!!)
220
- line.sub!( /^[ ,]+/, '' )
221
- minute_hash = get_minute_hash!( line )
222
- end
223
-
224
- players << player
225
- name = get_player_name!( line )
226
- end
227
-
228
- players
229
- end # method parse!
230
-
231
- private
232
- def get_player_name!( line )
233
- m = NAME_REGEX.match( line )
234
- if m
235
- ## remove from line
236
- line.slice!( 0...m[0].length )
237
- m[0].strip # remove leading and trailing spaces
238
- else
239
- nil
240
- end
241
- end
242
-
243
- def get_minute_hash!( line )
244
- m = MINUTES_REGEX.match( line ) # note: use ^ for start of string only!!!
245
- if m
246
- h = {}
247
- # - note: do NOT forget to turn name into symbol for lookup in new hash (name.to_sym)
248
- m.names.each { |n| h[n.to_sym] = m[n] } # or use match_data.names.zip( match_data.captures ) - more cryptic but "elegant"??
249
-
250
- ## remove matched string from line
251
- line.slice!( 0...m[0].length )
252
- h
253
- else
254
- nil
255
- end
256
- end
257
-
258
- end # class GoalsParser
259
-
260
- end # module SportDb
@@ -1,241 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
- class ScoresFinder
6
-
7
- include LogUtils::Logging
8
-
9
-
10
- ## e.g. 3-4 pen. 2-2 a.e.t. (1-1, 1-1)
11
- EN__P_ET_FT_HT__REGEX = /\b
12
- (?<score1p>\d{1,2})
13
- -
14
- (?<score2p>\d{1,2})
15
- \s* # allow optional spaces
16
- (?:p|pen\.?|pso) # e.g. pen, pen., PSO, p etc.
17
- \s* # allow optional spaces
18
- (?<score1et>\d{1,2})
19
- -
20
- (?<score2et>\d{1,2})
21
- \s* # allow optional spaces
22
- (?:aet|a\.e\.t\.)
23
- \s* # allow optional spaces
24
- \(
25
- (?<score1>\d{1,2})
26
- -
27
- (?<score2>\d{1,2})
28
- \s*
29
- ,
30
- \s*
31
- (?<score1i>\d{1,2})
32
- -
33
- (?<score2i>\d{1,2})
34
- \)
35
- (?=[\s\]]|$)/xi ## todo/check: remove loakahead assertion here - why require space?
36
- ## note: \b works only after non-alphanum e.g. )
37
-
38
-
39
- ## e.g. 2-1 a.e.t. (1-1, 0-0)
40
- EN__ET_FT_HT__REGEX = /\b
41
- (?<score1et>\d{1,2})
42
- -
43
- (?<score2et>\d{1,2})
44
- \s* # allow optional spaces
45
- (?:aet|a\.e\.t\.)
46
- \s* # allow optional spaces
47
- \(
48
- (?<score1>\d{1,2})
49
- -
50
- (?<score2>\d{1,2})
51
- \s*
52
- ,
53
- \s*
54
- (?<score1i>\d{1,2})
55
- -
56
- (?<score2i>\d{1,2})
57
- \)
58
- (?=[\s\]]|$)/xi ## todo/check: remove loakahead assertion here - why require space?
59
- ## note: \b works only after non-alphanum e.g. )
60
-
61
-
62
- ## e.g. 2-1 (1-1)
63
- EN__FT_HT__REGEX = /\b
64
- (?<score1>\d{1,2})
65
- -
66
- (?<score2>\d{1,2})
67
- \s*
68
- \(
69
- (?<score1i>\d{1,2})
70
- -
71
- (?<score2i>\d{1,2})
72
- \)
73
- (?=[\s\]]|$)/x ## todo/check: remove loakahead assertion here - why require space?
74
- ## note: \b works only after non-alphanum e.g. )
75
-
76
-
77
-
78
- ###################
79
- # more
80
-
81
- # e.g. 1:2 or 0:2 or 3:3 or
82
- # 1-1 or 0-2 or 3-3 or
83
- # 1x1 or 1X1 or 0x2 or 3x3 -- used in Brazil / Portugal
84
- FT_REGEX = /\b
85
- (?<score1>\d{1,2})
86
- [:\-xX]
87
- (?<score2>\d{1,2})
88
- \b/x
89
-
90
-
91
- # e.g. 1:2nV => after extra time a.e.t
92
-
93
- # note: possible ending w/ . -> thus cannot use /b will not work w/ .; use zero look-ahead
94
- ET_REGEX = /\b
95
- (?<score1>\d{1,2})
96
- [:\-xX]
97
- (?<score2>\d{1,2})
98
- \s? # allow optional space
99
- (?:nv|n\.v\.|aet|a\.e\.t\.) # allow optional . e.g. nV or n.V.
100
- (?=[\s\)\]]|$)/xi
101
-
102
- ## todo: add/allow english markers e.g. pen or p ??
103
-
104
- # e.g. 5:4iE => penalty / after penalty a.p
105
-
106
-
107
- # note: possible ending w/ . -> thus cannot use /b will not work w/ .; use zero look-ahead
108
- P_REGEX = /\b
109
- (?<score1>\d{1,2})
110
- [:\-xX]
111
- (?<score2>\d{1,2})
112
- \s? # allow optional space
113
- (?:iE|i\.E\.|p|pen|PSO) # allow optional . e.g. iE or i.E.
114
- (?=[\s\)\]]|$)/xi
115
-
116
-
117
- ## todo: allow all-in-one "literal form a la kicker" e.g.
118
- # 2:2 (1:1, 1:0) n.V. 5:1 i.E.
119
-
120
- def initialize
121
- # nothing here for now
122
- end
123
-
124
- def find!( line, opts={} )
125
-
126
- ### fix: add and match all-in-one literal first, followed by
127
-
128
- # note: always call after find_dates !!!
129
- # scores match date-like patterns!! e.g. 10-11 or 10:00 etc.
130
- # -- note: score might have two digits too
131
-
132
- ### fix: depending on language allow 1:1 or 1-1
133
- ## do NOT allow mix and match
134
- ## e.g. default to en is 1-1
135
- ## de is 1:1 etc.
136
-
137
-
138
- # extract score from line
139
- # and return it
140
- # note: side effect - removes date from line string
141
-
142
-
143
- score1i = nil # half time (ht) scores
144
- score2i = nil
145
-
146
- score1 = nil # full time (ft) scores
147
- score2 = nil
148
-
149
- score1et = nil # extra time (et) scores
150
- score2et = nil
151
-
152
- score1p = nil # penalty (p) scores
153
- score2p = nil
154
-
155
-
156
- if (md = EN__P_ET_FT_HT__REGEX.match( line ))
157
- score1i = md[:score1i].to_i
158
- score2i = md[:score2i].to_i
159
- score1 = md[:score1].to_i
160
- score2 = md[:score2].to_i
161
- score1et = md[:score1et].to_i
162
- score2et = md[:score2et].to_i
163
- score1p = md[:score1p].to_i
164
- score2p = md[:score2p].to_i
165
-
166
- logger.debug " score.en__p_et_ft_ht: >#{score1p}-#{score2p} pen. #{score1et}-#{score2et} a.e.t. (#{score1}-#{score2}, #{score1i}-#{score2i})<"
167
-
168
- line.sub!( md[0], '[SCORES.EN__P_ET_FT_HT]' )
169
-
170
- elsif (md = EN__ET_FT_HT__REGEX.match( line ))
171
- score1i = md[:score1i].to_i
172
- score2i = md[:score2i].to_i
173
- score1 = md[:score1].to_i
174
- score2 = md[:score2].to_i
175
- score1et = md[:score1et].to_i
176
- score2et = md[:score2et].to_i
177
-
178
- logger.debug " score.en__et_ft_ht: >#{score1et}-#{score2et} a.e.t. (#{score1}-#{score2}, #{score1i}-#{score2i})<"
179
-
180
- line.sub!( md[0], '[SCORES.EN__ET_FT_HT]' )
181
-
182
- elsif (md = EN__FT_HT__REGEX.match( line ))
183
- score1i = md[:score1i].to_i
184
- score2i = md[:score2i].to_i
185
- score1 = md[:score1].to_i
186
- score2 = md[:score2].to_i
187
-
188
- logger.debug " score.en__ft_ht: >#{score1}-#{score2} (#{score1i}-#{score2i})<"
189
-
190
- line.sub!( md[0], '[SCORES.EN__FT_HT]' )
191
- else
192
- #######################################################
193
- ## try "standard" generic patterns for fallbacks
194
-
195
- if (md = ET_REGEX.match( line ))
196
- score1et = md[:score1].to_i
197
- score2et = md[:score2].to_i
198
-
199
- logger.debug " score.et: >#{score1et}-#{score2et}<"
200
-
201
- line.sub!( md[0], '[SCORE.ET]' )
202
- end
203
-
204
- if (md = P_REGEX.match( line ))
205
- score1p = md[:score1].to_i
206
- score2p = md[:score2].to_i
207
-
208
- logger.debug " score.p: >#{score1p}-#{score2p}<"
209
-
210
- line.sub!( md[0], '[SCORE.P]' )
211
- end
212
-
213
- ## let full time (ft) standard regex go last - has no marker
214
-
215
- if (md = FT_REGEX.match( line ))
216
- score1 = md[:score1].to_i
217
- score2 = md[:score2].to_i
218
-
219
- logger.debug " score: >#{score1}-#{score2}<"
220
-
221
- line.sub!( md[0], '[SCORE]' )
222
- end
223
- end
224
-
225
- ## todo: how to handle game w/o extra time
226
- # but w/ optional penalty ??? e.g. used in copa liberatores, for example
227
- # retrun 0,0 or nil,nil for extra time score ?? or -1, -1 ??
228
- # for now use nil,nil
229
-
230
- scores = []
231
- scores += [score1i, score2i] if score1p || score2p || score1et || score2et || score1 || score2 || score1i || score2i
232
- scores += [score1, score2] if score1p || score2p || score1et || score2et || score1 || score2
233
- scores += [score1et, score2et] if score1p || score2p || score1et || score2et
234
- scores += [score1p, score2p] if score1p || score2p
235
-
236
- scores
237
- end
238
-
239
- end # class ScoresFinder
240
-
241
- end # module SportDb
@@ -1,93 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_scores.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestScores < MiniTest::Test
11
-
12
-
13
- def test_scores
14
- data = [
15
- [ '10:0', [nil,nil,10,0]],
16
- [ '1:22', [nil,nil,1,22]],
17
- [ '1-22', [nil,nil,1,22]],
18
- [ '1x22', [nil,nil,1,22]],
19
- [ '1X22', [nil,nil,1,22]],
20
-
21
-
22
- ## do not support three digits
23
- [ '1-222', []],
24
- [ '111-0', []],
25
- [ '1:222', []],
26
- [ '111:0', []],
27
- [ '111x0', []],
28
- [ '111X0', []],
29
-
30
- ## penality only
31
- [ '3-4iE', [nil,nil,nil,nil,nil,nil,3,4]],
32
- [ '3:4iE', [nil,nil,nil,nil,nil,nil,3,4]],
33
- [ '3:4 iE', [nil,nil,nil,nil,nil,nil,3,4]],
34
- [ '3:4 i.E.', [nil,nil,nil,nil,nil,nil,3,4]],
35
- [ '3-4 pen', [nil,nil,nil,nil,nil,nil,3,4]],
36
- [ '3-4 PSO', [nil,nil,nil,nil,nil,nil,3,4]], # PSO => penalty shotout
37
- [ '3-4p', [nil,nil,nil,nil,nil,nil,3,4]],
38
- [ '3-4 p', [nil,nil,nil,nil,nil,nil,3,4]],
39
-
40
- ## extra time only - allow ?? why not ?? only allow penalty w/ missing extra time?
41
- ## todo/fix: issue warning or error in parser!!!
42
- [ '3-4nV', [nil,nil,nil,nil,3,4]],
43
- [ '3:4nV', [nil,nil,nil,nil,3,4]],
44
- [ '3-4 aet', [nil,nil,nil,nil,3,4]],
45
- [ '3-4 a.e.t.', [nil,nil,nil,nil,3,4]],
46
-
47
- [ '3:4nV 1:1', [nil,nil,1,1,3,4]],
48
- [ '1:1 3:4nV', [nil,nil,1,1,3,4]],
49
- [ '3:4 nV 1:1', [nil,nil,1,1,3,4]],
50
- [ '3:4 n.V. 1:1', [nil,nil,1,1,3,4]],
51
-
52
- [ '3:4iE 1:1', [nil,nil,1,1,nil,nil,3,4]],
53
- [ '1:1 3:4iE', [nil,nil,1,1,nil,nil,3,4]],
54
-
55
- [ '1:1 2:2nV 3:4iE', [nil,nil,1,1,2,2,3,4]],
56
- [ '3:4iE 2:2nV 1:1', [nil,nil,1,1,2,2,3,4]],
57
- [ '3:4 i.E. 2:2 n.V. 1:1', [nil,nil,1,1,2,2,3,4]],
58
- [ '3-4p 2-2aet 1-1', [nil,nil,1,1,2,2,3,4]],
59
- [ '3-4 pen 2-2 aet 1-1', [nil,nil,1,1,2,2,3,4]],
60
-
61
- #####################################################
62
- ## check new all-in-one english (en) formats / patterns
63
- [ '2-1 (1-1)', [1,1,2,1]],
64
- [ '2-1 a.e.t. (1-1, 0-0)', [0,0,1,1,2,1]],
65
- [ '2-1aet (1-1, 0-0)', [0,0,1,1,2,1]],
66
- [ '2-1 A.E.T. (1-1, 0-0)', [0,0,1,1,2,1]],
67
- [ '2-1AET (1-1, 0-0)', [0,0,1,1,2,1]],
68
- [ '3-4 pen. 2-2 a.e.t. (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
69
- [ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
70
- [ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
71
- [ '3-4p 2-2aet (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
72
- [ '3-4PSO 2-2AET (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
73
- ]
74
-
75
- assert_scores( data )
76
- end
77
-
78
- private
79
- def assert_scores( data )
80
- data.each do |rec|
81
- line = rec[0]
82
- exp = rec[1]
83
-
84
- assert_equal exp, parse_scores( line )
85
- end
86
- end
87
-
88
- def parse_scores( line )
89
- finder = SportDb::ScoresFinder.new
90
- finder.find!( line )
91
- end
92
-
93
- end # class TestScores