sportdb-models 1.17.0 → 1.18.0

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: f2bdecfa31a07aeef927ef1a0f287ad27ba57fee
4
- data.tar.gz: ee12cdb555d85ca403b6674d7618824f65d391d1
3
+ metadata.gz: 8222b8d66c000dbd1e891ea4bc7aad1c43fdb25c
4
+ data.tar.gz: 5a1cf9608b78f92bde855509e2690025f6604b27
5
5
  SHA512:
6
- metadata.gz: 1dfeeed897d041f727652e90066850b0a2d623af67c3dee3a79f3851a312d364374fe09058865f0d7b9e4b2be6f66d66776d4534f91780f4261e4a8e721f537e
7
- data.tar.gz: 2dc970f7f0c74f4e4aa469e143f1797a2de9cbc58b4bff72ad2a0fc27e36342e69e025d94d0259e0439937177f3ee86b990bbdbcfea182e70613d3a98b10e09f
6
+ metadata.gz: 99a04b1b354c0655e28a6124f473106792e03d4d5eb7eb5af22a8c4d7b7c48cffdbf0c533fcf83458ae13e9ff524be6d2d18ba689027b46735bd793e8b57f578
7
+ data.tar.gz: 38ca6f564cc5b228264e1933df462e8dc5aa82739d7b43be4e9bdfe18e2bbfacea2f506168e1788ded408a12c94686f83b5baccfe5ae7e2726b700b97c8eb864
@@ -6,6 +6,78 @@ class ScoresFinder
6
6
 
7
7
  include LogUtils::Logging
8
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
+
9
81
  # e.g. 1:2 or 0:2 or 3:3 or
10
82
  # 1-1 or 0-2 or 3-3
11
83
  FT_REGEX = /\b
@@ -16,14 +88,14 @@ class ScoresFinder
16
88
 
17
89
 
18
90
  # e.g. 1:2nV => after extra time a.e.t
19
-
91
+
20
92
  # note: possible ending w/ . -> thus cannot use /b will not work w/ .; use zero look-ahead
21
93
  ET_REGEX = /\b
22
94
  (?<score1>\d{1,2})
23
95
  [:\-]
24
96
  (?<score2>\d{1,2})
25
97
  \s? # allow optional space
26
- (?:nV|n\.V\.|aet|a\.e\.t\.) # allow optional . e.g. nV or n.V.
98
+ (?:nv|n\.v\.|aet|a\.e\.t\.) # allow optional . e.g. nV or n.V.
27
99
  (?=[\s\)\]]|$)/xi
28
100
 
29
101
  ## todo: add/allow english markers e.g. pen or p ??
@@ -60,48 +132,93 @@ class ScoresFinder
60
132
  ## do NOT allow mix and match
61
133
  ## e.g. default to en is 1-1
62
134
  ## de is 1:1 etc.
63
-
135
+
64
136
 
65
137
  # extract score from line
66
138
  # and return it
67
- # NB: side effect - removes date from line string
139
+ # note: side effect - removes date from line string
68
140
 
69
- score1 = nil
141
+
142
+ score1i = nil # half time (ht) scores
143
+ score2i = nil
144
+
145
+ score1 = nil # full time (ft) scores
70
146
  score2 = nil
71
-
72
- score1et = nil
147
+
148
+ score1et = nil # extra time (et) scores
73
149
  score2et = nil
74
-
75
- score1p = nil
150
+
151
+ score1p = nil # penalty (p) scores
76
152
  score2p = nil
77
153
 
78
- if (md = ET_REGEX.match( line ))
79
- score1et = md[:score1].to_i
80
- score2et = md[:score2].to_i
81
-
82
- logger.debug " score.et: >#{score1et}-#{score2et}<"
83
-
84
- line.sub!( md[0], '[SCORE.ET]' )
85
- end
86
154
 
87
- if (md = P_REGEX.match( line ))
88
- score1p = md[:score1].to_i
89
- score2p = md[:score2].to_i
90
-
91
- logger.debug " score.p: >#{score1p}-#{score2p}<"
92
-
93
- line.sub!( md[0], '[SCORE.P]' )
94
- end
155
+ if (md = EN__P_ET_FT_HT__REGEX.match( line ))
156
+ score1i = md[:score1i].to_i
157
+ score2i = md[:score2i].to_i
158
+ score1 = md[:score1].to_i
159
+ score2 = md[:score2].to_i
160
+ score1et = md[:score1et].to_i
161
+ score2et = md[:score2et].to_i
162
+ score1p = md[:score1p].to_i
163
+ score2p = md[:score2p].to_i
164
+
165
+ logger.debug " score.en__p_et_ft_ht: >#{score1p}-#{score2p} pen. #{score1et}-#{score2et} a.e.t. (#{score1}-#{score2}, #{score1i}-#{score2i})<"
166
+
167
+ line.sub!( md[0], '[SCORES.EN__P_ET_FT_HT]' )
168
+
169
+ elsif (md = EN__ET_FT_HT__REGEX.match( line ))
170
+ score1i = md[:score1i].to_i
171
+ score2i = md[:score2i].to_i
172
+ score1 = md[:score1].to_i
173
+ score2 = md[:score2].to_i
174
+ score1et = md[:score1et].to_i
175
+ score2et = md[:score2et].to_i
176
+
177
+ logger.debug " score.en__et_ft_ht: >#{score1et}-#{score2et} a.e.t. (#{score1}-#{score2}, #{score1i}-#{score2i})<"
178
+
179
+ line.sub!( md[0], '[SCORES.EN__ET_FT_HT]' )
180
+
181
+ elsif (md = EN__FT_HT__REGEX.match( line ))
182
+ score1i = md[:score1i].to_i
183
+ score2i = md[:score2i].to_i
184
+ score1 = md[:score1].to_i
185
+ score2 = md[:score2].to_i
186
+
187
+ logger.debug " score.en__ft_ht: >#{score1}-#{score2} (#{score1i}-#{score2i})<"
188
+
189
+ line.sub!( md[0], '[SCORES.EN__FT_HT]' )
190
+ else
191
+ #######################################################
192
+ ## try "standard" generic patterns for fallbacks
193
+
194
+ if (md = ET_REGEX.match( line ))
195
+ score1et = md[:score1].to_i
196
+ score2et = md[:score2].to_i
197
+
198
+ logger.debug " score.et: >#{score1et}-#{score2et}<"
199
+
200
+ line.sub!( md[0], '[SCORE.ET]' )
201
+ end
202
+
203
+ if (md = P_REGEX.match( line ))
204
+ score1p = md[:score1].to_i
205
+ score2p = md[:score2].to_i
206
+
207
+ logger.debug " score.p: >#{score1p}-#{score2p}<"
208
+
209
+ line.sub!( md[0], '[SCORE.P]' )
210
+ end
211
+
212
+ ## let full time (ft) standard regex go last - has no marker
95
213
 
96
- ## let full time (ft) standard regex go last - has no marker
214
+ if (md = FT_REGEX.match( line ))
215
+ score1 = md[:score1].to_i
216
+ score2 = md[:score2].to_i
97
217
 
98
- if (md = FT_REGEX.match( line ))
99
- score1 = md[:score1].to_i
100
- score2 = md[:score2].to_i
218
+ logger.debug " score: >#{score1}-#{score2}<"
101
219
 
102
- logger.debug " score: >#{score1}-#{score2}<"
103
-
104
- line.sub!( md[0], '[SCORE]' )
220
+ line.sub!( md[0], '[SCORE]' )
221
+ end
105
222
  end
106
223
 
107
224
  ## todo: how to handle game w/o extra time
@@ -110,8 +227,9 @@ class ScoresFinder
110
227
  # for now use nil,nil
111
228
 
112
229
  scores = []
230
+ scores += [score1i, score2i] if score1p || score2p || score1et || score2et || score1 || score2 || score1i || score2i
113
231
  scores += [score1, score2] if score1p || score2p || score1et || score2et || score1 || score2
114
- scores += [score1et, score2et] if score1p || score2p || score1et || score2et
232
+ scores += [score1et, score2et] if score1p || score2p || score1et || score2et
115
233
  scores += [score1p, score2p] if score1p || score2p
116
234
 
117
235
  scores
@@ -119,4 +237,4 @@ class ScoresFinder
119
237
 
120
238
  end # class ScoresFinder
121
239
 
122
- end # module SportDb
240
+ end # module SportDb
@@ -25,7 +25,7 @@ class GameReader
25
25
  entry = zip_file.find_entry( entry_path )
26
26
  event_text = entry.get_input_stream().read()
27
27
  event_text = event_text.force_encoding( Encoding::UTF_8 )
28
-
28
+
29
29
  ## hack:
30
30
  ## support old event config format for now (will get removed later)
31
31
  ## e.g. check for
@@ -43,7 +43,7 @@ class GameReader
43
43
  reader = EventMetaReader.from_zip( zip_file, entry_path )
44
44
  reader.read()
45
45
  end
46
-
46
+
47
47
  event = reader.event ## was fetch_event( name )
48
48
  fixtures = reader.fixtures ## was fetch_event_fixtures( name )
49
49
 
@@ -78,7 +78,7 @@ class GameReader
78
78
  logger = LogKernel::Logger.root
79
79
 
80
80
  ### NOTE: fix-fix-fix - pass in event path!!!!!!! (not fixture path!!!!)
81
-
81
+
82
82
  ## - ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
83
83
  ## - ## - see textutils/utils.rb
84
84
  ## - text = File.read_utf8( path )
@@ -135,7 +135,7 @@ class GameReader
135
135
  ### fix - fix -fix:
136
136
  ## change event to event_or_event_key !!!!! - allow event_key as string passed in
137
137
  self.new( event, text_or_text_ary, more_attribs )
138
- end
138
+ end
139
139
 
140
140
 
141
141
  def initialize( event, text_or_text_ary, more_attribs={} )
@@ -171,7 +171,7 @@ class GameReader
171
171
  end
172
172
 
173
173
  ## fix add prop ??
174
- ### Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
174
+ ### Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
175
175
  end
176
176
 
177
177
 
@@ -209,7 +209,7 @@ class GameReader
209
209
 
210
210
 
211
211
  parse_fixtures( reader )
212
-
212
+
213
213
  end # method load_fixtures
214
214
 
215
215
 
@@ -220,7 +220,7 @@ class GameReader
220
220
  # note: group header resets (last) round (allows, for example):
221
221
  # e.g.
222
222
  # Group Playoffs/Replays -- round header
223
- # team1 team2 -- match
223
+ # team1 team2 -- match
224
224
  # Group B: -- group header
225
225
  # team1 team2 - match (will get new auto-matchday! not last round)
226
226
  @round = nil ## fix: change/rename to @last_round !!!
@@ -238,10 +238,10 @@ class GameReader
238
238
 
239
239
  def parse_group_def( line )
240
240
  logger.debug "parsing group def line: >#{line}<"
241
-
241
+
242
242
  @mapper_teams.map_teams!( line )
243
243
  team_keys = @mapper_teams.find_teams!( line )
244
-
244
+
245
245
  title, pos = find_group_title_and_pos!( line )
246
246
 
247
247
  logger.debug " line: >#{line}<"
@@ -249,7 +249,7 @@ class GameReader
249
249
  group_attribs = {
250
250
  title: title
251
251
  }
252
-
252
+
253
253
  group = Group.find_by_event_id_and_pos( @event.id, pos )
254
254
  if group.present?
255
255
  logger.debug "update group #{group.id}:"
@@ -261,9 +261,9 @@ class GameReader
261
261
  pos: pos
262
262
  })
263
263
  end
264
-
264
+
265
265
  logger.debug group_attribs.to_json
266
-
266
+
267
267
  group.update_attributes!( group_attribs )
268
268
 
269
269
  group.teams.clear # remove old teams
@@ -284,7 +284,7 @@ class GameReader
284
284
 
285
285
  start_at = find_date!( line, start_at: @event.start_at )
286
286
  end_at = find_date!( line, start_at: @event.start_at )
287
-
287
+
288
288
  # note: if end_at missing -- assume start_at is (==) end_at
289
289
  end_at = start_at if end_at.nil?
290
290
 
@@ -330,7 +330,7 @@ class GameReader
330
330
  else
331
331
  logger.debug "create round:"
332
332
  round = Round.new
333
-
333
+
334
334
  round_attribs = round_attribs.merge( {
335
335
  event_id: @event.id,
336
336
  pos: pos
@@ -338,7 +338,7 @@ class GameReader
338
338
  end
339
339
 
340
340
  logger.debug round_attribs.to_json
341
-
341
+
342
342
  round.update_attributes!( round_attribs )
343
343
  end
344
344
 
@@ -397,7 +397,7 @@ class GameReader
397
397
  end
398
398
 
399
399
  logger.debug " line: >#{line}<"
400
-
400
+
401
401
  ## NB: dummy/placeholder start_at, end_at date
402
402
  ## replace/patch after adding all games for round
403
403
 
@@ -410,7 +410,7 @@ class GameReader
410
410
  if pos > 999000
411
411
  # no pos (e.g. will get autonumbered later) - try match by title for now
412
412
  # e.g. lets us use title 'Group Replays', for example, multiple times
413
- @round = Round.find_by_event_id_and_title( @event.id, title )
413
+ @round = Round.find_by_event_id_and_title( @event.id, title )
414
414
  else
415
415
  @round = Round.find_by_event_id_and_pos( @event.id, pos )
416
416
  end
@@ -420,7 +420,7 @@ class GameReader
420
420
  else
421
421
  logger.debug "create round:"
422
422
  @round = Round.new
423
-
423
+
424
424
  round_attribs = round_attribs.merge( {
425
425
  event_id: @event.id,
426
426
  pos: pos,
@@ -430,7 +430,7 @@ class GameReader
430
430
  end
431
431
 
432
432
  logger.debug round_attribs.to_json
433
-
433
+
434
434
  @round.update_attributes!( round_attribs )
435
435
 
436
436
  @patch_round_ids_pos << @round.id if pos > 999000
@@ -451,7 +451,7 @@ class GameReader
451
451
  @mapper_teams.map_teams!( line ) ### todo/fix: limit mapping to two(2) teams - why? why not? might avoid matching @ Barcelona ??
452
452
  team_keys = @mapper_teams.find_teams!( line )
453
453
  team1_key = team_keys[0]
454
- team2_key = team_keys[1]
454
+ team2_key = team_keys[1]
455
455
 
456
456
  ## note: if we do NOT find two teams; return false - no match found
457
457
  if team1_key.nil? || team2_key.nil?
@@ -488,9 +488,9 @@ class GameReader
488
488
  ####
489
489
  # note:
490
490
  # only map ground if we got any grounds (setup/configured in event)
491
-
491
+
492
492
  if @event.grounds.count > 0
493
-
493
+
494
494
  ## todo/check: use @known_grounds for check?? why? why not??
495
495
  ## use in @known_grounds = TextUtils.build_title_table_for( @event.grounds )
496
496
 
@@ -520,15 +520,15 @@ class GameReader
520
520
 
521
521
  if @round.nil?
522
522
  ## no round header found; calculate round from date
523
-
523
+
524
524
  ###
525
525
  ## todo/fix: add some unit tests for round look up
526
526
  # fix: use date_v2 if present!! (old/original date; otherwise use date)
527
-
527
+
528
528
  #
529
529
  # fix: check - what to do with hours e.g. start_at use 00:00 and for end_at use 23.59 ??
530
530
  # -- for now - remove hours (e.g. use end_of_day and beginnig_of_day)
531
-
531
+
532
532
  ##
533
533
  # note: start_at and end_at are dates ONLY (note datetime)
534
534
  # - do NOT pass in hours etc. in query
@@ -565,7 +565,7 @@ class GameReader
565
565
  title: "Matchday #{date.to_date}",
566
566
  pos: 999001+@patch_round_ids_pos.length, # e.g. 999<count> - 999001,999002,etc.
567
567
  start_at: date.to_date,
568
- end_at: date.to_date
568
+ end_at: date.to_date
569
569
  }
570
570
 
571
571
  logger.info( " auto-add round >Matchday #{date.to_date}<" )
@@ -582,7 +582,7 @@ class GameReader
582
582
  if round.pos > 999000
583
583
  # note: do NOT update last_round_pos for to-be-patched rounds
584
584
  else
585
- @last_round_pos = [round.pos,@last_round_pos||0].max
585
+ @last_round_pos = [round.pos,@last_round_pos||0].max
586
586
  end
587
587
 
588
588
  ## note: will crash (round.pos) if round is nil
@@ -600,16 +600,18 @@ class GameReader
600
600
  )
601
601
 
602
602
  game_attribs = {
603
- score1: scores[0],
604
- score2: scores[1],
605
- score1et: scores[2],
606
- score2et: scores[3],
607
- score1p: scores[4],
608
- score2p: scores[5],
603
+ score1i: scores[0],
604
+ score2i: scores[1],
605
+ score1: scores[2],
606
+ score2: scores[3],
607
+ score1et: scores[4],
608
+ score2et: scores[5],
609
+ score1p: scores[6],
610
+ score2p: scores[7],
609
611
  play_at: date,
610
612
  play_at_v2: date_v2,
611
613
  postponed: postponed,
612
- knockout: round.knockout, ## note: for now always use knockout flag from round - why? why not??
614
+ knockout: round.knockout, ## note: for now always use knockout flag from round - why? why not??
613
615
  ground_id: ground.present? ? ground.id : nil,
614
616
  group_id: @group.present? ? @group.id : nil
615
617
  }
@@ -633,10 +635,10 @@ class GameReader
633
635
  team1_id: team1.id,
634
636
  team2_id: team2.id
635
637
  }
636
-
638
+
637
639
  ## NB: use round.games.count for pos
638
640
  ## lets us add games out of order if later needed
639
- more_game_attribs[ :pos ] = round.games.count+1 if pos.nil?
641
+ more_game_attribs[ :pos ] = round.games.count+1 if pos.nil?
640
642
 
641
643
  game_attribs = game_attribs.merge( more_game_attribs )
642
644
  end
@@ -644,7 +646,7 @@ class GameReader
644
646
  logger.debug game_attribs.to_json
645
647
  game.update_attributes!( game_attribs )
646
648
  end
647
-
649
+
648
650
  @last_game = game # store for later reference (e.g. used for goals etc.)
649
651
 
650
652
  return true # game match found
@@ -659,7 +661,7 @@ class GameReader
659
661
 
660
662
  def parse_date_header( line )
661
663
  # note: returns true if parsed, false if no match
662
-
664
+
663
665
  # line with NO teams plus include date e.g.
664
666
  # [Fri Jun/17] or
665
667
  # Jun/17 or
@@ -676,7 +678,7 @@ class GameReader
676
678
  if date && team1_key.nil? && team2_key.nil?
677
679
  logger.debug( "date header line found: >#{line}<")
678
680
  logger.debug( " date: #{date}")
679
-
681
+
680
682
  @last_date = date # keep a reference for later use
681
683
  return true
682
684
  else
@@ -694,12 +696,12 @@ class GameReader
694
696
  #
695
697
  squad1_count = Roster.where( event_id: @event.id, team_id: @last_team1 ).count
696
698
  if squad1_count > 0
697
- squad1 = Roster.where( event_id: @event.id, team_id: @last_team1 )
699
+ squad1 = Roster.where( event_id: @event.id, team_id: @last_team1 )
698
700
  else
699
701
  squad1 = []
700
702
  end
701
703
 
702
- squad2_count = Roster.where( event_id: @event.id, team_id: @last_team2 ).count
704
+ squad2_count = Roster.where( event_id: @event.id, team_id: @last_team2 ).count
703
705
  if squad2_count > 0
704
706
  squad2 = Roster.where( event_id: @event.id, team_id: @last_team2 )
705
707
  else
@@ -750,7 +752,7 @@ class GameReader
750
752
  else
751
753
  # auto-create player (player not found)
752
754
  logger.info " player NOT found >#{player_name}< - auto-create"
753
-
755
+
754
756
  ## fix: add auto flag (for auto-created persons/players)
755
757
  ## fix: move title_to_key logic to person model etc.
756
758
  player_key = TextUtils.title_to_key( player_name )
@@ -759,7 +761,7 @@ class GameReader
759
761
  title: player_name
760
762
  }
761
763
  logger.info " using attribs: #{player_attribs.inspect}"
762
-
764
+
763
765
  player = Person.create!( player_attribs )
764
766
  end
765
767
  end
@@ -767,7 +769,7 @@ class GameReader
767
769
 
768
770
  goal_attribs = {
769
771
  game_id: @last_game.id,
770
- team_id: goal.team == 1 ? @last_team1.id : @last_team2.id,
772
+ team_id: goal.team == 1 ? @last_team1.id : @last_team2.id,
771
773
  person_id: player.id,
772
774
  minute: goal.minute,
773
775
  offset: goal.offset,
@@ -799,12 +801,12 @@ def self.create_or_update_from_values( values, more_attribs={} )
799
801
 
800
802
 
801
803
  def parse_fixtures( reader )
802
-
804
+
803
805
  reader.each_line do |line|
804
806
 
805
807
  if is_goals?( line )
806
808
  parse_goals( line )
807
- elsif is_round_def?( line )
809
+ elsif is_round_def?( line )
808
810
  ## todo/fix: add round definition (w begin n end date)
809
811
  ## todo: do not patch rounds with definition (already assume begin/end date is good)
810
812
  ## -- how to deal with matches that get rescheduled/postponed?
@@ -3,7 +3,7 @@
3
3
  module SportDb
4
4
 
5
5
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 17
6
+ MINOR = 18
7
7
  PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
@@ -1,5 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_scores.rb
6
+ # or better
7
+ # rake -I ./lib test
8
+
9
+
10
+
3
11
  require 'helper'
4
12
 
5
13
  class TestScores < MiniTest::Test
@@ -7,46 +15,59 @@ class TestScores < MiniTest::Test
7
15
 
8
16
  def test_scores
9
17
  data = [
10
- [ '10:0', [10,0]],
11
- [ '1:22', [1,22]],
12
- [ '1-22', [1,22]],
18
+ [ '10:0', [nil,nil,10,0]],
19
+ [ '1:22', [nil,nil,1,22]],
20
+ [ '1-22', [nil,nil,1,22]],
13
21
 
14
22
  ## do not support three digits
15
- [ '1-222', []],
23
+ [ '1-222', []],
16
24
  [ '111-0', []],
17
25
  [ '1:222', []],
18
26
  [ '111:0', []],
19
27
 
20
28
  ## penality only
21
- [ '3-4iE', [nil,nil,nil,nil,3,4]],
22
- [ '3:4iE', [nil,nil,nil,nil,3,4]],
23
- [ '3:4 iE', [nil,nil,nil,nil,3,4]],
24
- [ '3:4 i.E.', [nil,nil,nil,nil,3,4]],
25
- [ '3-4 pen', [nil,nil,nil,nil,3,4]],
26
- [ '3-4 PSO', [nil,nil,nil,nil,3,4]], # PSO => penalty shotout
27
- [ '3-4p', [nil,nil,nil,nil,3,4]],
28
- [ '3-4 p', [nil,nil,nil,nil,3,4]],
29
+ [ '3-4iE', [nil,nil,nil,nil,nil,nil,3,4]],
30
+ [ '3:4iE', [nil,nil,nil,nil,nil,nil,3,4]],
31
+ [ '3:4 iE', [nil,nil,nil,nil,nil,nil,3,4]],
32
+ [ '3:4 i.E.', [nil,nil,nil,nil,nil,nil,3,4]],
33
+ [ '3-4 pen', [nil,nil,nil,nil,nil,nil,3,4]],
34
+ [ '3-4 PSO', [nil,nil,nil,nil,nil,nil,3,4]], # PSO => penalty shotout
35
+ [ '3-4p', [nil,nil,nil,nil,nil,nil,3,4]],
36
+ [ '3-4 p', [nil,nil,nil,nil,nil,nil,3,4]],
29
37
 
30
38
  ## extra time only - allow ?? why not ?? only allow penalty w/ missing extra time?
31
39
  ## todo/fix: issue warning or error in parser!!!
32
- [ '3-4nV', [nil,nil,3,4]],
33
- [ '3:4nV', [nil,nil,3,4]],
34
- [ '3-4 aet', [nil,nil,3,4]],
35
- [ '3-4 a.e.t.', [nil,nil,3,4]],
36
-
37
- [ '3:4nV 1:1', [1,1,3,4]],
38
- [ '1:1 3:4nV', [1,1,3,4]],
39
- [ '3:4 nV 1:1', [1,1,3,4]],
40
- [ '3:4 n.V. 1:1', [1,1,3,4]],
41
-
42
- [ '3:4iE 1:1', [1,1,nil,nil,3,4]],
43
- [ '1:1 3:4iE', [1,1,nil,nil,3,4]],
44
-
45
- [ '1:1 2:2nV 3:4iE', [1,1,2,2,3,4]],
46
- [ '3:4iE 2:2nV 1:1', [1,1,2,2,3,4]],
47
- [ '3:4 i.E. 2:2 n.V. 1:1', [1,1,2,2,3,4]],
48
- [ '3-4p 2-2aet 1-1', [1,1,2,2,3,4]],
49
- [ '3-4 pen 2-2 aet 1-1', [1,1,2,2,3,4]]
40
+ [ '3-4nV', [nil,nil,nil,nil,3,4]],
41
+ [ '3:4nV', [nil,nil,nil,nil,3,4]],
42
+ [ '3-4 aet', [nil,nil,nil,nil,3,4]],
43
+ [ '3-4 a.e.t.', [nil,nil,nil,nil,3,4]],
44
+
45
+ [ '3:4nV 1:1', [nil,nil,1,1,3,4]],
46
+ [ '1:1 3:4nV', [nil,nil,1,1,3,4]],
47
+ [ '3:4 nV 1:1', [nil,nil,1,1,3,4]],
48
+ [ '3:4 n.V. 1:1', [nil,nil,1,1,3,4]],
49
+
50
+ [ '3:4iE 1:1', [nil,nil,1,1,nil,nil,3,4]],
51
+ [ '1:1 3:4iE', [nil,nil,1,1,nil,nil,3,4]],
52
+
53
+ [ '1:1 2:2nV 3:4iE', [nil,nil,1,1,2,2,3,4]],
54
+ [ '3:4iE 2:2nV 1:1', [nil,nil,1,1,2,2,3,4]],
55
+ [ '3:4 i.E. 2:2 n.V. 1:1', [nil,nil,1,1,2,2,3,4]],
56
+ [ '3-4p 2-2aet 1-1', [nil,nil,1,1,2,2,3,4]],
57
+ [ '3-4 pen 2-2 aet 1-1', [nil,nil,1,1,2,2,3,4]],
58
+
59
+ #####################################################
60
+ ## check new all-in-one english (en) formats / patterns
61
+ [ '2-1 (1-1)', [1,1,2,1]],
62
+ [ '2-1 a.e.t. (1-1, 0-0)', [0,0,1,1,2,1]],
63
+ [ '2-1aet (1-1, 0-0)', [0,0,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
+ [ '3-4 pen. 2-2 a.e.t. (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
67
+ [ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
68
+ [ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
69
+ [ '3-4p 2-2aet (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
70
+ [ '3-4PSO 2-2AET (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
50
71
  ]
51
72
 
52
73
  assert_scores( data )
@@ -59,7 +80,7 @@ private
59
80
  exp = rec[1]
60
81
 
61
82
  assert_equal exp, parse_scores( line )
62
- end
83
+ end
63
84
  end
64
85
 
65
86
  def parse_scores( line )
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.17.0
4
+ version: 1.18.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: 2017-12-01 00:00:00.000000000 Z
11
+ date: 2018-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: worlddb-models