sportdb-readers 0.2.0 → 0.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b34ccb4d608b438478b0d909f5dad9e5f4807677
|
4
|
+
data.tar.gz: bb1641c9eb65feebd42fbbecb9b3430c0b6c69ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 269f51e9317a5762304ca0e36b9454a47a88e4cf6b7935690e6c2351c475ecfe7a24dffb1ac546af1f8925d3c7173cfb67373d7e46cd0b54923dcdedd8428f8c
|
7
|
+
data.tar.gz: 1e908059a559669c4a8a15ae6c88778c2b9c4f07e2badb1a3dc1a595d3b58c15ee35c5bd57054859afce2e32da356108035b9be926a7d1274cc277d857e3e0a3
|
@@ -5,10 +5,10 @@ module SportDb
|
|
5
5
|
class MatchParserSimpleV2 ## simple match parser for club match schedules
|
6
6
|
include LogUtils::Logging
|
7
7
|
|
8
|
-
def initialize( lines, teams,
|
8
|
+
def initialize( lines, teams, start )
|
9
9
|
@lines = lines ## todo/check: change to text instead of array of lines - why? why not?
|
10
10
|
@mapper_teams = TeamMapper.new( teams )
|
11
|
-
@
|
11
|
+
@start = start
|
12
12
|
|
13
13
|
## build lookup hash by (team) key
|
14
14
|
@teams = teams.reduce({}) { |h,team| h[team.key]=team; h }
|
@@ -241,7 +241,7 @@ class MatchParserSimpleV2 ## simple match parser for club match schedules
|
|
241
241
|
|
242
242
|
## pos = find_game_pos!( line )
|
243
243
|
|
244
|
-
date = find_date!( line,
|
244
|
+
date = find_date!( line, start: @start )
|
245
245
|
|
246
246
|
###
|
247
247
|
# check if date found?
|
@@ -422,18 +422,17 @@ class MatchParserSimpleV2 ## simple match parser for club match schedules
|
|
422
422
|
parse_date_header( line.dup )
|
423
423
|
end
|
424
424
|
|
425
|
-
def find_date!( line,
|
425
|
+
def find_date!( line, start: )
|
426
426
|
## NB: lets us pass in start_at/end_at date (for event)
|
427
427
|
# for auto-complete year
|
428
428
|
|
429
429
|
# extract date from line
|
430
430
|
# and return it
|
431
431
|
# NB: side effect - removes date from line string
|
432
|
-
|
433
|
-
finder = DateFinder.new
|
434
|
-
finder.find!( line, opts )
|
432
|
+
DateFormats.find!( line, start: start )
|
435
433
|
end
|
436
434
|
|
435
|
+
|
437
436
|
def parse_date_header( line )
|
438
437
|
# note: returns true if parsed, false if no match
|
439
438
|
|
@@ -447,7 +446,7 @@ class MatchParserSimpleV2 ## simple match parser for club match schedules
|
|
447
446
|
team1_key = team_keys[0]
|
448
447
|
team2_key = team_keys[1]
|
449
448
|
|
450
|
-
date = find_date!( line,
|
449
|
+
date = find_date!( line, start: @start )
|
451
450
|
|
452
451
|
if date && team1_key.nil? && team2_key.nil?
|
453
452
|
logger.debug( "date header line found: >#{line}<")
|
@@ -28,8 +28,16 @@ class MatchReaderV2 ## todo/check: rename to MatchReaderV2 (use plural?) why?
|
|
28
28
|
## hack for now: switch lang
|
29
29
|
if ['at', 'de'].include?( league.country.key )
|
30
30
|
SportDb.lang.lang = 'de'
|
31
|
+
DateFormats.lang = 'de'
|
32
|
+
elsif ['fr'].include?( league.country.key )
|
33
|
+
SportDb.lang.lang = 'fr'
|
34
|
+
DateFormats.lang = 'fr'
|
35
|
+
elsif ['es'].include?( league.country.key )
|
36
|
+
SportDb.lang.lang = 'es'
|
37
|
+
DateFormats.lang = 'es'
|
31
38
|
else
|
32
39
|
SportDb.lang.lang = 'en'
|
40
|
+
DateFormats.lang = 'en'
|
33
41
|
end
|
34
42
|
|
35
43
|
## todo/fix: set lang for now depending on league country!!!
|
data/test/test_match_parser.rb
CHANGED
@@ -96,10 +96,10 @@ TXT
|
|
96
96
|
lines = txt.split( /\n+/ ) # note: removes/strips empty lines
|
97
97
|
pp lines
|
98
98
|
|
99
|
-
|
99
|
+
start = Date.new( 2017, 7, 1 )
|
100
100
|
|
101
|
-
|
102
|
-
parser = SportDb::MatchParserSimpleV2.new( lines, clubs,
|
101
|
+
DateFormats.lang = 'en'
|
102
|
+
parser = SportDb::MatchParserSimpleV2.new( lines, clubs, start )
|
103
103
|
rounds, matches = parser.parse
|
104
104
|
pp rounds
|
105
105
|
pp matches
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-readers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.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: 2019-11-
|
11
|
+
date: 2019-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-config
|