sportdb-formats 1.1.0 → 1.1.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cdd2bc410771494ed506a24d384ca3c8b1c9684
|
4
|
+
data.tar.gz: 066f5288da503a00efe280369f57d6cd65bf4bf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f61edee9495047fc49dfb5720c7afc1e0e316e5fab024d8fc0b1bd5fcdad70524f6e22d24d8fad0aa679380565e0a0c7e36fae79c170655f8a7a496dee170aca
|
7
|
+
data.tar.gz: b378202d2c8152ac46386618d3c69c03d802b1439e74175f8d84fad304ce111edb0bb1cd848fc969848ce55e0cf8de15a46bec322351d5d199652ed16d41b164
|
@@ -100,6 +100,9 @@ module SportDb
|
|
100
100
|
## optional headers - note: find_header returns nil if header NOT found
|
101
101
|
header_stage = find_header( headers, ['Stage'] )
|
102
102
|
headers_mapping[:stage] = header_stage if header_stage
|
103
|
+
|
104
|
+
header_league = find_header( headers, ['League'] )
|
105
|
+
headers_mapping[:league] = header_league if header_league
|
103
106
|
else
|
104
107
|
## else try footballdata.uk and others
|
105
108
|
headers_mapping[:team1] = find_header( headers, ['HomeTeam', 'HT', 'Home'] )
|
@@ -290,13 +293,17 @@ module SportDb
|
|
290
293
|
end
|
291
294
|
end
|
292
295
|
|
296
|
+
league = nil
|
297
|
+
league = row[ headers_mapping[ :league ]] if headers_mapping[ :league ]
|
298
|
+
|
293
299
|
|
294
300
|
match = Import::Match.new( date: date,
|
295
301
|
team1: team1, team2: team2,
|
296
302
|
score1: score1, score2: score2,
|
297
303
|
score1i: score1i, score2i: score2i,
|
298
304
|
round: round,
|
299
|
-
stage: stage
|
305
|
+
stage: stage,
|
306
|
+
league: league )
|
300
307
|
matches << match
|
301
308
|
end
|
302
309
|
|
@@ -73,6 +73,10 @@ module SportDb
|
|
73
73
|
/[a-z0-9_.-]+\.csv$ ## note: allow dot (.) too e.g /eng.1.csv
|
74
74
|
}x
|
75
75
|
|
76
|
+
### add "generic" pattern to find all csv datafiles
|
77
|
+
CSV_RE = %r{ (?: ^|/ )
|
78
|
+
[a-z0-9_.-]+\.csv$ ## note: allow dot (.) too e.g /eng.1.csv
|
79
|
+
}x
|
76
80
|
|
77
81
|
|
78
82
|
## move class-level "static" finders to DirPackage (do NOT work for now for zip packages) - why? why not?
|
@@ -118,6 +122,7 @@ module SportDb
|
|
118
122
|
end
|
119
123
|
## add match_match and match_match_csv - why? why not?
|
120
124
|
|
125
|
+
|
121
126
|
class << self
|
122
127
|
alias_method :match_teams?, :match_teams
|
123
128
|
alias_method :teams?, :match_teams
|
@@ -212,6 +217,8 @@ module SportDb
|
|
212
217
|
end
|
213
218
|
end
|
214
219
|
def each_match_csv( &blk ) each( pattern: MATCH_CSV_RE, &blk ); end
|
220
|
+
def each_csv( &blk ) each( pattern: CSV_RE, &blk ); end
|
221
|
+
|
215
222
|
def each_club_props( &blk ) each( pattern: CLUB_PROPS_RE, &blk ); end
|
216
223
|
|
217
224
|
def each_leagues( &blk ) each( pattern: LEAGUES_RE, &blk ); end
|
@@ -20,7 +20,8 @@ class Match
|
|
20
20
|
:group,
|
21
21
|
:conf1, :conf2, ## special case for mls e.g. conference1, conference2 (e.g. west, east, central)
|
22
22
|
:country1, :country2, ## special case for champions league etc. - uses FIFA country code
|
23
|
-
:comments
|
23
|
+
:comments,
|
24
|
+
:league ## (optinal) added as text for now (use struct?)
|
24
25
|
|
25
26
|
def initialize( **kwargs )
|
26
27
|
update( kwargs ) unless kwargs.empty?
|
@@ -47,6 +48,9 @@ class Match
|
|
47
48
|
@group = kwargs[:group] if kwargs.has_key? :group
|
48
49
|
@comments = kwargs[:comments] if kwargs.has_key? :comments
|
49
50
|
|
51
|
+
@league = kwargs[:league] if kwargs.has_key? :league
|
52
|
+
|
53
|
+
|
50
54
|
if kwargs.has_key?( :score ) ## check all-in-one score struct for convenience!!!
|
51
55
|
score = kwargs[:score]
|
52
56
|
if score.nil? ## reset all score attribs to nil!!
|