sportdb-parser 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c94dcd42fc13a7043f6b926ca1d947df3199877693b22e53e4f50b5aa522bf5d
4
- data.tar.gz: 33eb689dcfb2bab0728c19b7d706da1556ddefafbfbcc6e424ac5bcbe3bccef6
3
+ metadata.gz: 3657cedc5125ee2515efa8be4a1838d05b7290523dd893f7eba5b87024e71238
4
+ data.tar.gz: caf6d7e909e17fa0dcabf659ab8f5046ca1940d8f7c1c6f5312e485dc0089384
5
5
  SHA512:
6
- metadata.gz: 97ef8d76ffa26312d66359f364588af3d7c76a3b0cebd3644b1f1ae775463defa9cb9552b267f26677c2c6f4e9b7b9fe62479dd34a7211fd1a4a3c1b5e9af830
7
- data.tar.gz: ca9b56c6c02c132f3924fb40c293e90379812b830a2899e2be02c1d6469a278456c6d68db7f73d5f5fd69b372c958953e3fefd829ac1120cf56b0944176a2b87
6
+ metadata.gz: 4063565aada304a1eb96009b6fe542392f41a55d4ad4d21b5de156004bd69a055c5f86b076bed1defbe50423c8c891dd538931ea6ca9b8ec41e237c23e699219
7
+ data.tar.gz: 91f6476810cb6617dfcd703ada57592cd38b87f3b4b9fc6fd4468a9457ff0e6ae6337a4e4f5c782e1b80f5f6b6015d5ce26ed6330915cd67a5fb6606f665017f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.0
1
+ ### 0.2.1
2
2
 
3
3
  ### 0.0.1 / 2024-07-12
4
4
 
data/Rakefile CHANGED
@@ -26,6 +26,6 @@ Hoe.spec 'sportdb-parser' do
26
26
  ]
27
27
 
28
28
  self.spec_extras = {
29
- required_ruby_version: '>= 2.2.2'
29
+ required_ruby_version: '>= 3.1.0'
30
30
  }
31
31
  end
data/bin/fbt CHANGED
@@ -55,7 +55,7 @@ p args
55
55
 
56
56
  paths = if args.empty?
57
57
  [
58
- '../../../openfootball/euro/2020--europe/euro.txt',
58
+ '../../../openfootball/euro/2021--europe/euro.txt',
59
59
  '../../../openfootball/euro/2024--germany/euro.txt',
60
60
  ]
61
61
  else
@@ -27,6 +27,12 @@ end
27
27
 
28
28
  ROUND_RE = %r{^(
29
29
 
30
+ ## add special case for group play-off rounds!
31
+ ## group 2 play-off (e.g. worldcup 1954, 1958)
32
+ (?: Group [ ] [a-z0-9]+ [ ]
33
+ Play-?offs?
34
+ )
35
+ |
30
36
  # round - note - requiers number e.g. round 1,2, etc.
31
37
  # note - use 1-9 regex (cannot start with 0) - why? why not?
32
38
  # make week 01 or round 01 or matchday 01 possible?
@@ -46,17 +52,23 @@ ROUND_RE = %r{^(
46
52
  |
47
53
  ## 1. Round / 2. Round / 3. Round / etc.
48
54
  ## Play-off Round
55
+ ## First Round
56
+ ## Final Round (e.g. Worldcup 1950)
49
57
  (?:
50
- (?: [1-9][0-9]* \.
51
- |
52
- Play-?off
58
+ (?: [1-9][0-9]* \. |
59
+ Play-?off |
60
+ 1st | First |
61
+ 2nd | Second |
62
+ Final
53
63
  )
54
64
  [ ] Round
55
65
  )
56
66
  |
57
67
  ## starting with preliminary
68
+ # e.g. Preliminary round
58
69
  (?: Preliminary [ ]
59
- (?: Semi-?finals |
70
+ (?: Round |
71
+ Semi-?finals |
60
72
  Final
61
73
  )
62
74
  )
@@ -110,10 +122,15 @@ ROUND_RE = %r{^(
110
122
  Finals?
111
123
  |
112
124
  ## add replays
113
- ## Final Replay
125
+ ## e.g. Final Replay
126
+ ## Quarter-finals replays
127
+ ## First round replays
114
128
  (?:
115
- Final
116
- [ ] Replay
129
+ (?: First [ ] Round |
130
+ Quarter-?finals? |
131
+ Finals?
132
+ )
133
+ [ ] Replays?
117
134
  )
118
135
  )$}ix
119
136
 
@@ -1,6 +1,6 @@
1
- module SportDb
1
+ module SportDb
2
2
  class Parser
3
-
3
+
4
4
 
5
5
 
6
6
  def self.parse_names( txt )
@@ -47,8 +47,8 @@ def self.build_map( lines, downcase: false )
47
47
  ## "may" => 5,
48
48
  ## "june" => 6, "jun" => 6, ...
49
49
  lines.each_with_index.reduce( {} ) do |h,(line,i)|
50
- line.each do |name|
51
- h[ downcase ? name.downcase : name ] = i+1
50
+ line.each do |name|
51
+ h[ downcase ? name.downcase : name ] = i+1
52
52
  end ## note: start mapping with 1 (and NOT zero-based, that is, 0)
53
53
  h
54
54
  end
@@ -109,28 +109,56 @@ DAY_MAP = build_map( DAY_LINES, downcase: true )
109
109
  ## todo - add more date variants !!!!
110
110
 
111
111
  # e.g. Fri Aug/9 or Fri Aug 9
112
- DATE_RE = %r{
112
+ DATE_I_RE = %r{
113
113
  (?<date>
114
114
  \b
115
115
  ## optional day name
116
116
  ((?<day_name>#{DAY_NAMES})
117
117
  [ ]
118
- )?
118
+ )?
119
119
  (?<month_name>#{MONTH_NAMES})
120
120
  (?: \/|[ ] )
121
121
  (?<day>\d{1,2})
122
122
  ## optional year
123
123
  ( [ ]
124
124
  (?<year>\d{4})
125
- )?
126
- \b
125
+ )?
126
+ \b
127
+ )}ix
128
+
129
+
130
+ # e.g. 3 June or 10 June
131
+ DATE_II_RE = %r{
132
+ (?<date>
133
+ \b
134
+ ## optional day name
135
+ ((?<day_name>#{DAY_NAMES})
136
+ [ ]
137
+ )?
138
+ (?<day>\d{1,2})
139
+ [ ]
140
+ (?<month_name>#{MONTH_NAMES})
141
+ ## optional year
142
+ ( [ ]
143
+ (?<year>\d{4})
144
+ )?
145
+ \b
127
146
  )}ix
128
147
 
129
148
 
149
+ #############################################
150
+ # map tables
151
+ # note: order matters; first come-first matched/served
152
+ DATE_RE = Regexp.union(
153
+ DATE_I_RE,
154
+ DATE_II_RE
155
+ )
156
+
157
+
130
158
  ###
131
- # date duration
159
+ # date duration
132
160
  # use - or + as separator
133
- # in theory plus( +) only if dates
161
+ # in theory plus( +) only if dates
134
162
  # are two days next to each other
135
163
  #
136
164
  # otherwise define new dates type in the future? why? why not?
@@ -147,7 +175,7 @@ DATE_RE = %r{
147
175
  # Jun/25 .. 26 - why? why not???
148
176
  # Jun/25 to 26 - why? why not???
149
177
  # Jun/25 + 26 - add - why? why not???
150
- # Sun-Wed Jun/23-26 - add - why? why not???
178
+ # Sun-Wed Jun/23-26 - add - why? why not???
151
179
  # Wed+Thu Jun/26+27 2024 - add - why? why not???
152
180
  #
153
181
  # maybe use comman and plus for list of dates
@@ -157,39 +185,89 @@ DATE_RE = %r{
157
185
  # add back optional comma (before) year - why? why not?
158
186
 
159
187
 
160
- DURATION_RE = %r{
188
+ ##
189
+ # todo add plus later on - why? why not?
190
+
191
+ DURATION_I_RE = %r{
161
192
  (?<duration>
162
193
  \b
163
194
  ## optional day name
164
195
  ((?<day_name1>#{DAY_NAMES})
165
196
  [ ]
166
- )?
197
+ )?
167
198
  (?<month_name1>#{MONTH_NAMES})
168
199
  (?: \/|[ ] )
169
200
  (?<day1>\d{1,2})
170
201
  ## optional year
171
202
  ( [ ]
172
203
  (?<year1>\d{4})
173
- )?
204
+ )?
174
205
 
175
206
  ## support + and - (add .. or such - why??)
176
- [ ]*[+-][ ]*
177
-
207
+ [ ]*[-][ ]*
208
+
178
209
  ## optional day name
179
210
  ((?<day_name2>#{DAY_NAMES})
180
211
  [ ]
181
- )?
212
+ )?
182
213
  (?<month_name2>#{MONTH_NAMES})
183
214
  (?: \/|[ ] )
184
215
  (?<day2>\d{1,2})
185
216
  ## optional year
186
217
  ( [ ]
187
218
  (?<year2>\d{4})
188
- )?
189
- \b
219
+ )?
220
+ \b
221
+ )}ix
222
+
223
+
224
+ ###
225
+ # variant ii
226
+ # e.g. 26 July - 27 July
227
+
228
+ DURATION_II_RE = %r{
229
+ (?<duration>
230
+ \b
231
+ ## optional day name
232
+ ((?<day_name1>#{DAY_NAMES})
233
+ [ ]
234
+ )?
235
+ (?<day1>\d{1,2})
236
+ [ ]
237
+ (?<month_name1>#{MONTH_NAMES})
238
+ ## optional year
239
+ ( [ ]
240
+ (?<year1>\d{4})
241
+ )?
242
+
243
+ ## support + and - (add .. or such - why??)
244
+ [ ]*[-][ ]*
245
+
246
+ ## optional day name
247
+ ((?<day_name2>#{DAY_NAMES})
248
+ [ ]
249
+ )?
250
+ (?<day2>\d{1,2})
251
+ [ ]
252
+ (?<month_name2>#{MONTH_NAMES})
253
+ ## optional year
254
+ ( [ ]
255
+ (?<year2>\d{4})
256
+ )?
257
+ \b
190
258
  )}ix
191
259
 
192
260
 
261
+ #############################################
262
+ # map tables
263
+ # note: order matters; first come-first matched/served
264
+ DURATION_RE = Regexp.union(
265
+ DURATION_I_RE,
266
+ DURATION_II_RE
267
+ )
268
+
269
+
270
+
193
271
  end # class Parser
194
- end # module SportDb
195
-
272
+ end # module SportDb
273
+
@@ -4,7 +4,7 @@ module SportDb
4
4
  module Parser
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 2
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: 2.2.2
115
+ version: 3.1.0
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="