sportdb-formats 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51b22ea9a05b89006e8048871b2616d5a4fadd4fcb435dc1fd33c1194a6182de
4
- data.tar.gz: '069b114b3679b2f0bf1fda38c4b97b52a949d7e3e0ab1e9cad41e0f08b540c28'
3
+ metadata.gz: a9f1a3d4643a73600d020fd3e34356df44f869eda7a0e1e06479819142f22a57
4
+ data.tar.gz: 1ae30d054bb50a52785bc13c6f3d568129d28cc5c0f10b88bae964ea88263c94
5
5
  SHA512:
6
- metadata.gz: 29f00ceff229bc2e8445ee6ef6c2c0a7ecd27b00c899535130f10f480ec0526b18d5e3df30e78f1577f35f6e65fe6aafff2f99ef587eb869445b9b9ab5f20c2c
7
- data.tar.gz: c97c1568d3b063ba2e25afa21c07479ac4f098df7c0bf2e5a3701a5ef2eb9d8c2c56415573191bae0cb7fbbc07e8ee229eca30fdeda9b1a0713615cdf4c46b5a
6
+ metadata.gz: 752dad1c1f27f0ced1b410232d1b187551eda65e7e1a3be55000b3fa00b669bcfc943da7df1c858eafbabc83b05e9914c86d95e8fc14dc6f4fd7b72bcb1b73da
7
+ data.tar.gz: b92e4b47d4570f54ebd04e3153b05038df6bc5e1f622a45e87d034af38aa5fb31ab7c6d81f4d391a1c99370e5948f13e3f4dff6a00e069d73429e490ec61de91
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 1.2.0
1
+ ### 1.2.1
2
2
 
3
3
  ### 0.0.1 / 2019-10-28
4
4
 
@@ -209,6 +209,10 @@ class GoalsParser
209
209
  include LogUtils::Logging
210
210
 
211
211
 
212
+ ### todo/fix:
213
+ ## let's use stringscanner for parsing line - why? why not?
214
+
215
+
212
216
  # note: use ^ for start of string only!!!
213
217
  # - for now slurp everything up to digits (inlc. spaces - use strip to remove)
214
218
  # todo/check: use/rename to NAME_UNTIL_REGEX ??? ( add lookahead for spaces?)
@@ -220,18 +224,21 @@ class GoalsParser
220
224
  # todo/check: change to MINUTE_REGEX ??
221
225
  # add MINUTE_SKIP_REGEX or MINUTE_SEP_REGEX /^[ ,]+/
222
226
  # todo/fix: split out penalty and owngoal flag in PATTERN constant for reuse
227
+ # note - offset 90+10 possible!!!!
228
+ # note - allow p/pen./pen or o.g. or og
223
229
  MINUTES_REGEX = /^ # note: use ^ for start of string only!!!
224
230
  (?<minute>[0-9]{1,3})
225
231
  (?:\+
226
- (?<offset>[1-9]{1})
232
+ (?<offset>[0-9]{1,2})
227
233
  )?
228
234
  '
229
235
  (?:[ ]*
230
236
  \(
231
- (?<type>P|pen\.|o\.g\.)
237
+ (?<type>p|pen\.?|
238
+ og|o\.g\.)
232
239
  \)
233
240
  )?
234
- /x
241
+ /ix
235
242
 
236
243
 
237
244
 
@@ -256,22 +263,21 @@ class GoalsParser
256
263
  player = GoalsPlayerStruct.new
257
264
  player.name = name
258
265
 
259
- minute_hash = get_minute_hash!( line )
260
- while minute_hash
266
+ minute_hash = nil
267
+ while minute_hash=get_minute_hash!( line ) ## note: returns nil if no (regex) match
261
268
  logger.debug " found minutes >#{minute_hash.inspect}< - remaining >#{line}<"
262
269
 
263
270
  minute = GoalsMinuteStruct.new
264
271
  minute.minute = minute_hash[:minute].to_i
265
272
  minute.offset = minute_hash[:offset].to_i if minute_hash[:offset]
266
273
  if minute_hash[:type]
267
- minute.owngoal = true if minute_hash[:type] =~ /o\.g\./
268
- minute.penalty = true if minute_hash[:type] =~ /P|pen\./
274
+ minute.owngoal = true if minute_hash[:type] =~ /og|o\.g\./i
275
+ minute.penalty = true if minute_hash[:type] =~ /p|pen\.?/i
269
276
  end
270
277
  player.minutes << minute
271
278
 
272
279
  # remove commas and spaces (note: use ^ for start of string only!!!)
273
280
  line.sub!( /^[ ,]+/, '' )
274
- minute_hash = get_minute_hash!( line )
275
281
  end
276
282
 
277
283
  players << player
@@ -297,6 +303,8 @@ private
297
303
  m = MINUTES_REGEX.match( line ) # note: use ^ for start of string only!!!
298
304
  if m
299
305
  h = {}
306
+ ## todo/fix - hash conversion no longer need in ruby 3+!!
307
+ ## double check - and remove (simplify) !!!!
300
308
  # - note: do NOT forget to turn name into symbol for lookup in new hash (name.to_sym)
301
309
  m.names.each { |n| h[n.to_sym] = m[n] } # or use match_data.names.zip( match_data.captures ) - more cryptic but "elegant"??
302
310
 
@@ -362,6 +362,27 @@ class MatchParser ## simple match parser for team match schedules
362
362
  end
363
363
 
364
364
 
365
+ ### todo/check - include (optional) leading space in regex - why? why not?
366
+ NUM_RE = /^[ ]*\(
367
+ (?<num>[0-9]{1,3})
368
+ \)
369
+ /x
370
+
371
+ def find_num!( line )
372
+ ## check for leading match number e.g.
373
+ ## (1) Fri Jun/14 21:00 Germany 5-1 (3-0) Scotland
374
+ m = line.match( NUM_RE )
375
+ if m
376
+ num = m[:num].to_i(10) ## allows 01/02/07 etc. -- why? why not?
377
+ match_str = m[0]
378
+ line.sub!( match_str, '[NUM]' )
379
+ num
380
+ else
381
+ nil
382
+ end
383
+ end
384
+
385
+
365
386
  def try_parse_game( line )
366
387
  # note: clone line; for possible test do NOT modify in place for now
367
388
  # note: returns true if parsed, false if no match
@@ -405,11 +426,16 @@ class MatchParser ## simple match parser for team match schedules
405
426
  return false
406
427
  end
407
428
 
429
+
430
+ ## try optional match number e.g.
431
+ ## (1) Fri Jun/14 21:00 Germany 5-1 (3-0) Scotland
432
+ num = find_num!( line )
433
+ ## pos = find_game_pos!( line )
434
+
408
435
  ## find (optional) match status e.g. [abandoned] or [replay] or [awarded]
409
436
  ## or [cancelled] or [postponed] etc.
410
437
  status = find_status!( line ) ## todo/check: allow match status also in geo part (e.g. after @) - why? why not?
411
438
 
412
- ## pos = find_game_pos!( line )
413
439
 
414
440
  date = find_date!( line, start: @start ) ## date or datetime (but NOT time!)
415
441
 
@@ -475,7 +501,8 @@ class MatchParser ## simple match parser for team match schedules
475
501
  else # assume date is nil
476
502
  end
477
503
 
478
- @matches << Import::Match.new( date: date_str,
504
+ @matches << Import::Match.new( num: num,
505
+ date: date_str,
479
506
  time: time_str,
480
507
  team1: team1, ## note: for now always use mapping value e.g. rec (NOT string e.g. team1.name)
481
508
  team2: team2, ## note: for now always use mapping value e.g. rec (NOT string e.g. team2.name)
@@ -298,11 +298,11 @@ class TeamSearch
298
298
  else
299
299
  if league.clubs?
300
300
  if league.intl? ## todo/fix: add intl? to ActiveRecord league!!!
301
- @club.find!( name )
301
+ @clubs.find!( name )
302
302
  else ## assume clubs in domestic/national league tournament
303
303
  ## note - search by league countries (may incl. more than one country
304
304
  ## e.g. us incl. ca, fr incl. mc, ch incl. li, etc.
305
- @club.find_by!( name: name, league: league )
305
+ @clubs.find_by!( name: name, league: league )
306
306
  end
307
307
  else ## assume national teams (not clubs)
308
308
  @national_teams.find!( name )
@@ -4,7 +4,7 @@ module Formats
4
4
 
5
5
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 2
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-22 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-structs