sportdb 1.8.15 → 1.8.16

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -19,6 +19,7 @@ lib/sportdb/console.rb
19
19
  lib/sportdb/data/keys.rb
20
20
  lib/sportdb/data/models.rb
21
21
  lib/sportdb/deleter.rb
22
+ lib/sportdb/finders/date.rb
22
23
  lib/sportdb/lang.rb
23
24
  lib/sportdb/matcher.rb
24
25
  lib/sportdb/models/badge.rb
data/bin/sportdb CHANGED
File without changes
data/lib/sportdb.rb CHANGED
@@ -65,6 +65,7 @@ end
65
65
 
66
66
 
67
67
  require 'sportdb/schema' # NB: requires sportdb/models (include SportDB::Models)
68
+ require 'sportdb/finders/date'
68
69
  require 'sportdb/utils'
69
70
  require 'sportdb/utils_date'
70
71
  require 'sportdb/utils_group'
@@ -0,0 +1,271 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDb
4
+
5
+ class DateFinder
6
+
7
+ include LogUtils::Logging
8
+
9
+ # todo: make more generic for reuse
10
+ MONTH_EN = 'Jan|Feb|March|Mar|April|Apr|May|June|Jun|July|Jul|Aug|Sept|Sep|Oct|Nov|Dec'
11
+ MONTH_EN_TO_MM = {
12
+ 'Jan' => '1',
13
+ 'Feb' => '2',
14
+ 'Mar' => '3', 'March' => '3',
15
+ 'Apr' => '4', 'April' => '4',
16
+ 'May' => '5',
17
+ 'Jun' => '6', 'June' => '6',
18
+ 'Jul' => '7', 'July' => '7',
19
+ 'Aug' => '8',
20
+ 'Sep' => '9', 'Sept' => '9',
21
+ 'Oct' => '10',
22
+ 'Nov' => '11',
23
+ 'Dec' => '12' }
24
+
25
+ MONTH_ES = 'Enero|Ene|Feb|Marzo|Mar|Abril|Abr|Mayo|May|Junio|Jun|Julio|Jul|Agosto|Ago|Sept|Set|Sep|Oct|Nov|Dic'
26
+ MONTH_ES_TO_MM = {
27
+ 'Ene' => '1', 'Enero' => '1',
28
+ 'Feb' => '2',
29
+ 'Mar' => '3', 'Marzo' => '3',
30
+ 'Abr' => '4', 'Abril' => '4',
31
+ 'May' => '5', 'Mayo' => '5',
32
+ 'Jun' => '6', 'Junio' => '6',
33
+ 'Jul' => '7', 'Julio' => '7',
34
+ 'Ago' => '8', 'Agosto' => '8',
35
+ 'Sep' => '9', 'Set' => '9', 'Sept' => '9',
36
+ 'Oct' => '10',
37
+ 'Nov' => '11',
38
+ 'Dic' => '12' }
39
+
40
+ # todo/fix - add de and es too!!
41
+ # note: in Austria - Jänner - in Deutschland Januar allow both ??
42
+ # MONTH_DE = 'J[aä]n|Feb|Mär|Apr|Mai|Jun|Jul|Aug|Sep|Okt|Nov|Dez'
43
+
44
+
45
+ # e.g. 2012-09-14 20:30 => YYYY-MM-DD HH:MM
46
+ # nb: allow 2012-9-3 7:30 e.g. no leading zero required
47
+ # regex_db
48
+ DB__DATE_TIME_REGEX = /\b
49
+ (?<year>\d{4})
50
+ -
51
+ (?<month>\d{1,2})
52
+ -
53
+ (?<day>\d{1,2})
54
+ \s+
55
+ (?<hours>\d{1,2})
56
+ :
57
+ (?<minutes>\d{2})
58
+ \b/x
59
+
60
+ # e.g. 2012-09-14 w/ implied hours (set to 12:00)
61
+ # nb: allow 2012-9-3 e.g. no leading zero required
62
+ # regex_db2
63
+ DB__DATE_REGEX = /\b
64
+ (?<year>\d{4})
65
+ -
66
+ (?<month>\d{1,2})
67
+ -
68
+ (?<day>\d{1,2})
69
+ \b/x
70
+
71
+ # e.g. 14.09.2012 20:30 => DD.MM.YYYY HH:MM
72
+ # nb: allow 2.3.2012 e.g. no leading zero required
73
+ # nb: allow hour as 20.30
74
+ # regex_de
75
+ DD_MM_YYYY__DATE_TIME_REGEX = /\b
76
+ (?<day>\d{1,2})
77
+ \.
78
+ (?<month>\d{1,2})
79
+ \.
80
+ (?<year>\d{4})
81
+ \s+
82
+ (?<hours>\d{1,2})
83
+ [:.]
84
+ (?<minutes>\d{2})
85
+ \b/x
86
+
87
+ # e.g. 14.09. 20:30 => DD.MM. HH:MM
88
+ # nb: allow 2.3.2012 e.g. no leading zero required
89
+ # nb: allow hour as 20.30 or 3.30 instead of 03.30
90
+ # regex_de2
91
+ DD_MM__DATE_TIME_REGEX = /\b
92
+ (?<day>\d{1,2})
93
+ \.
94
+ (?<month>\d{1,2})
95
+ \.
96
+ \s+
97
+ (?<hours>\d{1,2})
98
+ [:.]
99
+ (?<minutes>\d{2})
100
+ \b/x
101
+
102
+ # e.g. 14.09.2012 => DD.MM.YYYY w/ implied hours (set to 12:00)
103
+ # regex_de3
104
+ DD_MM_YYYY__DATE_REGEX = /\b
105
+ (?<day>\d{1,2})
106
+ \.
107
+ (?<month>\d{1,2})
108
+ \.
109
+ (?<year>\d{4})
110
+ \b/x
111
+
112
+ # e.g. 14.09. => DD.MM. w/ implied year and implied hours (set to 12:00)
113
+ # note: allow end delimiter ] e.g. [Sa 12.01.] or end-of-string ($) too
114
+ # note: we use a lookahead for last part e.g. (?:\s+|$|[\]]) - do NOT cosume
115
+ # regex_de4
116
+ DD_MM__DATE_REGEX = /\b
117
+ (?<day>\d{1,2})
118
+ \.
119
+ (?<month>\d{1,2})
120
+ \.
121
+ (?=\s+|$|[\]])/x ## note: allow end-of-string/line too
122
+
123
+
124
+ # e.g. 12 May 2013 14:00 => D|DD.MMM.YYYY H|HH:MM
125
+ EN__DD_MONTH_YYYY__DATE_TIME_REGEX = /\b
126
+ (?<day>\d{1,2})
127
+ \s
128
+ (?<month_en>#{MONTH_EN})
129
+ \s
130
+ (?<year>\d{4})
131
+ \s+
132
+ (?<hours>\d{1,2})
133
+ :
134
+ (?<minutes>\d{2})
135
+ \b/x
136
+
137
+ # e.g. Jun/12 14:00 w/ implied year H|HH:MM
138
+ EN__MONTH_DD__DATE_TIME_REGEX = /\b
139
+ (?<month_en>#{MONTH_EN})
140
+ \/
141
+ (?<day>\d{1,2})
142
+ \s+
143
+ (?<hours>\d{1,2})
144
+ :
145
+ (?<minutes>\d{2})
146
+ \b/x
147
+
148
+ # e.g. Jun/12 2013 w/ implied hours (set to 12:00)
149
+ EN__MONTH_DD_YYYY__DATE_REGEX = /\b
150
+ (?<month_en>#{MONTH_EN})
151
+ \/
152
+ (?<day>\d{1,2})
153
+ \s
154
+ (?<year>\d{4})
155
+ \b/x
156
+
157
+ # e.g. Jun/12 w/ implied year and implied hours (set to 12:00)
158
+ EN__MONTH_DD__DATE_REGEX = /\b
159
+ (?<month_en>#{MONTH_EN})
160
+ \/
161
+ (?<day>\d{1,2})
162
+ \b/x
163
+
164
+
165
+ # e.g. 12 Ene w/ implied year and implied hours (set to 12:00)
166
+ ES__DD_MONTH__DATE_REGEX = /\b
167
+ (?<day>\d{1,2})
168
+ \s
169
+ (?<month_es>#{MONTH_ES})
170
+ \b/x
171
+
172
+
173
+
174
+ # map table - 1) tag, 2) regex - note: order matters; first come-first matched/served
175
+ FORMATS = [
176
+ [ '[YYYY_MM_DD_hh_mm]', DB__DATE_TIME_REGEX ],
177
+ [ '[YYYY_MM_DD]', DB__DATE_REGEX ],
178
+ [ '[DD_MM_YYYY_hh_mm]', DD_MM_YYYY__DATE_TIME_REGEX ],
179
+ [ '[DD_MM_hh_mm]', DD_MM__DATE_TIME_REGEX ],
180
+ [ '[DD_MM_YYYY]', DD_MM_YYYY__DATE_REGEX ],
181
+ [ '[DD_MM]', DD_MM__DATE_REGEX ],
182
+ [ '[EN_DD_MONTH_YYYY_hh_mm]', EN__DD_MONTH_YYYY__DATE_TIME_REGEX ],
183
+ [ '[EN_MONTH_DD_hh_mm]', EN__MONTH_DD__DATE_TIME_REGEX ],
184
+ [ '[EN_MONTH_DD_YYYY]', EN__MONTH_DD_YYYY__DATE_REGEX ],
185
+ [ '[EN_MONTH_DD]', EN__MONTH_DD__DATE_REGEX ],
186
+ [ '[ES_DD_MONTH]', ES__DD_MONTH__DATE_REGEX ]
187
+ ]
188
+
189
+
190
+
191
+ def initialize
192
+ # nothing here for now
193
+ end
194
+
195
+ def find!( line, opts={} )
196
+ # fix: use more lookahead for all required trailing spaces!!!!!
197
+ # fix: use <name capturing group> for month,day,year etc.!!!
198
+
199
+ #
200
+ # fix: !!!!
201
+ # date in [] will become [[DATE.DE4]] - when getting removed will keep ]!!!!
202
+ # fix: change regex to \[[A-Z0-9.]\] !!!!!! plus add unit test too!!!
203
+ #
204
+
205
+ md = nil
206
+ FORMATS.each do |format|
207
+ tag = format[0]
208
+ pattern = format[1]
209
+ md=pattern.match( line )
210
+ if md
211
+ date = parse_date_time( md, opts )
212
+ ## fix: use md[0] e.g. match for sub! instead of using regex again - why? why not???
213
+ ## fix: use md.begin(0), md.end(0)
214
+ line.sub!( md[0], tag )
215
+ ## todo/fix: make sure match data will not get changed (e.g. using sub! before parse_date_time)
216
+ return date
217
+ end
218
+ # no match; continue; try next pattern
219
+ end
220
+
221
+ return nil # no match found
222
+ end
223
+
224
+ private
225
+ def calc_year( month, day, opts )
226
+ start_at = opts[:start_at]
227
+
228
+ logger.debug " [calc_year] ????-#{month}-#{day} -- start_at: #{start_at}"
229
+
230
+ if month >= start_at.month
231
+ # assume same year as start_at event (e.g. 2013 for 2013/14 season)
232
+ start_at.year
233
+ else
234
+ # assume year+1 as start_at event (e.g. 2014 for 2013/14 season)
235
+ start_at.year+1
236
+ end
237
+ end
238
+
239
+ def parse_date_time( match_data, opts={} )
240
+
241
+ # convert regex match_data captures to hash
242
+ # - note: cannont use match_data like a hash (e.g. raises exception if key/name not present/found)
243
+ h = {}
244
+ # - note: do NOT forget to turn name into symbol for lookup in new hash (name.to_sym)
245
+ match_data.names.each { |name| h[name.to_sym] = match_data[name] } # or use match_data.names.zip( match_data.captures ) - more cryptic but "elegant"??
246
+
247
+ ## puts "[parse_date_time] match_data:"
248
+ ## pp h
249
+ logger.debug " [parse_date_time] hash: >#{h.inspect}<"
250
+
251
+ h[ :month ] = MONTH_EN_TO_MM[ h[:month_en] ] if h[:month_en]
252
+ h[ :month ] = MONTH_ES_TO_MM[ h[:month_es] ] if h[:month_es]
253
+
254
+ month = h[:month]
255
+ day = h[:day]
256
+ year = h[:year] || calc_year( month.to_i, day.to_i, opts ).to_s
257
+
258
+ hours = h[:hours] || '12' # default to 12:00 for HH:MM (hours:minutes)
259
+ minutes = h[:minutes] || '00'
260
+
261
+ value = '%d-%02d-%02d %02d:%02d' % [year.to_i, month.to_i, day.to_i, hours.to_i, minutes.to_i]
262
+ logger.debug " date: >#{value}<"
263
+
264
+ DateTime.strptime( value, '%Y-%m-%d %H:%M' )
265
+ end
266
+
267
+
268
+ end # class DateFinder
269
+
270
+
271
+ end # module SportDb
@@ -33,5 +33,6 @@ module SportDb
33
33
  TEAM_CODE_PATTERN = '\A[A-Z][A-Z0-9][A-Z0-9_]?\z'
34
34
  TEAM_CODE_PATTERN_MESSAGE = "expected two or three uppercase letters A-Z (and 0-9_; must start with A-Z) /#{TEAM_CODE_PATTERN}/"
35
35
 
36
+
36
37
  end # module SportDb
37
38
 
@@ -8,19 +8,8 @@ module SportDb
8
8
  line =~ /=>/
9
9
  end
10
10
 
11
- def calculate_year( day, month, start_at )
12
- if month >= start_at.month
13
- # assume same year as start_at event (e.g. 2013 for 2013/14 season)
14
- start_at.year
15
- else
16
- # assume year+1 as start_at event (e.g. 2014 for 2013/14 season)
17
- start_at.year+1
18
- end
19
- end
20
-
21
11
 
22
12
  def find_date!( line, opts={} )
23
-
24
13
  ## NB: lets us pass in start_at/end_at date (for event)
25
14
  # for auto-complete year
26
15
 
@@ -28,201 +17,8 @@ module SportDb
28
17
  # and return it
29
18
  # NB: side effect - removes date from line string
30
19
 
31
- # e.g. 2012-09-14 20:30 => YYYY-MM-DD HH:MM
32
- # nb: allow 2012-9-3 7:30 e.g. no leading zero required
33
- regex_db = /\b(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{2})\b/
34
-
35
- # e.g. 2012-09-14 w/ implied hours (set to 12:00)
36
- # nb: allow 2012-9-3 e.g. no leading zero required
37
- regex_db2 = /\b(\d{4})-(\d{1,2})-(\d{1,2})\b/
38
-
39
- # e.g. 14.09. 20:30 => DD.MM. HH:MM
40
- # nb: allow 2.3.2012 e.g. no leading zero required
41
- # nb: allow hour as 20.30 or 3.30 instead of 03.30
42
- regex_de = /\b(\d{1,2})\.(\d{1,2})\.\s+(\d{1,2})[:.](\d{2})\b/
43
-
44
- # e.g. 14.09.2012 20:30 => DD.MM.YYYY HH:MM
45
- # nb: allow 2.3.2012 e.g. no leading zero required
46
- # nb: allow hour as 20.30
47
- regex_de2 = /\b(\d{1,2})\.(\d{1,2})\.(\d{4})\s+(\d{1,2})[:.](\d{2})\b/
48
-
49
- # e.g. 14.09.2012 => DD.MM.YYYY w/ implied hours (set to 12:00)
50
- regex_de3 = /\b(\d{1,2})\.(\d{1,2})\.(\d{4})\b/
51
-
52
- # e.g. 14.09. => DD.MM. w/ implied year and implied hours (set to 12:00)
53
- # note: allow end delimiter ] e.g. [Sa 12.01.] or end-of-string ($) too
54
- # note: we use a lookahead for last part e.g. (?:\s+|$|[\]]) - do NOT cosume
55
- regex_de4 = /\b(\d{1,2})\.(\d{1,2})\.(?=\s+|$|[\]])/ ## note: allow end-of-string/line too
56
-
57
- # fix: !!!!
58
- # date in [] will become [[DATE.DE4]] - when getting removed will keep ]!!!!
59
- # fix: change regex to \[[A-Z0-9.]\] !!!!!! plus add unit test too!!!
60
- #
61
- # fix: use more lookahead for all required trailing spaces!!!!!
62
- # fix: use <name capturing group> for month,day,year etc.!!!
63
-
64
- # todo: make more generic for reuse
65
- month_abbrev_en = 'Jan|Feb|March|Mar|April|Apr|May|June|Jun|July|Jul|Aug|Sept|Sep|Oct|Nov|Dec'
66
- month_abbrev_en_to_i = {
67
- 'Jan' => 1,
68
- 'Feb' => 2,
69
- 'Mar' => 3, 'March' => 3,
70
- 'Apr' => 4, 'April' => 4,
71
- 'May' => 5,
72
- 'Jun' => 6, 'June' => 6,
73
- 'Jul' => 7, 'July' => 7,
74
- 'Aug' => 8,
75
- 'Sep' => 9, 'Sept' => 9,
76
- 'Oct' => 10,
77
- 'Nov' => 11,
78
- 'Dec' => 12 }
79
-
80
-
81
- # e.g. 12 May 2013 14:00 => D|DD.MMM.YYYY H|HH:MM
82
- regex_en = /\b(\d{1,2})\s(#{month_abbrev_en})\s(\d{4})\s+(\d{1,2}):(\d{2})\b/
83
-
84
-
85
- # e.g. Jun/12 14:00 w/ implied year H|HH:MM
86
- regex_en2 = /\b(#{month_abbrev_en})\/(\d{1,2})\s+(\d{1,2}):(\d{2})\b/
87
-
88
- # e.g. Jun/12 w/ implied year and implied hours (set to 12:00)
89
- regex_en21 = /\b(#{month_abbrev_en})\/(\d{1,2})\b/
90
-
91
- # todo/fix - add de and es too!!
92
- # note: in Austria - Jänner - in Deutschland Januar allow both ??
93
- month_abbrev_de = 'J[aä]n|Feb|Mär|Apr|Mai|Jun|Jul|Aug|Sep|Okt|Nov|Dez'
94
-
95
- month_abbrev_es = 'Enero|Ene|Feb|Marzo|Mar|Abril|Abr|Mayo|May|Junio|Jun|Julio|Jul|Agosto|Ago|Sept|Set|Sep|Oct|Nov|Dic'
96
- month_abbrev_es_to_i = {
97
- 'Ene' => 1, 'Enero' => 1,
98
- 'Feb' => 2,
99
- 'Mar' => 3, 'Marzo' => 3,
100
- 'Abr' => 4, 'Abril' => 4,
101
- 'May' => 5, 'Mayo' => 5,
102
- 'Jun' => 6, 'Junio' => 6,
103
- 'Jul' => 7, 'Julio' => 7,
104
- 'Ago' => 8, 'Agosto' => 8,
105
- 'Sep' => 9, 'Set' => 9, 'Sept' => 9,
106
- 'Oct' => 10,
107
- 'Nov' => 11,
108
- 'Dic' => 12 }
109
-
110
- # e.g. 12 Ene w/ implied year and implied hours (set to 12:00)
111
- regex_es21 = /\b(\d{1,2})\s(#{month_abbrev_es})\b/
112
-
113
- if line =~ regex_db
114
- value = '%d-%02d-%02d %02d:%02d' % [$1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i]
115
- logger.debug " date: >#{value}<"
116
-
117
- ## todo: lets you configure year
118
- ## and time zone (e.g. cet, eet, utc, etc.)
119
-
120
- line.sub!( regex_db, '[DATE.DB]' )
121
-
122
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
123
- elsif line =~ regex_db2
124
- value = '%d-%02d-%02d 12:00' % [$1.to_i, $2.to_i, $3.to_i]
125
- logger.debug " date: >#{value}<"
126
-
127
- line.sub!( regex_db2, '[DATE.DB2]' )
128
-
129
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
130
- elsif line =~ regex_de2
131
- value = '%d-%02d-%02d %02d:%02d' % [$3.to_i, $2.to_i, $1.to_i, $4.to_i, $5.to_i]
132
- logger.debug " date: >#{value}<"
133
-
134
- ## todo: lets you configure year
135
- ## and time zone (e.g. cet, eet, utc, etc.)
136
-
137
- line.sub!( regex_de2, '[DATE.DE2]' )
138
-
139
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
140
- elsif line =~ regex_de
141
-
142
- year = calculate_year( $1.to_i, $2.to_i, opts[:start_at] )
143
-
144
- value = '%d-%02d-%02d %02d:%02d' % [year, $2.to_i, $1.to_i, $3.to_i, $4.to_i]
145
- logger.debug " date: >#{value}<"
146
-
147
- ## todo: lets you configure year
148
- ## and time zone (e.g. cet, eet, utc, etc.)
149
-
150
- line.sub!( regex_de, '[DATE.DE]' )
151
-
152
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
153
- elsif line =~ regex_de3
154
- value = '%d-%02d-%02d 12:00' % [$3.to_i, $2.to_i, $1.to_i]
155
- logger.debug " date: >#{value}<"
156
-
157
- ## todo: lets you configure year
158
- ## and time zone (e.g. cet, eet, utc, etc.)
159
-
160
- line.sub!( regex_de3, '[DATE.DE3]' )
161
-
162
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
163
- elsif line =~ regex_de4
164
-
165
- year = calculate_year( $1.to_i, $2.to_i, opts[:start_at] )
166
-
167
- value = '%d-%02d-%02d 12:00' % [year, $2.to_i, $1.to_i]
168
- logger.debug " date: >#{value}<"
169
-
170
- ## todo: lets you configure year
171
- ## and time zone (e.g. cet, eet, utc, etc.)
172
-
173
- ### NOTE: needs a trailing space
174
- # not if regex ends w/ whitespace e.g. /s+
175
- # make sure sub! adds a space at the end
176
- # e.g. '[DATE.DE4]' becomes '[DATE.DE4] '
177
-
178
- line.sub!( regex_de4, '[DATE.DE4] ' )
179
-
180
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
181
- elsif line =~ regex_en
182
- value = '%d-%s-%02d %02d:%02d' % [$3.to_i, $2, $1.to_i, $4.to_i, $5.to_i]
183
- logger.debug " date: >#{value}<"
184
-
185
- line.sub!( regex_en, '[DATE.EN]' )
186
-
187
- return DateTime.strptime( value, '%Y-%b-%d %H:%M' ) ## %b - abbreviated month name (e.g. Jan,Feb, etc.)
188
- elsif line =~ regex_en2
189
- day = $2.to_i
190
- month = month_abbrev_en_to_i[ $1 ]
191
- year = calculate_year( day, month, opts[:start_at] )
192
- hours = $3.to_i
193
- minutes = $4.to_i
194
-
195
- value = '%d-%02d-%02d %02d:%02d' % [year, month, day, hours, minutes]
196
- logger.debug " date: >#{value}<"
197
-
198
- line.sub!( regex_en2, '[DATE.EN2] ' )
199
-
200
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
201
- elsif line =~ regex_en21
202
- day = $2.to_i
203
- month = month_abbrev_en_to_i[ $1 ]
204
- year = calculate_year( day, month, opts[:start_at] )
205
-
206
- value = '%d-%02d-%02d 12:00' % [year, month, day]
207
- logger.debug " date: >#{value}<"
208
-
209
- line.sub!( regex_en21, '[DATE.EN21] ' )
210
-
211
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
212
- elsif line =~ regex_es21
213
- day = $1.to_i
214
- month = month_abbrev_es_to_i[ $2 ]
215
- year = calculate_year( day, month, opts[:start_at] )
216
-
217
- value = '%d-%02d-%02d 12:00' % [year, month, day]
218
- logger.debug " date: >#{value}<"
219
-
220
- line.sub!( regex_es21, '[DATE.ES21] ' )
221
-
222
- return DateTime.strptime( value, '%Y-%m-%d %H:%M' )
223
- else
224
- return nil
225
- end
20
+ finder = DateFinder.new
21
+ finder.find!( line, opts )
226
22
  end
227
23
 
228
24
  end # module FixtureHelpers
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.15'
3
+ VERSION = '1.8.16'
4
4
  end
5
5
 
6
6
 
data/test/test_date.rb CHANGED
@@ -1,18 +1,31 @@
1
1
  # encoding: utf-8
2
2
 
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_date.rb
6
+
3
7
  require 'helper'
4
8
 
5
9
  class TestDate < MiniTest::Unit::TestCase
6
10
 
7
11
  def test_date
12
+ start_at = DateTime.new( 2013, 1, 1 )
13
+
8
14
  assert_datetime DateTime.new( 2013, 1, 19, 22 ), parse_date( '19.01.2013 22.00' )
9
15
  assert_datetime DateTime.new( 2013, 1, 21, 21, 30 ), parse_date( '21.01.2013 21.30' )
10
16
 
11
17
  assert_date DateTime.new( 2013, 1, 26 ), parse_date( '26.01.2013' )
18
+ assert_date DateTime.new( 2013, 1, 26 ), parse_date( '[26.01.2013]' )
19
+
20
+ assert_datetime DateTime.new( 2013, 1, 21, 12, 00 ), parse_date( '[21.1.]', start_at: start_at )
12
21
  end
13
22
 
23
+
14
24
  def test_date_en
15
- start_at = DateTime.new( 2013, 1, 25 )
25
+ start_at = DateTime.new( 2013, 1, 1 )
26
+
27
+ assert_date DateTime.new( 2011, 1, 26 ), parse_date( 'Jan/26 2011', start_at: start_at )
28
+ assert_datetime DateTime.new( 2011, 1, 26, 12, 00 ), parse_date( 'Jan/26 2011', start_at: start_at )
16
29
 
17
30
  assert_date DateTime.new( 2013, 1, 26 ), parse_date( 'Jan/26', start_at: start_at )
18
31
  assert_datetime DateTime.new( 2013, 1, 26, 12, 00 ), parse_date( 'Jan/26', start_at: start_at )
@@ -30,7 +43,7 @@ private
30
43
  assert_equal exp.month, act.month
31
44
  assert_equal exp.day, act.day
32
45
  end
33
-
46
+
34
47
  def assert_time( exp, act )
35
48
  assert_equal exp.hour, act.hour
36
49
  assert_equal exp.min, act.min
@@ -41,15 +54,11 @@ private
41
54
  assert_time( exp, act )
42
55
  end
43
56
 
44
- class Reader
45
- include LogUtils::Logging # add logger
46
- include SportDb::FixtureHelpers
47
- end
48
57
 
49
58
  def parse_date( line, opts={} )
50
59
  # e.g. lets you pass in opts[:start_at] ???
51
- reader = Reader.new
52
- reader.find_date!( line, opts )
60
+ finder = SportDb::DateFinder.new
61
+ finder.find!( line, opts )
53
62
  end
54
63
 
55
64
  end # class TestScores
metadata CHANGED
@@ -1,155 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.15
4
+ version: 1.8.16
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Gerald Bauer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-04-21 00:00:00.000000000 Z
12
+ date: 2014-04-25 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: props
15
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &72538960 !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ! '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
24
+ version_requirements: *72538960
27
25
  - !ruby/object:Gem::Dependency
28
26
  name: logutils
29
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &72537120 !ruby/object:Gem::Requirement
28
+ none: false
30
29
  requirements:
31
30
  - - ! '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
35
+ version_requirements: *72537120
41
36
  - !ruby/object:Gem::Dependency
42
37
  name: textutils
43
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &72529170 !ruby/object:Gem::Requirement
39
+ none: false
44
40
  requirements:
45
41
  - - ! '>='
46
42
  - !ruby/object:Gem::Version
47
43
  version: '0'
48
44
  type: :runtime
49
45
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
46
+ version_requirements: *72529170
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: worlddb
57
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &72528110 !ruby/object:Gem::Requirement
50
+ none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 2.0.2
62
55
  type: :runtime
63
56
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: 2.0.2
57
+ version_requirements: *72528110
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: tagutils
71
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &72527770 !ruby/object:Gem::Requirement
61
+ none: false
72
62
  requirements:
73
63
  - - ! '>='
74
64
  - !ruby/object:Gem::Version
75
65
  version: '0'
76
66
  type: :runtime
77
67
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ! '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
68
+ version_requirements: *72527770
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: fetcher
85
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &72527230 !ruby/object:Gem::Requirement
72
+ none: false
86
73
  requirements:
87
74
  - - ! '>='
88
75
  - !ruby/object:Gem::Version
89
76
  version: '0.3'
90
77
  type: :runtime
91
78
  prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: '0.3'
79
+ version_requirements: *72527230
97
80
  - !ruby/object:Gem::Dependency
98
81
  name: gli
99
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &72526900 !ruby/object:Gem::Requirement
83
+ none: false
100
84
  requirements:
101
85
  - - ! '>='
102
86
  - !ruby/object:Gem::Version
103
87
  version: 2.5.6
104
88
  type: :runtime
105
89
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: 2.5.6
90
+ version_requirements: *72526900
111
91
  - !ruby/object:Gem::Dependency
112
92
  name: activerecord
113
- requirement: !ruby/object:Gem::Requirement
93
+ requirement: &72526650 !ruby/object:Gem::Requirement
94
+ none: false
114
95
  requirements:
115
96
  - - ! '>='
116
97
  - !ruby/object:Gem::Version
117
98
  version: '0'
118
99
  type: :runtime
119
100
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ! '>='
123
- - !ruby/object:Gem::Version
124
- version: '0'
101
+ version_requirements: *72526650
125
102
  - !ruby/object:Gem::Dependency
126
103
  name: rdoc
127
- requirement: !ruby/object:Gem::Requirement
104
+ requirement: &72526110 !ruby/object:Gem::Requirement
105
+ none: false
128
106
  requirements:
129
107
  - - ~>
130
108
  - !ruby/object:Gem::Version
131
109
  version: '4.0'
132
110
  type: :development
133
111
  prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ~>
137
- - !ruby/object:Gem::Version
138
- version: '4.0'
112
+ version_requirements: *72526110
139
113
  - !ruby/object:Gem::Dependency
140
114
  name: hoe
141
- requirement: !ruby/object:Gem::Requirement
115
+ requirement: &72524490 !ruby/object:Gem::Requirement
116
+ none: false
142
117
  requirements:
143
118
  - - ~>
144
119
  - !ruby/object:Gem::Version
145
- version: '3.10'
120
+ version: '3.11'
146
121
  type: :development
147
122
  prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ~>
151
- - !ruby/object:Gem::Version
152
- version: '3.10'
123
+ version_requirements: *72524490
153
124
  description: sportdb - sport.db command line tool
154
125
  email: opensport@googlegroups.com
155
126
  executables:
@@ -181,6 +152,7 @@ files:
181
152
  - lib/sportdb/data/keys.rb
182
153
  - lib/sportdb/data/models.rb
183
154
  - lib/sportdb/deleter.rb
155
+ - lib/sportdb/finders/date.rb
184
156
  - lib/sportdb/lang.rb
185
157
  - lib/sportdb/matcher.rb
186
158
  - lib/sportdb/models/badge.rb
@@ -288,7 +260,6 @@ files:
288
260
  homepage: https://github.com/geraldb/sport.db.ruby
289
261
  licenses:
290
262
  - Public Domain
291
- metadata: {}
292
263
  post_install_message: ! '******************************************************************************
293
264
 
294
265
 
@@ -306,29 +277,31 @@ rdoc_options:
306
277
  require_paths:
307
278
  - lib
308
279
  required_ruby_version: !ruby/object:Gem::Requirement
280
+ none: false
309
281
  requirements:
310
282
  - - ! '>='
311
283
  - !ruby/object:Gem::Version
312
284
  version: 1.9.2
313
285
  required_rubygems_version: !ruby/object:Gem::Requirement
286
+ none: false
314
287
  requirements:
315
288
  - - ! '>='
316
289
  - !ruby/object:Gem::Version
317
290
  version: '0'
318
291
  requirements: []
319
292
  rubyforge_project:
320
- rubygems_version: 2.1.10
293
+ rubygems_version: 1.8.17
321
294
  signing_key:
322
- specification_version: 4
295
+ specification_version: 3
323
296
  summary: sportdb - sport.db command line tool
324
297
  test_files:
325
- - test/test_changes.rb
326
- - test/test_cursor.rb
327
298
  - test/test_date.rb
328
299
  - test/test_lang.rb
329
- - test/test_reader.rb
330
- - test/test_round_def.rb
331
- - test/test_round_header.rb
300
+ - test/test_cursor.rb
332
301
  - test/test_scores.rb
333
- - test/test_utils.rb
334
302
  - test/test_winner.rb
303
+ - test/test_round_def.rb
304
+ - test/test_utils.rb
305
+ - test/test_round_header.rb
306
+ - test/test_reader.rb
307
+ - test/test_changes.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 4459c37fc4ca396f49c2c42a8a0dbb671c1eb7e9
4
- data.tar.gz: de9e5e62f8de5fb9b45a78534e43368d5404b70f
5
- SHA512:
6
- metadata.gz: ca0972bd7ecc76d8d2aaf7ba8b12690b8145b68c80b64c630ae446a47e622cba84bcae477e9b6bacd89b6ff856716bbd3db00a0a11ce8f472e8b72d1eadd736f
7
- data.tar.gz: 7aa791e995880106aa051855db62fa92cb63bd57671f1af0f835a457055c11bf12ec9fa0b26ff61cf9f6ffc1655678d9dbe685660939d72db7a45dba7472c680