sportdb-formats 1.0.5 → 1.0.6

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: c1645b8fed586be03207b65e25866473f3124c3d
4
- data.tar.gz: c50d164b1cf1fe79e5dc5c8ac9e946fc6ba96f31
3
+ metadata.gz: 35a7be066d82d59b2cf35c8dc5676c0d5118479b
4
+ data.tar.gz: eeceea13624ae5c795bc2b2709e7bef6727dd184
5
5
  SHA512:
6
- metadata.gz: bed9e662901b25660899f1b3df3f6a9f506f88422a50db23d119d7f55a4e94ac84e82474879926b5f6db079a13600ebe093ae3ea39d351e758b25e3904789edf
7
- data.tar.gz: c2aff73cf2ba9ea04fddde788076bd72b983681ba2e492a665f3e104f76712ce1708d32abc1eb64e0dece966f34d30bda3724acaf53598d487b51307f735cc4e
6
+ metadata.gz: 732d53cf84db4d87449c9fe86e4c0b1109a277b8442a7fd15cf61a5318555e6a53c61c08ab1b66187429fc770f89e4a72ef48b9bde616e2736a96bb8d1a47324
7
+ data.tar.gz: 60b46bf871ffd180bec2a3a96403ecceebc5689dde1d0c6181ecf1b22fdaf9b8aaf49bd8e15a8ba886cf9751e62fc89658376b27d983e8871003f498d6498c0e
@@ -7,21 +7,21 @@ module SportDb
7
7
  ## see https://github.com/textkit/textutils/blob/master/textutils/lib/textutils/title_mapper2.rb
8
8
 
9
9
 
10
- class MapperV2 ## todo/check: rename to NameMapper/TitleMapper ? why? why not??
10
+ class MapperV2 ## todo/check: rename to NameMapper ? why? why not??
11
11
 
12
12
  include Logging
13
13
 
14
- attr_reader :known_titles ## rename to mapping or mappings or just titles - why? why not?
14
+ attr_reader :known_names ## rename to mapping or mappings or just names - why? why not?
15
15
 
16
16
  ########
17
17
  ## key: e.g. augsburg
18
- ## title: e.g. FC Augsburg
19
- ## length (of title(!!) - not regex pattern): e.g. 11 -- do not count dots (e.g. U.S.A. => 3 or 6) why? why not?
20
- MappingStruct = Struct.new( :key, :title, :length, :pattern) ## todo/check: use (rename to) TitleStruct - why? why not??
18
+ ## name: e.g. FC Augsburg
19
+ ## length (of name(!!) - not regex pattern): e.g. 11 -- do not count dots (e.g. U.S.A. => 3 or 6) why? why not?
20
+ MappingStruct = Struct.new( :key, :name, :length, :pattern) ## todo/check: use (rename to) NameStruct - why? why not??
21
21
 
22
22
  ######
23
23
  ## convenience helper - (auto)build ActiveRecord-like team records/structs
24
- Record = Struct.new( :key, :title, :synonyms )
24
+ Record = Struct.new( :key, :name, :alt_names )
25
25
  def build_records( txt_or_lines )
26
26
  recs = []
27
27
 
@@ -44,12 +44,12 @@ class MapperV2 ## todo/check: rename to NameMapper/TitleMapper ? why? why n
44
44
  values = line.split( '|' )
45
45
  values = values.map { |value| value.strip }
46
46
 
47
- title = values[0]
47
+ name = values[0]
48
48
  ## note: quick hack - auto-generate key, that is, remove all non-ascii chars and downcase
49
- key = title.downcase.gsub( /[^a-z]/, '' )
50
- synonyms = values.size > 1 ? values[1..-1].join( '|' ) : nil
49
+ key = name.downcase.gsub( /[^a-z]/, '' )
50
+ alt_names = values.size > 1 ? values[1..-1].join( '|' ) : nil
51
51
 
52
- recs << Record.new( key, title, synonyms )
52
+ recs << Record.new( key, name, alt_names )
53
53
  end
54
54
  recs
55
55
  end
@@ -63,10 +63,10 @@ class MapperV2 ## todo/check: rename to NameMapper/TitleMapper ? why? why n
63
63
  (records_or_mapping.is_a?( Array ) && records_or_mapping[0].is_a?( String ))
64
64
 
65
65
  ## build mapping lookup table
66
- @known_titles = if records_or_mapping.is_a?( Hash ) ## assume "custom" mapping hash table (title/name=>record)
67
- build_title_table_for_mapping( records_or_mapping )
66
+ @known_names = if records_or_mapping.is_a?( Hash ) ## assume "custom" mapping hash table (name=>record)
67
+ build_name_table_for_mapping( records_or_mapping )
68
68
  else ## assume array of records
69
- build_title_table_for_records( records_or_mapping )
69
+ build_name_table_for_records( records_or_mapping )
70
70
  end
71
71
 
72
72
  ## build lookup hash by record (e.g. team/club/etc.) key
@@ -85,9 +85,9 @@ class MapperV2 ## todo/check: rename to NameMapper/TitleMapper ? why? why n
85
85
 
86
86
 
87
87
 
88
- def map_titles!( line ) ## rename to just map! - why?? why not???
88
+ def map_names!( line ) ## rename to just map! - why?? why not???
89
89
  begin
90
- found = map_title_for!( @tag, line, @known_titles )
90
+ found = map_name_for!( @tag, line, @known_names )
91
91
  end while found
92
92
  end
93
93
 
@@ -110,27 +110,27 @@ class MapperV2 ## todo/check: rename to NameMapper/TitleMapper ? why? why n
110
110
 
111
111
 
112
112
  private
113
- def build_title_table_for_mapping( mapping )
114
- known_titles = []
113
+ def build_name_table_for_mapping( mapping )
114
+ known_names = []
115
115
 
116
- mapping.each do |title, rec|
116
+ mapping.each do |name, rec|
117
117
  m = MappingStruct.new
118
118
  m.key = rec.key
119
- m.title = title
120
- m.length = title.length
121
- m.pattern = Regexp.escape( title ) ## note: just use "standard" regex escape (e.g. no extras for umlauts,accents,etc.)
119
+ m.name = name
120
+ m.length = name.length
121
+ m.pattern = Regexp.escape( name ) ## note: just use "standard" regex escape (e.g. no extras for umlauts,accents,etc.)
122
122
 
123
- known_titles << m
123
+ known_names << m
124
124
  end
125
125
 
126
126
  ## note: sort here by length (largest goes first - best match)
127
- known_titles = known_titles.sort { |l,r| r.length <=> l.length }
128
- known_titles
127
+ known_names = known_names.sort { |l,r| r.length <=> l.length }
128
+ known_names
129
129
  end
130
130
 
131
- def build_title_table_for_records( records )
131
+ def build_name_table_for_records( records )
132
132
 
133
- ## build known tracks table w/ synonyms e.g.
133
+ ## build known tracks table w/ alt names e.g.
134
134
  #
135
135
  # [[ 'wolfsbrug', 'VfL Wolfsburg'],
136
136
  # [ 'augsburg', 'FC Augsburg'],
@@ -138,65 +138,65 @@ private
138
138
  # [ 'augsburg', 'Augi3' ],
139
139
  # [ 'stuttgart', 'VfB Stuttgart']]
140
140
 
141
- known_titles = []
141
+ known_names = []
142
142
 
143
143
  records.each_with_index do |rec,index|
144
144
 
145
- title_candidates = []
146
- title_candidates << rec.title
145
+ name_candidates = []
146
+ name_candidates << rec.name
147
147
 
148
- title_candidates += rec.synonyms.split('|') if rec.synonyms && !rec.synonyms.empty?
148
+ name_candidates += rec.alt_names.split('|') if rec.alt_names && !rec.alt_names.empty?
149
149
 
150
150
 
151
- ## check if title includes subtitle e.g. Grand Prix Japan (Suzuka Circuit)
152
- # make subtitle optional by adding title w/o subtitle e.g. Grand Prix Japan
151
+ ## check if name includes subname e.g. Grand Prix Japan (Suzuka Circuit)
152
+ # make subname optional by adding name w/o subname e.g. Grand Prix Japan
153
153
 
154
- titles = []
155
- title_candidates.each do |t|
156
- titles << t
154
+ names = []
155
+ name_candidates.each do |t|
156
+ names << t
157
157
  if t =~ /\(.+\)/
158
- extra_title = t.gsub( /\(.+\)/, '' ) # remove/delete subtitles
158
+ extra_name = t.gsub( /\(.+\)/, '' ) # remove/delete subnames
159
159
  # note: strip leading n trailing withspaces too!
160
160
  # -- todo: add squish or something if () is inline e.g. leaves two spaces?
161
- extra_title.strip!
162
- titles << extra_title
161
+ extra_name.strip!
162
+ names << extra_name
163
163
  end
164
164
  end
165
165
 
166
- titles.each do |t|
166
+ names.each do |name|
167
167
  m = MappingStruct.new
168
168
  m.key = rec.key
169
- m.title = t
170
- m.length = t.length
169
+ m.name = name
170
+ m.length = name.length
171
171
  ## note: escape for regex plus allow subs for special chars/accents
172
- m.pattern = title_esc_regex( t )
172
+ m.pattern = name_esc_regex( name )
173
173
 
174
- known_titles << m
174
+ known_names << m
175
175
  end
176
176
 
177
- logger.debug " #{rec.class.name}[#{index+1}] #{rec.key} >#{titles.join('|')}<"
177
+ logger.debug " #{rec.class.name}[#{index+1}] #{rec.key} >#{names.join('|')}<"
178
178
 
179
179
  ## note: only include code field - if defined
180
180
  if rec.respond_to?(:code) && rec.code && !rec.code.empty?
181
181
  m = MappingStruct.new
182
182
  m.key = rec.key
183
- m.title = rec.code
183
+ m.name = rec.code
184
184
  m.length = rec.code.length
185
185
  m.pattern = rec.code ## note: use code for now as is (no variants allowed fow now)
186
186
 
187
- known_titles << m
187
+ known_names << m
188
188
  end
189
189
  end
190
190
 
191
191
  ## note: sort here by length (largest goes first - best match)
192
192
  # exclude code and key (key should always go last)
193
- known_titles = known_titles.sort { |l,r| r.length <=> l.length }
194
- known_titles
193
+ known_names = known_names.sort { |l,r| r.length <=> l.length }
194
+ known_names
195
195
  end
196
196
 
197
197
 
198
198
 
199
- def map_title_for!( tag, line, mappings )
199
+ def map_name_for!( tag, line, mappings )
200
200
  mappings.each do |mapping|
201
201
  key = mapping.key
202
202
  pattern = mapping.pattern
@@ -234,9 +234,9 @@ private
234
234
 
235
235
 
236
236
  ####
237
- # title helper cut-n-paste copy from TextUtils
237
+ # name helper cut-n-paste copy from TextUtils
238
238
  ## see https://github.com/textkit/textutils/blob/master/textutils/lib/textutils/helper/title_helper.rb
239
- def title_esc_regex( title_unescaped )
239
+ def name_esc_regex( name_unescaped )
240
240
 
241
241
  ## escape regex special chars e.g.
242
242
  # . to \. and
@@ -257,16 +257,16 @@ def title_esc_regex( title_unescaped )
257
257
  # e.g. Club Atlético Colón (Santa Fe)
258
258
  # e.g. Bauer Anton (????)
259
259
 
260
- ## NB: cannot use Regexp.escape! will escape space '' to '\ '
261
- ## title = Regexp.escape( title_unescaped )
262
- title = title_unescaped.gsub( '.', '\.' )
263
- title = title.gsub( '(', '\(' )
264
- title = title.gsub( ')', '\)' )
265
- title = title.gsub( '?', '\?' )
266
- title = title.gsub( '*', '\*' )
267
- title = title.gsub( '+', '\+' )
268
- title = title.gsub( '$', '\$' )
269
- title = title.gsub( '^', '\^' )
260
+ ## note: cannot use Regexp.escape! will escape space '' to '\ '
261
+ ## name = Regexp.escape( name_unescaped )
262
+ name = name_unescaped.gsub( '.', '\.' )
263
+ name = name.gsub( '(', '\(' )
264
+ name = name.gsub( ')', '\)' )
265
+ name = name.gsub( '?', '\?' )
266
+ name = name.gsub( '*', '\*' )
267
+ name = name.gsub( '+', '\+' )
268
+ name = name.gsub( '$', '\$' )
269
+ name = name.gsub( '^', '\^' )
270
270
 
271
271
  ## match accented char with or without accents
272
272
  ## add (ü|ue) etc.
@@ -309,10 +309,10 @@ def title_esc_regex( title_unescaped )
309
309
  ## collect some more (real-world) examples first!!!!!
310
310
 
311
311
  alternatives.each do |alt|
312
- title = title.gsub( alt[0], alt[1] )
312
+ name = name.gsub( alt[0], alt[1] )
313
313
  end
314
314
 
315
- title
315
+ name
316
316
  end
317
317
 
318
318
  end # class MapperV2
@@ -16,7 +16,7 @@ class TeamMapper
16
16
  end
17
17
 
18
18
  def map_teams!( line )
19
- @mapper.map_titles!( line )
19
+ @mapper.map_names!( line )
20
20
  end
21
21
  end # class TeamMapper
22
22
 
@@ -82,15 +82,15 @@ class MatchParser ## simple match parser for team match schedules
82
82
  # team1 team2 - match (will get new auto-matchday! not last round)
83
83
  @last_round = nil
84
84
 
85
- title, pos = find_group_title_and_pos!( line )
85
+ name, pos = find_group_name_and_pos!( line )
86
86
 
87
- logger.debug " title: >#{title}<"
87
+ logger.debug " name: >#{name}<"
88
88
  logger.debug " pos: >#{pos}<"
89
89
  logger.debug " line: >#{line}<"
90
90
 
91
- group = @groups[ title ]
91
+ group = @groups[ name ]
92
92
  if group.nil?
93
- puts "!! ERROR - no group def found for >#{title}<"
93
+ puts "!! ERROR - no group def found for >#{name}<"
94
94
  exit 1
95
95
  end
96
96
 
@@ -104,19 +104,19 @@ class MatchParser ## simple match parser for team match schedules
104
104
  @mapper_teams.map_teams!( line )
105
105
  teams = @mapper_teams.find_teams!( line )
106
106
 
107
- title, pos = find_group_title_and_pos!( line )
107
+ name, pos = find_group_name_and_pos!( line )
108
108
 
109
109
  logger.debug " line: >#{line}<"
110
110
 
111
- group = Import::Group.new( pos: pos,
112
- title: title,
113
- teams: teams.map {|team| team.title } )
111
+ ## todo/check/fix: add back group key - why? why not?
112
+ group = Import::Group.new( name: name,
113
+ teams: teams.map {|team| team.name } )
114
114
 
115
- @groups[ title ] = group
115
+ @groups[ name ] = group
116
116
  end
117
117
 
118
118
 
119
- def find_group_title_and_pos!( line )
119
+ def find_group_name_and_pos!( line )
120
120
  ## group pos - for now support single digit e.g 1,2,3 or letter e.g. A,B,C or HEX
121
121
  ## nb: (?:) = is for non-capturing group(ing)
122
122
 
@@ -148,14 +148,14 @@ class MatchParser ## simple match parser for team match schedules
148
148
  else m[1].to_i
149
149
  end
150
150
 
151
- title = m[0]
151
+ name = m[0]
152
152
 
153
- logger.debug " title: >#{title}<"
153
+ logger.debug " name: >#{name}<"
154
154
  logger.debug " pos: >#{pos}<"
155
155
 
156
- line.sub!( regex, '[GROUP.TITLE+POS]' )
156
+ line.sub!( regex, '[GROUP.NAME+POS]' )
157
157
 
158
- [title,pos]
158
+ [name,pos]
159
159
  end
160
160
 
161
161
 
@@ -181,29 +181,29 @@ class MatchParser ## simple match parser for team match schedules
181
181
 
182
182
 
183
183
  pos = find_round_pos!( line )
184
- title = find_round_def_title!( line )
185
- # NB: use extracted round title for knockout check
186
- knockout_flag = is_knockout_round?( title )
184
+ name = find_round_def_name!( line )
185
+ # NB: use extracted round name for knockout check
186
+ knockout_flag = is_knockout_round?( name )
187
187
 
188
188
 
189
189
  logger.debug " start_date: #{start_date}"
190
190
  logger.debug " end_date: #{end_date}"
191
191
  logger.debug " pos: #{pos}"
192
- logger.debug " title: >#{title}<"
192
+ logger.debug " name: >#{name}<"
193
193
  logger.debug " knockout_flag: #{knockout_flag}"
194
194
 
195
195
  logger.debug " line: >#{line}<"
196
196
 
197
197
  #######################################
198
198
  # todo/fix: add auto flag is false !!!! - why? why not?
199
- round = Import::Round.new( pos: pos,
200
- title: title,
199
+ # todo/fix/check: add num if present!!!!
200
+ round = Import::Round.new( name: name,
201
201
  start_date: start_date,
202
202
  end_date: end_date,
203
203
  knockout: knockout_flag,
204
204
  auto: false )
205
205
 
206
- @rounds[ title ] = round
206
+ @rounds[ name ] = round
207
207
  end
208
208
 
209
209
 
@@ -227,8 +227,8 @@ class MatchParser ## simple match parser for team match schedules
227
227
  line.sub!( regex_pos, '[ROUND.POS] ' ) ## NB: add back trailing space that got swallowed w/ regex -> [ \t]+
228
228
  return $1.to_i
229
229
  elsif line =~ regex_num
230
- ## assume number in title is pos (e.g. Jornada 3, 3 Runde etc.)
231
- ## NB: do NOT remove pos from string (will get removed by round title)
230
+ ## assume number in name is pos (e.g. Jornada 3, 3 Runde etc.)
231
+ ## NB: do NOT remove pos from string (will get removed by round name)
232
232
 
233
233
  num = $1.to_i # note: clone capture; keep a copy (another regex follows; will redefine $1)
234
234
 
@@ -254,54 +254,54 @@ class MatchParser ## simple match parser for team match schedules
254
254
  end
255
255
  end # method find_round_pos!
256
256
 
257
- def find_round_def_title!( line )
258
- # assume everything before pipe (\) is the round title
259
- # strip [ROUND.POS], todo:?? [ROUND.TITLE2]
257
+ def find_round_def_name!( line )
258
+ # assume everything before pipe (\) is the round name
259
+ # strip [ROUND.POS], todo:?? [ROUND.NAME2]
260
260
 
261
- # todo/fix: add title2 w/ // or / why? why not?
261
+ # todo/fix: add name2 w/ // or / why? why not?
262
262
  # -- strip / or / chars
263
263
 
264
264
  buf = line.dup
265
- logger.debug " find_round_def_title! line-before: >>#{buf}<<"
265
+ logger.debug " find_round_def_name! line-before: >>#{buf}<<"
266
266
 
267
267
  ## cut-off everything after (including) pipe (|)
268
268
  buf = buf[ 0...buf.index('|') ]
269
269
 
270
- # e.g. remove [ROUND.POS], [ROUND.TITLE2], [GROUP.TITLE+POS] etc.
270
+ # e.g. remove [ROUND.POS], [ROUND.NAME2], [GROUP.NAME+POS] etc.
271
271
  buf.gsub!( /\[[^\]]+\]/, '' ) ## fix: use helper for (re)use e.g. remove_match_placeholder/marker or similar?
272
272
  # remove leading and trailing whitespace
273
273
  buf.strip!
274
274
 
275
- logger.debug " find_round_def_title! line-after: >>#{buf}<<"
275
+ logger.debug " find_round_def_name! line-after: >>#{buf}<<"
276
276
 
277
- logger.debug " title: >>#{buf}<<"
278
- line.sub!( buf, '[ROUND.TITLE]' )
277
+ logger.debug " name: >>#{buf}<<"
278
+ line.sub!( buf, '[ROUND.NAME]' )
279
279
 
280
280
  buf
281
281
  end
282
282
 
283
- def find_round_header_title!( line )
284
- # assume everything left is the round title
285
- # extract all other items first (round title2, round pos, group title n pos, etc.)
283
+ def find_round_header_name!( line )
284
+ # assume everything left is the round name
285
+ # extract all other items first (round name2, round pos, group name n pos, etc.)
286
286
 
287
287
  ## todo/fix:
288
288
  ## cleanup method
289
289
  ## use buf.index( '//' ) to split string (see found_round_def)
290
290
  ## why? simpler why not?
291
- ## - do we currently allow groups if title2 present? add example if it works?
291
+ ## - do we currently allow groups if name2 present? add example if it works?
292
292
 
293
293
  buf = line.dup
294
- logger.debug " find_round_header_title! line-before: >>#{buf}<<"
294
+ logger.debug " find_round_header_name! line-before: >>#{buf}<<"
295
295
 
296
- buf.gsub!( /\[[^\]]+\]/, '' ) # e.g. remove [ROUND.POS], [ROUND.TITLE2], [GROUP.TITLE+POS] etc.
296
+ buf.gsub!( /\[[^\]]+\]/, '' ) # e.g. remove [ROUND.POS], [ROUND.NAME2], [GROUP.NAME+POS] etc.
297
297
  buf.strip! # remove leading and trailing whitespace
298
298
 
299
- logger.debug " find_round_title! line-after: >>#{buf}<<"
299
+ logger.debug " find_round_name! line-after: >>#{buf}<<"
300
300
 
301
- ### bingo - assume what's left is the round title
301
+ ### bingo - assume what's left is the round name
302
302
 
303
- logger.debug " title: >>#{buf}<<"
304
- line.sub!( buf, '[ROUND.TITLE]' )
303
+ logger.debug " name: >>#{buf}<<"
304
+ line.sub!( buf, '[ROUND.NAME]' )
305
305
 
306
306
  buf
307
307
  end
@@ -315,63 +315,21 @@ class MatchParser ## simple match parser for team match schedules
315
315
  # add unit test too to verify
316
316
  pos = find_round_pos!( line )
317
317
 
318
- title = find_round_header_title!( line )
318
+ name = find_round_header_name!( line )
319
319
 
320
320
  logger.debug " line: >#{line}<"
321
321
 
322
322
 
323
- round = @rounds[ title ]
323
+ round = @rounds[ name ]
324
324
  if round.nil? ## auto-add / create if missing
325
- round = Import::Round.new( pos: pos,
326
- title: title )
327
- @rounds[ title ] = round
325
+ ## todo/check: add num (was pos) if present - why? why not?
326
+ round = Import::Round.new( name: name )
327
+ @rounds[ name ] = round
328
328
  end
329
329
 
330
330
  ## todo/check: if pos match (MUST always match for now)
331
331
  @last_round = round
332
332
  @last_group = nil # note: reset group to no group - why? why not?
333
-
334
-
335
- ## NB: dummy/placeholder start_at, end_at date
336
- ## replace/patch after adding all games for round
337
-
338
- =begin
339
- round_attribs = {
340
- title: title,
341
- title2: title2,
342
- knockout: knockout_flag
343
- }
344
-
345
- if pos > 999000
346
- # no pos (e.g. will get autonumbered later) - try match by title for now
347
- # e.g. lets us use title 'Group Replays', for example, multiple times
348
- @round = Round.find_by_event_id_and_title( @event.id, title )
349
- else
350
- @round = Round.find_by_event_id_and_pos( @event.id, pos )
351
- end
352
-
353
- if @round.present?
354
- logger.debug "update round #{@round.id}:"
355
- else
356
- logger.debug "create round:"
357
- @round = Round.new
358
-
359
- round_attribs = round_attribs.merge( {
360
- event_id: @event.id,
361
- pos: pos,
362
- start_at: Date.parse('1911-11-11'),
363
- end_at: Date.parse('1911-11-11')
364
- })
365
- end
366
-
367
- logger.debug round_attribs.to_json
368
-
369
- @round.update_attributes!( round_attribs )
370
-
371
- @patch_round_ids_pos << @round.id if pos > 999000
372
- ### store list of round ids for patching start_at/end_at at the end
373
- @patch_round_ids_dates << @round.id # todo/fix/check: check if round has definition (do NOT patch if definition (not auto-added) present)
374
- =end
375
333
  end
376
334
 
377
335
 
@@ -457,11 +415,11 @@ class MatchParser ## simple match parser for team match schedules
457
415
  ## todo/check: pass along round and group refs or just string (canonical names) - why? why not?
458
416
 
459
417
  @matches << Import::Match.new( date: date,
460
- team1: team1, ## note: for now always use mapping value e.g. rec (NOT string e.g. team1.title)
461
- team2: team2, ## note: for now always use mapping value e.g. rec (NOT string e.g. team2.title)
418
+ team1: team1, ## note: for now always use mapping value e.g. rec (NOT string e.g. team1.name)
419
+ team2: team2, ## note: for now always use mapping value e.g. rec (NOT string e.g. team2.name)
462
420
  score: score,
463
- round: round ? round.title : nil, ## note: for now always use string (assume unique canonical name for event)
464
- group: @last_group ? @last_group.title : nil ) ## note: for now always use string (assume unique canonical name for event)
421
+ round: round ? round.name : nil, ## note: for now always use string (assume unique canonical name for event)
422
+ group: @last_group ? @last_group.name : nil ) ## note: for now always use string (assume unique canonical name for event)
465
423
 
466
424
  ### todo: cache team lookups in hash?
467
425
 
@@ -517,7 +475,7 @@ class MatchParser ## simple match parser for team match schedules
517
475
 
518
476
  round_attribs = {
519
477
  event_id: @event.id,
520
- title: "Matchday #{date.to_date}",
478
+ name: "Matchday #{date.to_date}",
521
479
  pos: 999001+@patch_round_ids_pos.length, # e.g. 999<count> - 999001,999002,etc.
522
480
  start_at: date.to_date,
523
481
  end_at: date.to_date
@@ -541,7 +499,7 @@ class MatchParser ## simple match parser for team match schedules
541
499
  end
542
500
 
543
501
  ## note: will crash (round.pos) if round is nil
544
- logger.debug( " using round #{round.pos} >#{round.title}< start_at: #{round.start_at}, end_at: #{round.end_at}" )
502
+ logger.debug( " using round #{round.pos} >#{round.name}< start_at: #{round.start_at}, end_at: #{round.end_at}" )
545
503
  else
546
504
  ## use round from last round header
547
505
  round = @round
@@ -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]
@@ -2,20 +2,13 @@ module SportDb
2
2
  module Import
3
3
 
4
4
  class Group
5
- attr_reader :title, :pos, :teams
5
+ attr_reader :key, :name, :teams
6
6
 
7
- ##
8
- ## todo: change db schema
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
- @title = title
18
- @pos = pos
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
@@ -2,24 +2,17 @@ module SportDb
2
2
  module Import
3
3
 
4
4
  class Round
5
- attr_reader :title, :start_date, :end_date, :knockout
6
- attr_accessor :pos # note: make read & writable
5
+ attr_reader :name, :start_date, :end_date, :knockout
6
+ attr_accessor :num # note: make read & writable - why? why not?
7
7
 
8
- ##
9
- ## todo: change db schema
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
- @title = title
22
- @pos = pos
14
+ @name = name
15
+ @num = num
23
16
  @start_date = start_date
24
17
  @end_date = end_date
25
18
  @knockout = knockout
@@ -11,10 +11,9 @@ class Team
11
11
  ## todo: use just names for alt_names - why? why not?
12
12
  attr_accessor :key, :name, :alt_names,
13
13
  :code, ## code == abbreviation e.g. ARS etc.
14
- :year, :year_end, ## todo/fix: change year_end to end_year (like in season)!!!
14
+ :year, :year_end, ## todo/fix: change year to start_year and year_end to end_year (like in season)!!!
15
15
  :country
16
16
 
17
- alias_method :title, :name ## add alias/compat - why? why not
18
17
 
19
18
  def names
20
19
  ## todo/check: add alt_names_auto too? - why? why not?
@@ -7,7 +7,7 @@ module Formats
7
7
 
8
8
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
9
  MINOR = 0
10
- PATCH = 5
10
+ PATCH = 6
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
13
13
  def self.version
@@ -75,13 +75,13 @@ TXT
75
75
  assert_equal 'Czechoslovakia (-1992)', recs[0].name
76
76
  assert_equal 'TCH', recs[0].code
77
77
  assert_equal 'czechoslovakia', recs[0].key
78
- assert_equal ['Czechoslovakia'], recs[0].alt_names
78
+ assert_equal [], recs[0].alt_names
79
79
  assert_equal [], recs[0].tags
80
80
 
81
81
  assert_equal 'East Germany (-1989)', recs[3].name
82
82
  assert_equal 'GDR', recs[3].code
83
83
  assert_equal 'eastgermany', recs[3].key
84
- assert_equal ['East Germany'], recs[3].alt_names
84
+ assert_equal [], recs[3].alt_names
85
85
  assert_equal [], recs[3].tags
86
86
  end
87
87
 
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.0.5
4
+ version: 1.0.6
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-05-18 00:00:00.000000000 Z
11
+ date: 2020-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphabets