sportdb-formats 1.1.0 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +6 -34
  3. data/Rakefile +3 -6
  4. data/lib/sportdb/formats.rb +54 -70
  5. data/lib/sportdb/formats/country/country_index.rb +2 -2
  6. data/lib/sportdb/formats/event/event_index.rb +141 -0
  7. data/lib/sportdb/formats/event/event_reader.rb +183 -0
  8. data/lib/sportdb/formats/league/league_index.rb +22 -18
  9. data/lib/sportdb/formats/league/league_outline_reader.rb +24 -7
  10. data/lib/sportdb/formats/league/league_reader.rb +7 -1
  11. data/lib/sportdb/formats/match/match_parser.rb +47 -18
  12. data/lib/sportdb/formats/package.rb +59 -11
  13. data/lib/sportdb/formats/team/club_index.rb +13 -11
  14. data/lib/sportdb/formats/team/club_index_history.rb +134 -0
  15. data/lib/sportdb/formats/team/club_reader_history.rb +203 -0
  16. data/lib/sportdb/formats/team/club_reader_props.rb +20 -5
  17. data/lib/sportdb/formats/version.rb +1 -1
  18. data/test/helper.rb +50 -81
  19. data/test/test_club_index_history.rb +107 -0
  20. data/test/test_club_reader_history.rb +212 -0
  21. data/test/test_datafile_package.rb +1 -1
  22. metadata +11 -81
  23. data/lib/sportdb/formats/config.rb +0 -40
  24. data/lib/sportdb/formats/match/match_parser_csv.rb +0 -321
  25. data/lib/sportdb/formats/name_helper.rb +0 -84
  26. data/lib/sportdb/formats/score/score_formats.rb +0 -220
  27. data/lib/sportdb/formats/score/score_parser.rb +0 -202
  28. data/lib/sportdb/formats/season_utils.rb +0 -27
  29. data/lib/sportdb/formats/structs/country.rb +0 -31
  30. data/lib/sportdb/formats/structs/group.rb +0 -18
  31. data/lib/sportdb/formats/structs/league.rb +0 -37
  32. data/lib/sportdb/formats/structs/match.rb +0 -151
  33. data/lib/sportdb/formats/structs/matchlist.rb +0 -220
  34. data/lib/sportdb/formats/structs/round.rb +0 -25
  35. data/lib/sportdb/formats/structs/season.rb +0 -123
  36. data/lib/sportdb/formats/structs/standings.rb +0 -268
  37. data/lib/sportdb/formats/structs/team.rb +0 -150
  38. data/lib/sportdb/formats/structs/team_usage.rb +0 -88
  39. data/test/test_clubs.rb +0 -40
  40. data/test/test_conf.rb +0 -65
  41. data/test/test_csv_match_parser.rb +0 -114
  42. data/test/test_csv_match_parser_utils.rb +0 -20
  43. data/test/test_csv_reader.rb +0 -31
  44. data/test/test_match.rb +0 -30
  45. data/test/test_match_auto.rb +0 -72
  46. data/test/test_match_auto_champs.rb +0 -45
  47. data/test/test_match_auto_euro.rb +0 -37
  48. data/test/test_match_auto_relegation.rb +0 -41
  49. data/test/test_match_auto_worldcup.rb +0 -61
  50. data/test/test_match_champs.rb +0 -27
  51. data/test/test_match_eng.rb +0 -26
  52. data/test/test_match_euro.rb +0 -27
  53. data/test/test_match_worldcup.rb +0 -27
  54. data/test/test_name_helper.rb +0 -67
  55. data/test/test_scores.rb +0 -122
  56. data/test/test_season.rb +0 -62
@@ -16,7 +16,7 @@ class TestDatafilePackage < MiniTest::Test
16
16
  ].each do |eng|
17
17
  assert eng.find( '2015-16/.conf.txt' ).read.start_with?( '= English Premier League 2015/16' )
18
18
  assert eng.find( '2017-18/.conf.txt' ).read.start_with?( '= English Premier League 2017/18' )
19
- assert eng.find( '2015-16/1-premierleague-i.txt' ).read.start_with?( '= English Premier League 2015/16' )
19
+ assert eng.find( '2015-16/1-premierleague.txt' ).read.start_with?( '= English Premier League 2015/16' )
20
20
  end
21
21
 
22
22
  [Datafile::DirPackage.new( '../../../openfootball/austria' ),
metadata CHANGED
@@ -1,71 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-15 00:00:00.000000000 Z
11
+ date: 2020-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: alphabets
14
+ name: sportdb-structs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: 0.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: date-formats
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.0.1
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 1.0.1
41
- - !ruby/object:Gem::Dependency
42
- name: csvreader
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 1.2.4
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 1.2.4
55
- - !ruby/object:Gem::Dependency
56
- name: sportdb-langs
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 0.1.0
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: 0.1.0
26
+ version: 0.1.1
69
27
  - !ruby/object:Gem::Dependency
70
28
  name: rubyzip
71
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,11 +80,12 @@ files:
122
80
  - README.md
123
81
  - Rakefile
124
82
  - lib/sportdb/formats.rb
125
- - lib/sportdb/formats/config.rb
126
83
  - lib/sportdb/formats/country/country_index.rb
127
84
  - lib/sportdb/formats/country/country_reader.rb
128
85
  - lib/sportdb/formats/datafile.rb
129
86
  - lib/sportdb/formats/datafile_package.rb
87
+ - lib/sportdb/formats/event/event_index.rb
88
+ - lib/sportdb/formats/event/event_reader.rb
130
89
  - lib/sportdb/formats/goals.rb
131
90
  - lib/sportdb/formats/league/league_index.rb
132
91
  - lib/sportdb/formats/league/league_outline_reader.rb
@@ -136,26 +95,13 @@ files:
136
95
  - lib/sportdb/formats/match/mapper_teams.rb
137
96
  - lib/sportdb/formats/match/match_parser.rb
138
97
  - lib/sportdb/formats/match/match_parser_auto_conf.rb
139
- - lib/sportdb/formats/match/match_parser_csv.rb
140
- - lib/sportdb/formats/name_helper.rb
141
98
  - lib/sportdb/formats/outline_reader.rb
142
99
  - lib/sportdb/formats/package.rb
143
100
  - lib/sportdb/formats/parser_helper.rb
144
- - lib/sportdb/formats/score/score_formats.rb
145
- - lib/sportdb/formats/score/score_parser.rb
146
- - lib/sportdb/formats/season_utils.rb
147
- - lib/sportdb/formats/structs/country.rb
148
- - lib/sportdb/formats/structs/group.rb
149
- - lib/sportdb/formats/structs/league.rb
150
- - lib/sportdb/formats/structs/match.rb
151
- - lib/sportdb/formats/structs/matchlist.rb
152
- - lib/sportdb/formats/structs/round.rb
153
- - lib/sportdb/formats/structs/season.rb
154
- - lib/sportdb/formats/structs/standings.rb
155
- - lib/sportdb/formats/structs/team.rb
156
- - lib/sportdb/formats/structs/team_usage.rb
157
101
  - lib/sportdb/formats/team/club_index.rb
102
+ - lib/sportdb/formats/team/club_index_history.rb
158
103
  - lib/sportdb/formats/team/club_reader.rb
104
+ - lib/sportdb/formats/team/club_reader_history.rb
159
105
  - lib/sportdb/formats/team/club_reader_props.rb
160
106
  - lib/sportdb/formats/team/national_team_index.rb
161
107
  - lib/sportdb/formats/team/team_index.rb
@@ -163,38 +109,22 @@ files:
163
109
  - lib/sportdb/formats/version.rb
164
110
  - test/helper.rb
165
111
  - test/test_club_index.rb
112
+ - test/test_club_index_history.rb
166
113
  - test/test_club_reader.rb
114
+ - test/test_club_reader_history.rb
167
115
  - test/test_club_reader_props.rb
168
- - test/test_clubs.rb
169
- - test/test_conf.rb
170
116
  - test/test_country_index.rb
171
117
  - test/test_country_reader.rb
172
- - test/test_csv_match_parser.rb
173
- - test/test_csv_match_parser_utils.rb
174
- - test/test_csv_reader.rb
175
118
  - test/test_datafile.rb
176
119
  - test/test_datafile_package.rb
177
120
  - test/test_goals.rb
178
121
  - test/test_league_index.rb
179
122
  - test/test_league_outline_reader.rb
180
123
  - test/test_league_reader.rb
181
- - test/test_match.rb
182
- - test/test_match_auto.rb
183
- - test/test_match_auto_champs.rb
184
- - test/test_match_auto_euro.rb
185
- - test/test_match_auto_relegation.rb
186
- - test/test_match_auto_worldcup.rb
187
- - test/test_match_champs.rb
188
- - test/test_match_eng.rb
189
- - test/test_match_euro.rb
190
- - test/test_match_worldcup.rb
191
- - test/test_name_helper.rb
192
124
  - test/test_outline_reader.rb
193
125
  - test/test_package.rb
194
126
  - test/test_package_match.rb
195
127
  - test/test_regex.rb
196
- - test/test_scores.rb
197
- - test/test_season.rb
198
128
  - test/test_wiki_reader.rb
199
129
  homepage: https://github.com/sportdb/sport.db
200
130
  licenses:
@@ -1,40 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
- module Import
5
-
6
- class Configuration
7
- ##
8
- ## todo: allow configure of countries_dir like clubs_dir
9
- ## "fallback" and use a default built-in world/countries.txt
10
-
11
- attr_accessor :catalog
12
-
13
- attr_reader :lang
14
- def lang=(value)
15
- ## check/todo: always use to_sym - why? needed?
16
- DateFormats.lang = value
17
- ScoreFormats.lang = value
18
- SportDb.lang.lang = value
19
-
20
- ## todo/fix: change SportDb.lang to SportDb.parser.lang or lang_parser or utils or someting !!!!
21
- ## use Sport.lang only as a read-only shortcut a la catalog for config.lang!!!!
22
- end
23
-
24
- end # class Configuration
25
-
26
-
27
- ## lets you use
28
- ## SportDb::Import.configure do |config|
29
- ## config.lang = 'it'
30
- ## end
31
-
32
- def self.configure() yield( config ); end
33
-
34
- def self.config() @config ||= Configuration.new; end
35
-
36
- ## e.g. use config.catalog -- keep Import.catalog as a shortcut (for "read-only" access)
37
- def self.catalog() config.catalog; end
38
-
39
- end # module Import
40
- end # module SportDb
@@ -1,321 +0,0 @@
1
- # encoding: utf-8
2
-
3
-
4
- module SportDb
5
- class CsvMatchParser
6
-
7
- #############
8
- # helpers
9
- def self.find_seasons( path, col: 'Season', sep: nil, headers: nil )
10
-
11
- ## check if headers incl. season if yes,has priority over col mapping
12
- ## e.g. no need to specify twice (if using headers)
13
- col = headers[:season] if headers && headers[:season]
14
-
15
- seasons = Hash.new( 0 ) ## default value is 0
16
-
17
- ## todo/fix: yes, use CsvHash.foreach - why? why not?
18
- ## use read_csv with block to switch to foreach!!!!
19
- rows = read_csv( path, sep: sep )
20
-
21
- rows.each_with_index do |row,i|
22
- puts "[#{i}] " + row.inspect if i < 2
23
-
24
- season = row[ col ] ## column name defaults to 'Season'
25
- seasons[ season ] += 1
26
- end
27
-
28
- pp seasons
29
-
30
- ## note: only return season keys/names (not hash with usage counter)
31
- seasons.keys
32
- end
33
-
34
-
35
- ##########
36
- # main machinery
37
-
38
- ## todo/fix: use a generic "global" parse_csv method - why? why not?
39
- ## def self.parse_csv( text, sep: ',' ) ## helper -lets you change the csv library in one place if needed/desired
40
- ## ## note: do NOT symbolize keys - keep them as is!!!!!!
41
- ## ## todo/fix: move "upstream" and remove symbolize keys too!!! - why? why not?
42
- ## CsvHash.parse( text, sep: sep )
43
- ## end
44
-
45
- def self.read( path, headers: nil, filters: nil, converters: nil, sep: nil )
46
- txt = File.open( path, 'r:utf-8' ) {|f| f.read } ## note: make sure to use (assume) utf-8
47
- parse( txt, headers: headers,
48
- filters: filters,
49
- converters: converters,
50
- sep: sep )
51
- end
52
-
53
- def self.parse( txt, headers: nil, filters: nil, converters: nil, sep: nil )
54
- new( txt ).parse( headers: headers,
55
- filters: filters,
56
- converters: converters,
57
- sep: sep )
58
- end
59
-
60
-
61
- def initialize( txt )
62
- @txt = txt
63
- end
64
-
65
- def parse( headers: nil, filters: nil, converters: nil, sep: nil )
66
-
67
- headers_mapping = {}
68
-
69
- rows = parse_csv( @txt, sep: sep )
70
-
71
- return [] if rows.empty? ## no rows / empty?
72
-
73
-
74
- ## fix/todo: use logger!!!!
75
- ## pp csv
76
-
77
- if headers ## use user supplied headers if present
78
- headers_mapping = headers_mapping.merge( headers )
79
- else
80
-
81
- ## note: returns an array of strings (header names) - assume all rows have the same columns/fields!!!
82
- headers = rows[0].keys
83
- pp headers
84
-
85
- # note: greece 2001-02 etc. use HT - check CVS reader row['HomeTeam'] may not be nil but an empty string?
86
- # e.g. row['HomeTeam'] || row['HT'] will NOT work for now
87
-
88
- if find_header( headers, ['Team 1']) && find_header( headers, ['Team 2'])
89
- ## assume our own football.csv format, see github.com/footballcsv
90
- headers_mapping[:team1] = find_header( headers, ['Team 1'] )
91
- headers_mapping[:team2] = find_header( headers, ['Team 2'] )
92
- headers_mapping[:date] = find_header( headers, ['Date'] )
93
-
94
- ## check for all-in-one full time (ft) and half time (ht9 scores?
95
- headers_mapping[:score] = find_header( headers, ['FT'] )
96
- headers_mapping[:scorei] = find_header( headers, ['HT'] )
97
-
98
- headers_mapping[:round] = find_header( headers, ['Round'] )
99
-
100
- ## optional headers - note: find_header returns nil if header NOT found
101
- header_stage = find_header( headers, ['Stage'] )
102
- headers_mapping[:stage] = header_stage if header_stage
103
- else
104
- ## else try footballdata.uk and others
105
- headers_mapping[:team1] = find_header( headers, ['HomeTeam', 'HT', 'Home'] )
106
- headers_mapping[:team2] = find_header( headers, ['AwayTeam', 'AT', 'Away'] )
107
- headers_mapping[:date] = find_header( headers, ['Date'] )
108
-
109
- ## note: FT = Full Time, HG = Home Goal, AG = Away Goal
110
- headers_mapping[:score1] = find_header( headers, ['FTHG', 'HG'] )
111
- headers_mapping[:score2] = find_header( headers, ['FTAG', 'AG'] )
112
-
113
- ## check for half time scores ?
114
- ## note: HT = Half Time
115
- headers_mapping[:score1i] = find_header( headers, ['HTHG'] )
116
- headers_mapping[:score2i] = find_header( headers, ['HTAG'] )
117
- end
118
- end
119
-
120
- pp headers_mapping
121
-
122
- ### todo/fix: check headers - how?
123
- ## if present HomeTeam or HT required etc.
124
- ## issue error/warn is not present
125
- ##
126
- ## puts "*** !!! wrong (unknown) headers format; cannot continue; fix it; sorry"
127
- ## exit 1
128
- ##
129
-
130
- matches = []
131
-
132
- rows.each_with_index do |row,i|
133
-
134
- ## fix/todo: use logger!!!!
135
- ## puts "[#{i}] " + row.inspect if i < 2
136
-
137
-
138
- ## todo/fix: move to its own (helper) method - filter or such!!!!
139
- if filters ## filter MUST match if present e.g. row['Season'] == '2017/2018'
140
- skip = false
141
- filters.each do |header, value|
142
- if row[ header ] != value ## e.g. row['Season']
143
- skip = true
144
- break
145
- end
146
- end
147
- next if skip ## if header values NOT matching
148
- end
149
-
150
-
151
- ## note:
152
- ## add converters after filters for now (why not before filters?)
153
- if converters ## any converters defined?
154
- ## convert single proc shortcut to array with single converter
155
- converters = [converters] if converters.is_a?( Proc )
156
-
157
- ## assumes array of procs
158
- converters.each do |converter|
159
- row = converter.call( row )
160
- end
161
- end
162
-
163
-
164
-
165
- team1 = row[ headers_mapping[ :team1 ]]
166
- team2 = row[ headers_mapping[ :team2 ]]
167
-
168
-
169
- ## check if data present - if not skip (might be empty row)
170
- ## note: (old classic) csv reader returns nil for empty fields
171
- ## new modern csv reader ALWAYS returns strings (and empty strings for data not available (n/a))
172
- if (team1.nil? || team1.empty?) &&
173
- (team2.nil? || team2.empty?)
174
- puts "*** WARN: skipping empty? row[#{i}] - no teams found:"
175
- pp row
176
- next
177
- end
178
-
179
- ## remove possible match played counters e.g. (4) (11) etc.
180
- team1 = team1.sub( /\(\d+\)/, '' ).strip
181
- team2 = team2.sub( /\(\d+\)/, '' ).strip
182
-
183
-
184
-
185
- col = row[ headers_mapping[ :date ]]
186
- col = col.strip # make sure not leading or trailing spaces left over
187
-
188
- if col.empty? ||
189
- col =~ /^-{1,}$/ || # e.g. - or ---
190
- col =~ /^\?{1,}$/ # e.g. ? or ???
191
- ## note: allow missing / unknown date for match
192
- date = nil
193
- else
194
- ## remove possible weekday or weeknumber e.g. (Fri) (4) etc.
195
- col = col.sub( /\(W?\d{1,2}\)/, '' ) ## e.g. (W11), (4), (21) etc.
196
- col = col.sub( /\(\w+\)/, '' ) ## e.g. (Fri), (Fr) etc.
197
- col = col.strip # make sure not leading or trailing spaces left over
198
-
199
- if col =~ /^\d{2}\/\d{2}\/\d{4}$/
200
- date_fmt = '%d/%m/%Y' # e.g. 17/08/2002
201
- elsif col =~ /^\d{2}\/\d{2}\/\d{2}$/
202
- date_fmt = '%d/%m/%y' # e.g. 17/08/02
203
- elsif col =~ /^\d{4}-\d{2}-\d{2}$/ ## "standard" / default date format
204
- date_fmt = '%Y-%m-%d' # e.g. 1995-08-04
205
- elsif col =~ /^\d{1,2} \w{3} \d{4}$/
206
- date_fmt = '%d %b %Y' # e.g. 8 Jul 2017
207
- elsif col =~ /^\w{3} \w{3} \d{1,2} \d{4}$/
208
- date_fmt = '%a %b %d %Y' # e.g. Sat Aug 7 1993
209
- else
210
- puts "*** !!! wrong (unknown) date format >>#{col}<<; cannot continue; fix it; sorry"
211
- ## todo/fix: add to errors/warns list - why? why not?
212
- exit 1
213
- end
214
-
215
- ## todo/check: use date object (keep string?) - why? why not?
216
- ## todo/fix: yes!! use date object!!!! do NOT use string
217
- date = Date.strptime( col, date_fmt ).strftime( '%Y-%m-%d' )
218
- end
219
-
220
-
221
- round = nil
222
- ## check for (optional) round / matchday
223
- if headers_mapping[ :round ]
224
- col = row[ headers_mapping[ :round ]]
225
- ## todo: issue warning if not ? or - (and just empty string) why? why not
226
- round = col.to_i if col =~ /^\d{1,2}$/ # check format - e.g. ignore ? or - or such non-numbers for now
227
- end
228
-
229
-
230
- score1 = nil
231
- score2 = nil
232
- score1i = nil
233
- score2i = nil
234
-
235
- ## check for full time scores ?
236
- if headers_mapping[ :score1 ] && headers_mapping[ :score2 ]
237
- ft = [ row[ headers_mapping[ :score1 ]],
238
- row[ headers_mapping[ :score2 ]] ]
239
-
240
- ## todo/fix: issue warning if not ? or - (and just empty string) why? why not
241
- score1 = ft[0].to_i if ft[0] =~ /^\d{1,2}$/
242
- score2 = ft[1].to_i if ft[1] =~ /^\d{1,2}$/
243
- end
244
-
245
- ## check for half time scores ?
246
- if headers_mapping[ :score1i ] && headers_mapping[ :score2i ]
247
- ht = [ row[ headers_mapping[ :score1i ]],
248
- row[ headers_mapping[ :score2i ]] ]
249
-
250
- ## todo/fix: issue warning if not ? or - (and just empty string) why? why not
251
- score1i = ht[0].to_i if ht[0] =~ /^\d{1,2}$/
252
- score2i = ht[1].to_i if ht[1] =~ /^\d{1,2}$/
253
- end
254
-
255
- ## check for all-in-one full time scores?
256
- if headers_mapping[ :score ]
257
- ft = row[ headers_mapping[ :score ] ]
258
- if ft =~ /^\d{1,2}[\-:]\d{1,2}$/ ## sanity check scores format
259
- scores = ft.split( /[\-:]/ )
260
- score1 = scores[0].to_i
261
- score2 = scores[1].to_i
262
- end
263
- ## todo/fix: issue warning if non-empty!!! and not matching format!!!!
264
- end
265
-
266
- if headers_mapping[ :scorei ]
267
- ht = row[ headers_mapping[ :scorei ] ]
268
- if ht =~ /^\d{1,2}[\-:]\d{1,2}$/ ## sanity check scores format
269
- scores = ht.split( /[\-:]/) ## allow 1-1 and 1:1
270
- score1i = scores[0].to_i
271
- score2i = scores[1].to_i
272
- end
273
- ## todo/fix: issue warning if non-empty!!! and not matching format!!!!
274
- end
275
-
276
-
277
- ## try some optional headings / columns
278
- stage = nil
279
- if headers_mapping[ :stage ]
280
- col = row[ headers_mapping[ :stage ]]
281
- ## todo/fix: check can col be nil e.g. col.nil? possible?
282
- stage = if col.nil? || col.empty? || col == '-' || col == 'n/a'
283
- ## note: allow missing stage for match / defaults to "regular"
284
- nil
285
- elsif col == '?'
286
- ## note: default explicit unknown to unknown for now AND not regular - why? why not?
287
- '?' ## todo/check: use unkown and NOT ? - why? why not?
288
- else
289
- col
290
- end
291
- end
292
-
293
-
294
- match = Import::Match.new( date: date,
295
- team1: team1, team2: team2,
296
- score1: score1, score2: score2,
297
- score1i: score1i, score2i: score2i,
298
- round: round,
299
- stage: stage )
300
- matches << match
301
- end
302
-
303
- ## pp matches
304
- matches
305
- end
306
-
307
-
308
- private
309
-
310
- def find_header( headers, candidates )
311
- ## todo/fix: use find_first from enumare of similar ?! - why? more idiomatic code?
312
-
313
- candidates.each do |candidate|
314
- return candidate if headers.include?( candidate ) ## bingo!!!
315
- end
316
- nil ## no matching header found!!!
317
- end
318
-
319
- end # class CsvMatchParser
320
- end # module SportDb
321
-