sportdb-formats 1.0.5 → 1.1.3
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 +4 -4
- data/Manifest.txt +8 -11
- data/Rakefile +1 -1
- data/lib/sportdb/formats.rb +19 -0
- data/lib/sportdb/formats/country/country_index.rb +2 -2
- data/lib/sportdb/formats/event/event_index.rb +141 -0
- data/lib/sportdb/formats/event/event_reader.rb +183 -0
- data/lib/sportdb/formats/league/league_index.rb +22 -18
- data/lib/sportdb/formats/league/league_outline_reader.rb +27 -7
- data/lib/sportdb/formats/league/league_reader.rb +7 -1
- data/lib/sportdb/formats/match/mapper.rb +63 -63
- data/lib/sportdb/formats/match/mapper_teams.rb +1 -1
- data/lib/sportdb/formats/match/match_parser.rb +141 -193
- data/lib/sportdb/formats/match/match_parser_csv.rb +169 -25
- data/lib/sportdb/formats/match/match_status_parser.rb +86 -0
- data/lib/sportdb/formats/name_helper.rb +4 -1
- data/lib/sportdb/formats/package.rb +57 -9
- data/lib/sportdb/formats/parser_helper.rb +11 -2
- data/lib/sportdb/formats/score/score_formats.rb +19 -0
- data/lib/sportdb/formats/score/score_parser.rb +10 -2
- data/lib/sportdb/formats/season_utils.rb +0 -11
- data/lib/sportdb/formats/structs/group.rb +5 -12
- data/lib/sportdb/formats/structs/match.rb +7 -1
- data/lib/sportdb/formats/structs/round.rb +6 -13
- data/lib/sportdb/formats/structs/season.rb +114 -45
- data/lib/sportdb/formats/structs/standings.rb +30 -9
- data/lib/sportdb/formats/structs/team.rb +8 -2
- data/lib/sportdb/formats/team/club_index.rb +13 -11
- data/lib/sportdb/formats/team/club_index_history.rb +138 -0
- data/lib/sportdb/formats/team/club_reader_history.rb +203 -0
- data/lib/sportdb/formats/team/club_reader_props.rb +2 -3
- data/lib/sportdb/formats/version.rb +2 -2
- data/test/helper.rb +48 -81
- data/test/test_club_index_history.rb +107 -0
- data/test/test_club_reader_history.rb +212 -0
- data/test/test_country_reader.rb +2 -2
- data/test/test_datafile_package.rb +1 -1
- data/test/test_match_status_parser.rb +49 -0
- data/test/test_regex.rb +25 -7
- data/test/test_scores.rb +2 -0
- data/test/test_season.rb +68 -19
- metadata +12 -15
- data/test/test_conf.rb +0 -65
- data/test/test_csv_match_parser.rb +0 -114
- data/test/test_csv_match_parser_utils.rb +0 -20
- data/test/test_match_auto.rb +0 -72
- data/test/test_match_auto_champs.rb +0 -45
- data/test/test_match_auto_euro.rb +0 -37
- data/test/test_match_auto_worldcup.rb +0 -61
- data/test/test_match_champs.rb +0 -27
- data/test/test_match_eng.rb +0 -26
- data/test/test_match_euro.rb +0 -27
- data/test/test_match_worldcup.rb +0 -27
@@ -18,10 +18,19 @@ module SportDb
|
|
18
18
|
|
19
19
|
|
20
20
|
def is_round?( line )
|
21
|
-
## note: =~
|
22
|
-
|
21
|
+
## note: =~ returns nil if not match found, and 0,1, etc for match
|
22
|
+
|
23
|
+
## note: allow "free standing" leg 1 and leg 2 too
|
24
|
+
## (e.g. Hinspiel, Rückspiel etc. used for now in Relegation, for example)
|
25
|
+
## note ONLY allowed if "free standing", that is, full line with nothing else
|
26
|
+
## use "custom" regex for special case for now
|
27
|
+
## avoids match HIN in PascHINg, for example (hin in german for leg 1)
|
28
|
+
line =~ SportDb.lang.regex_round ||
|
29
|
+
line =~ /^(#{SportDb.lang.leg1})$/i ||
|
30
|
+
line =~ /^(#{SportDb.lang.leg2})$/i
|
23
31
|
end
|
24
32
|
|
33
|
+
|
25
34
|
def is_knockout_round?( line )
|
26
35
|
|
27
36
|
## todo: check for adding ignore case for regex (e.g. 1st leg/1st Leg)
|
@@ -9,6 +9,24 @@ module ScoreFormats
|
|
9
9
|
ET_EN = '(?: aet | a\.e\.t\.? )' # note: make last . optional (e.g a.e.t) allowed too
|
10
10
|
|
11
11
|
|
12
|
+
## note: allow SPECIAL cases WITHOUT full time scores (just a.e.t or pen. + a.e.t.)
|
13
|
+
## 3-4 pen. 2-2 a.e.t.
|
14
|
+
## 2-2 a.e.t.
|
15
|
+
EN__P_ET__RE = /\b
|
16
|
+
(?:
|
17
|
+
(?<score1p>\d{1,2})
|
18
|
+
[ ]* - [ ]* # note: sep in optional block; CANNOT use a reference
|
19
|
+
(?<score2p>\d{1,2})
|
20
|
+
[ ]* #{P_EN} [ ]*
|
21
|
+
)? # note: make penalty (P) score optional for now
|
22
|
+
(?<score1et>\d{1,2})
|
23
|
+
[ ]* - [ ]*
|
24
|
+
(?<score2et>\d{1,2})
|
25
|
+
[ ]* #{ET_EN}
|
26
|
+
(?=[ \]]|$)/xi ## todo/check: remove loakahead assertion here - why require space?
|
27
|
+
## note: \b works only after non-alphanum e.g. )
|
28
|
+
|
29
|
+
|
12
30
|
## e.g. 3-4 pen. 2-2 a.e.t. (1-1, 1-1) or
|
13
31
|
## 3-4 pen. 2-2 a.e.t. (1-1, ) or
|
14
32
|
## 3-4 pen. 2-2 a.e.t. (1-1) or
|
@@ -203,6 +221,7 @@ module ScoreFormats
|
|
203
221
|
FORMATS_EN = [
|
204
222
|
[ EN__P_ET_FT_HT__RE, '[SCORE.EN__P?_ET_(FT_HT?)]' ], # e.g. 5-1 pen. 2-2 a.e.t. (1-1, 1-0)
|
205
223
|
[ EN__P_FT_HT__RE, '[SCORE.EN__P_(FT_HT?)]' ], # e.g. 5-1 pen. (1-1)
|
224
|
+
[ EN__P_ET__RE, '[SCORE.EN__P?_ET]' ], # e.g. 2-2 a.e.t. or 5-1 pen. 2-2 a.e.t.
|
206
225
|
[ EN__FT_HT__RE, '[SCORE.EN__FT_(HT)?]' ], # e.g. 1-1 (1-0)
|
207
226
|
]
|
208
227
|
|
@@ -90,6 +90,12 @@ class ScoreParser
|
|
90
90
|
|
91
91
|
|
92
92
|
def parse( line )
|
93
|
+
|
94
|
+
##########
|
95
|
+
## todo/fix/check: add unicode to regular dash conversion - why? why not?
|
96
|
+
## e.g. – becomes - (yes, the letters a different!!!)
|
97
|
+
#############
|
98
|
+
|
93
99
|
score = nil
|
94
100
|
@formats.each do |format|
|
95
101
|
re = format[0]
|
@@ -169,8 +175,10 @@ private
|
|
169
175
|
score2i = h[:score2i].to_i
|
170
176
|
end
|
171
177
|
|
172
|
-
score1
|
173
|
-
|
178
|
+
if h[:score1] && h[:score2] ## note: full time (FT) score can be optional too!!!
|
179
|
+
score1 = h[:score1].to_i
|
180
|
+
score2 = h[:score2].to_i
|
181
|
+
end
|
174
182
|
|
175
183
|
if h[:score1et] && h[:score2et]
|
176
184
|
score1et = h[:score1et].to_i
|
@@ -2,21 +2,10 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
module SeasonHelper ## use Helpers why? why not?
|
5
|
-
|
6
5
|
##############################################
|
7
6
|
### deprecated!!! use new Season class!!!
|
8
7
|
## this code will get removed!!!!
|
9
8
|
###################################################
|
10
|
-
|
11
|
-
def prev( str ) SportDb::Import::Season.new( str ).prev; end
|
12
|
-
def key( str ) SportDb::Import::Season.new( str ).key; end
|
13
|
-
def directory( str, format: nil ) SportDb::Import::Season.new( str ).directory( format: format ); end
|
14
|
-
|
15
|
-
## note: new start_year now returns an integer number (no longer a string)!!!
|
16
|
-
def start_year( str ) SportDb::Import::Season.new( str ).start_year; end
|
17
|
-
## note: new end_year now returns an integer number (no longer a string)!!!
|
18
|
-
## if now end_year (year? == true) than returns nil (no longer the start_year "as fallback")!!!
|
19
|
-
def end_year( str ) SportDb::Import::Season.new( str ).end_year; end
|
20
9
|
end # module SeasonHelper
|
21
10
|
|
22
11
|
|
@@ -2,20 +2,13 @@ module SportDb
|
|
2
2
|
module Import
|
3
3
|
|
4
4
|
class Group
|
5
|
-
attr_reader
|
5
|
+
attr_reader :key, :name, :teams
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
## make start and end date optional
|
10
|
-
## change pos to num - why? why not?
|
11
|
-
## make pos/num optional too
|
12
|
-
##
|
13
|
-
## sort round by scheduled/planed start date
|
14
|
-
def initialize( title:,
|
15
|
-
pos:,
|
7
|
+
def initialize( key: nil,
|
8
|
+
name:,
|
16
9
|
teams: )
|
17
|
-
@
|
18
|
-
@
|
10
|
+
@key = key ## e.g. A,B,C or 1,2,3, - note: always a string or nil
|
11
|
+
@name = name
|
19
12
|
@teams = teams
|
20
13
|
end
|
21
14
|
end # class Group
|
@@ -18,9 +18,11 @@ class Match
|
|
18
18
|
:leg, ## e.g. '1','2','3','replay', etc. - use leg for marking **replay** too - keep/make leg numeric?! - why? why not?
|
19
19
|
:stage,
|
20
20
|
:group,
|
21
|
+
:status, ## e.g. replay, cancelled, awarded, abadoned, postponed, etc.
|
21
22
|
:conf1, :conf2, ## special case for mls e.g. conference1, conference2 (e.g. west, east, central)
|
22
23
|
:country1, :country2, ## special case for champions league etc. - uses FIFA country code
|
23
|
-
:comments
|
24
|
+
:comments,
|
25
|
+
:league ## (optinal) added as text for now (use struct?)
|
24
26
|
|
25
27
|
def initialize( **kwargs )
|
26
28
|
update( kwargs ) unless kwargs.empty?
|
@@ -45,8 +47,12 @@ class Match
|
|
45
47
|
@stage = kwargs[:stage] if kwargs.has_key? :stage
|
46
48
|
@leg = kwargs[:leg] if kwargs.has_key? :leg
|
47
49
|
@group = kwargs[:group] if kwargs.has_key? :group
|
50
|
+
@status = kwargs[:status] if kwargs.has_key? :status
|
48
51
|
@comments = kwargs[:comments] if kwargs.has_key? :comments
|
49
52
|
|
53
|
+
@league = kwargs[:league] if kwargs.has_key? :league
|
54
|
+
|
55
|
+
|
50
56
|
if kwargs.has_key?( :score ) ## check all-in-one score struct for convenience!!!
|
51
57
|
score = kwargs[:score]
|
52
58
|
if score.nil? ## reset all score attribs to nil!!
|
@@ -2,24 +2,17 @@ module SportDb
|
|
2
2
|
module Import
|
3
3
|
|
4
4
|
class Round
|
5
|
-
attr_reader :
|
6
|
-
attr_accessor :
|
5
|
+
attr_reader :name, :start_date, :end_date, :knockout
|
6
|
+
attr_accessor :num # note: make read & writable - why? why not?
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
## make start and end date optional
|
11
|
-
## change pos to num - why? why not?
|
12
|
-
## make pos/num optional too
|
13
|
-
##
|
14
|
-
## sort round by scheduled/planed start date
|
15
|
-
def initialize( title:,
|
16
|
-
pos: nil,
|
8
|
+
def initialize( name:,
|
9
|
+
num: nil,
|
17
10
|
start_date: nil,
|
18
11
|
end_date: nil,
|
19
12
|
knockout: false,
|
20
13
|
auto: true )
|
21
|
-
@
|
22
|
-
@
|
14
|
+
@name = name
|
15
|
+
@num = num
|
23
16
|
@start_date = start_date
|
24
17
|
@end_date = end_date
|
25
18
|
@knockout = knockout
|
@@ -1,26 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
### note: make Season like Date a "top-level" / "generic" class
|
5
|
+
|
6
6
|
|
7
7
|
|
8
8
|
class Season
|
9
9
|
##
|
10
10
|
## todo: add (optional) start_date and end_date - why? why not?
|
11
|
-
## add next
|
12
|
-
|
13
|
-
|
14
|
-
attr_reader :start_year,
|
15
|
-
:end_year
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def initialize( str ) ## assume only string / line gets passed in for now
|
21
|
-
@start_year, @end_year = parse( str )
|
22
|
-
end
|
12
|
+
## todo/todo/todo/check/check/check !!!
|
13
|
+
## todo: add a kernel Seaons e.g. Season('2011/12')
|
14
|
+
## forward to Season.convert( *args ) - why? why not?
|
23
15
|
|
16
|
+
## todo: add unicode - too - why? why not? see wikipedia pages, for example
|
24
17
|
|
25
18
|
YYYY_YYYY_RE = %r{^ ## e.g. 2011-2012 or 2011/2012
|
26
19
|
(\d{4})
|
@@ -45,79 +38,155 @@ class Season
|
|
45
38
|
$
|
46
39
|
}x
|
47
40
|
|
48
|
-
|
41
|
+
|
42
|
+
def self.parse( str )
|
43
|
+
new( *_parse( str ))
|
44
|
+
end
|
45
|
+
|
46
|
+
def self._parse( str ) ## "internal" parse helper
|
49
47
|
if str =~ YYYY_YYYY_RE ## e.g. 2011/2012
|
50
48
|
[$1.to_i, $2.to_i]
|
51
49
|
elsif str =~ YYYY_YY_RE ## e.g. 2011/12
|
52
50
|
fst = $1.to_i
|
53
51
|
snd = $2.to_i
|
54
52
|
snd_exp = '%02d' % [(fst+1) % 100] ## double check: e.g 00 == 00, 01==01 etc.
|
55
|
-
raise ArgumentError
|
53
|
+
raise ArgumentError, "[Season.parse] invalid year in season >>#{str}<<; expected #{snd_exp} but got #{$2}" if snd_exp != $2
|
56
54
|
[fst, fst+1]
|
57
55
|
elsif str =~ YYYY_Y_RE ## e.g. 2011/2
|
58
56
|
fst = $1.to_i
|
59
57
|
snd = $2.to_i
|
60
58
|
snd_exp = '%d' % [(fst+1) % 10] ## double check: e.g 0 == 0, 1==1 etc.
|
61
|
-
raise ArgumentError
|
59
|
+
raise ArgumentError, "[Season.parse] invalid year in season >>#{str}<<; expected #{snd_exp} but got #{$2}" if snd_exp != $2
|
62
60
|
[fst, fst+1]
|
63
61
|
elsif str =~ YYYY_RE ## e.g. 2011
|
64
62
|
[$1.to_i]
|
65
63
|
else
|
66
|
-
raise ArgumentError
|
64
|
+
raise ArgumentError, "[Season.parse] unkown season format >>#{str}<<; sorry cannot parse"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
attr_reader :start_year,
|
71
|
+
:end_year
|
72
|
+
|
73
|
+
def initialize( *args ) ## assume only string / line gets passed in for now
|
74
|
+
if args.size == 1 && args[0].is_a?( String )
|
75
|
+
@start_year, @end_year = self.class._parse( args[0] )
|
76
|
+
elsif args.size == 1 && args[0].is_a?( Integer )
|
77
|
+
@start_year = args[0]
|
78
|
+
@end_year = nil
|
79
|
+
elsif args.size == 2 && args[0].is_a?( Integer ) &&
|
80
|
+
args[1].is_a?( Integer )
|
81
|
+
@start_year = args[0]
|
82
|
+
@end_year = args[1]
|
83
|
+
end_year_exp = @start_year+1
|
84
|
+
raise ArgumentError, "[Season] invalid year in season >>#{to_s}<<; expected #{end_year_exp} but got #{@end_year}" if end_year_exp != @end_year
|
85
|
+
else
|
86
|
+
pp args
|
87
|
+
raise ArgumentError, "[Season] expected season string or season start year (integer) with opt. end year"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
###
|
93
|
+
## convenience helper
|
94
|
+
def start_date ## generate "generic / syntetic start date" - keep helper - why? why not?
|
95
|
+
if year?
|
96
|
+
Date.new( start_year, 1, 1 )
|
97
|
+
else
|
98
|
+
Date.new( start_year 1, 7 )
|
67
99
|
end
|
68
100
|
end
|
69
101
|
|
70
102
|
|
103
|
+
## single-year season e.g. 2011 if no end_year present - todo - find a better name?
|
104
|
+
def year?() @end_year.nil?; end
|
71
105
|
|
72
106
|
def prev
|
73
107
|
if year?
|
74
|
-
Season.new(
|
108
|
+
Season.new( @start_year-1 )
|
75
109
|
else
|
76
|
-
Season.new(
|
110
|
+
Season.new( @start_year-1, @start_year )
|
77
111
|
end
|
78
112
|
end
|
79
113
|
|
80
|
-
def
|
114
|
+
def next
|
81
115
|
if year?
|
82
|
-
|
116
|
+
Season.new( @start_year+1 )
|
83
117
|
else
|
84
|
-
|
118
|
+
Season.new( @end_year, @end_year+1 )
|
85
119
|
end
|
86
120
|
end
|
87
|
-
alias_method :
|
88
|
-
|
121
|
+
alias_method :succ, :next ## add support for ranges
|
122
|
+
|
123
|
+
include Comparable
|
124
|
+
def <=>(other)
|
125
|
+
## todo/fix/fix: check if other is_a?( Season )!!!
|
126
|
+
## what to return if other type/class ??
|
89
127
|
|
90
|
-
|
91
|
-
alias_method :title, :key
|
128
|
+
res = @start_year <=> other.start_year
|
92
129
|
|
130
|
+
## check special edge case - year season and other e.g.
|
131
|
+
## 2010 <=> 2010/2011
|
132
|
+
if res == 0 && @end_year != other.end_year
|
133
|
+
res = @end_year ? 1 : -1 # the season with an end year is greater / wins for now
|
134
|
+
end
|
93
135
|
|
94
|
-
|
95
|
-
|
96
|
-
## long | archive | decade(?) => 1980s/1988-89, 2010s/2017-18, ...
|
97
|
-
## short | std(?) => 1988-89, 2017-18, ...
|
136
|
+
res
|
137
|
+
end
|
98
138
|
|
99
|
-
## convert season name to "standard" season name for directory
|
100
139
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
140
|
+
|
141
|
+
def to_formatted_s( format=:default, sep: '/' )
|
142
|
+
if year?
|
143
|
+
'%d' % @start_year
|
144
|
+
else
|
145
|
+
case format
|
146
|
+
when :default, :short, :s ## e.g. 1999/00 or 2019/20
|
147
|
+
"%d#{sep}%02d" % [@start_year, @end_year % 100]
|
148
|
+
when :long, :l ## e.g. 1999/2000 or 2019/2020
|
149
|
+
"%d#{sep}%d" % [@start_year, @end_year]
|
150
|
+
else
|
151
|
+
raise ArgumentError, "[Season.to_s] unsupported format >#{format}<"
|
112
152
|
end
|
113
153
|
end
|
114
|
-
end
|
115
|
-
alias_method :
|
116
|
-
|
154
|
+
end
|
155
|
+
alias_method :to_s, :to_formatted_s
|
156
|
+
|
157
|
+
def key() to_s( :short ); end
|
158
|
+
alias_method :to_key, :key
|
159
|
+
alias_method :name, :key
|
160
|
+
alias_method :title, :key
|
117
161
|
|
162
|
+
alias_method :inspect, :key ## note: add inspect debug support change debug output to string!!
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
def to_path( format=:default )
|
167
|
+
case format
|
168
|
+
when :default, :short, :s ## e.g. 1999-00 or 2019-20
|
169
|
+
to_s( :short, sep: '-' )
|
170
|
+
when :long, :l ## e.g. 1999-2000 or 2019-2000
|
171
|
+
to_s( :long, sep: '-' )
|
172
|
+
when :archive, :decade, :d ## e.g. 1990s/1999-00 or 2010s/2019-20
|
173
|
+
"%3d0s/%s" % [@start_year / 10, to_s( :short, sep: '-' )]
|
174
|
+
when :century, :c ## e.g. 1900s/1990-00 or 2000s/2019-20
|
175
|
+
"%2d00s/%s" % [@start_year / 100, to_s( :short, sep: '-' )]
|
176
|
+
else
|
177
|
+
raise ArgumentError, "[Season.to_path] unsupported format >#{format}<"
|
178
|
+
end
|
179
|
+
end # method to_path
|
180
|
+
alias_method :directory, :to_path ## keep "legacy" directory alias - why? why not?
|
181
|
+
alias_method :path, :to_path
|
118
182
|
|
119
183
|
end # class Season
|
120
184
|
|
121
185
|
|
186
|
+
|
187
|
+
|
188
|
+
module SportDb
|
189
|
+
module Import
|
190
|
+
Season = ::Season ## add a convenience alias
|
122
191
|
end # module Import
|
123
192
|
end # module SportDb
|
@@ -12,7 +12,7 @@ module SportDb
|
|
12
12
|
|
13
13
|
class Standings
|
14
14
|
|
15
|
-
class StandingsLine ## nested class StandinsLine
|
15
|
+
class StandingsLine ## nested class StandinsLine - todo/fix: change to Line - why? why not?
|
16
16
|
attr_accessor :rank, :team,
|
17
17
|
:played, :won, :lost, :drawn, ## -- total
|
18
18
|
:goals_for, :goals_against, :pts,
|
@@ -21,8 +21,13 @@ class Standings
|
|
21
21
|
:away_played, :away_won, :away_lost, :away_drawn, ## -- away
|
22
22
|
:away_goals_for, :away_goals_against, :away_pts
|
23
23
|
|
24
|
+
alias_method :team_name, :team ## note: team for now always a string
|
25
|
+
alias_method :pos, :rank ## rename back to use pos instead of rank - why? why not?
|
26
|
+
|
27
|
+
|
24
28
|
def initialize( team )
|
25
29
|
@rank = nil # use 0? why? why not?
|
30
|
+
## change rank back to pos - why? why not?
|
26
31
|
@team = team
|
27
32
|
@played = @home_played = @away_played = 0
|
28
33
|
@won = @home_won = @away_won = 0
|
@@ -49,7 +54,12 @@ class Standings
|
|
49
54
|
|
50
55
|
def update( match_or_matches )
|
51
56
|
## convenience - update all matches at once
|
52
|
-
|
57
|
+
## todo/check: check for ActiveRecord_Associations_CollectionProxy and than use to_a (to "force" array) - why? why not?
|
58
|
+
matches = if match_or_matches.is_a?(Array)
|
59
|
+
match_or_matches
|
60
|
+
else
|
61
|
+
[match_or_matches]
|
62
|
+
end
|
53
63
|
|
54
64
|
matches.each_with_index do |match,i| # note: index(i) starts w/ zero (0)
|
55
65
|
update_match( match )
|
@@ -171,19 +181,30 @@ class Standings
|
|
171
181
|
private
|
172
182
|
def update_match( m ) ## add a match
|
173
183
|
|
174
|
-
##
|
184
|
+
## note: always use team as string for now
|
185
|
+
## for now allow passing in of string OR struct - why? why not?
|
186
|
+
## todo/fix: change to m.team1_name and m.team2_name - why? why not?
|
187
|
+
team1 = m.team1.is_a?( String ) ? m.team1 : m.team1.name
|
188
|
+
team2 = m.team2.is_a?( String ) ? m.team2 : m.team2.name
|
189
|
+
|
190
|
+
score = m.score_str
|
191
|
+
|
192
|
+
## puts " #{team1} - #{team2} #{score}"
|
193
|
+
|
175
194
|
unless m.over?
|
176
|
-
puts " !!!! skipping match - not yet over (
|
195
|
+
puts " !!!! skipping match - not yet over (date in the future) => #{m.date}"
|
177
196
|
return
|
178
197
|
end
|
179
198
|
|
180
199
|
unless m.complete?
|
181
|
-
puts "!!! [calc_standings] skipping match #{
|
200
|
+
puts "!!! [calc_standings] skipping match #{team1} - #{team2} w/ past date #{m.date} - scores incomplete => #{score}"
|
182
201
|
return
|
183
202
|
end
|
184
203
|
|
185
|
-
|
186
|
-
|
204
|
+
|
205
|
+
|
206
|
+
line1 = @lines[ team1 ] || StandingsLine.new( team1 )
|
207
|
+
line2 = @lines[ team2 ] || StandingsLine.new( team2 )
|
187
208
|
|
188
209
|
line1.played += 1
|
189
210
|
line1.home_played += 1
|
@@ -236,8 +257,8 @@ private
|
|
236
257
|
puts "*** warn: [standings] skipping match with missing scores: #{m.inspect}"
|
237
258
|
end
|
238
259
|
|
239
|
-
@lines[
|
240
|
-
@lines[
|
260
|
+
@lines[ team1 ] = line1
|
261
|
+
@lines[ team2 ] = line2
|
241
262
|
end # method update_match
|
242
263
|
|
243
264
|
end # class Standings
|