sportdb-formats 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
  SHA1:
3
- metadata.gz: 7888347efffbc31760344406232e8f930d8777a0
4
- data.tar.gz: 8cba378a58d47f5b4ddc34ee933df6bb19e74cc7
3
+ metadata.gz: '08b90c09533628f176c7c08778634c557898b5ca'
4
+ data.tar.gz: 434a9655f2d11614016322bb7829b975866aa9ca
5
5
  SHA512:
6
- metadata.gz: 54cf5468032c75452e8a595fcf2efb204edec7796478aeef21fdd571c0503eaf1e412c0b8e51e927cb5fab0e7ea363d286885bdd6e7c62f5b422f5f2a7c806b4
7
- data.tar.gz: c56db501666da9225f930ed16d9bbdd16f81d968b5d25eea5f04b764bf5c3bed62a33ad6843595c2316102356d89071c324b13db7a3bb8a8e9171f3abf77a534
6
+ metadata.gz: 6dc601d34ae8d5bb66b181cb09228d40792c2af2a360b82203f711fdfae309353bf1d3f01b79f5c0d4d41e0a64b0d69709193b553065950364a7d4e7bf5a72d3
7
+ data.tar.gz: a583d31ff5fd7d6201c7f85499b448e0f73111a71d679511ca13b82d798ba3a12a40a57be42a821760a3dbafeafe9ab16a8c48b7d46c7f582df27c4f43de175c
@@ -7,8 +7,9 @@ class ScoresFinder
7
7
  include LogUtils::Logging
8
8
 
9
9
 
10
- ## e.g. 3-4 pen. 2-2 a.e.t. (1-1, 1-1)
11
- EN__P_ET_FT_HT__REGEX = /\b
10
+ ## e.g. 3-4 pen. 2-2 a.e.t. (1-1, 1-1) or
11
+ ## 3-4 pen. 2-2 a.e.t. (1-1, )
12
+ EN__P_ET_FT_HT__RE = /\b
12
13
  (?<score1p>\d{1,2})
13
14
  -
14
15
  (?<score2p>\d{1,2})
@@ -28,16 +29,19 @@ class ScoresFinder
28
29
  \s*
29
30
  ,
30
31
  \s*
31
- (?<score1i>\d{1,2})
32
- -
33
- (?<score2i>\d{1,2})
34
- \)
32
+ (?:
33
+ (?<score1i>\d{1,2})
34
+ -
35
+ (?<score2i>\d{1,2})
36
+ )? # note: make half time (HT) score optional for now
37
+ \)
35
38
  (?=[\s\]]|$)/xi ## todo/check: remove loakahead assertion here - why require space?
36
39
  ## note: \b works only after non-alphanum e.g. )
37
40
 
38
41
 
39
- ## e.g. 2-1 a.e.t. (1-1, 0-0)
40
- EN__ET_FT_HT__REGEX = /\b
42
+ ## e.g. 2-1 a.e.t. (1-1, 0-0) or
43
+ ## 2-1 a.e.t. (1-1, )
44
+ EN__ET_FT_HT__RE = /\b
41
45
  (?<score1et>\d{1,2})
42
46
  -
43
47
  (?<score2et>\d{1,2})
@@ -51,16 +55,18 @@ class ScoresFinder
51
55
  \s*
52
56
  ,
53
57
  \s*
54
- (?<score1i>\d{1,2})
55
- -
56
- (?<score2i>\d{1,2})
57
- \)
58
+ (?:
59
+ (?<score1i>\d{1,2})
60
+ -
61
+ (?<score2i>\d{1,2})
62
+ )? # note: make half time (HT) score optional for now
63
+ \)
58
64
  (?=[\s\]]|$)/xi ## todo/check: remove loakahead assertion here - why require space?
59
65
  ## note: \b works only after non-alphanum e.g. )
60
66
 
61
67
 
62
68
  ## e.g. 2-1 (1-1)
63
- EN__FT_HT__REGEX = /\b
69
+ EN__FT_HT__RE = /\b
64
70
  (?<score1>\d{1,2})
65
71
  -
66
72
  (?<score2>\d{1,2})
@@ -81,7 +87,7 @@ class ScoresFinder
81
87
  # e.g. 1:2 or 0:2 or 3:3 or
82
88
  # 1-1 or 0-2 or 3-3 or
83
89
  # 1x1 or 1X1 or 0x2 or 3x3 -- used in Brazil / Portugal
84
- FT_REGEX = /\b
90
+ FT_RE = /\b
85
91
  (?<score1>\d{1,2})
86
92
  [:\-xX]
87
93
  (?<score2>\d{1,2})
@@ -91,7 +97,7 @@ class ScoresFinder
91
97
  # e.g. 1:2nV => after extra time a.e.t
92
98
 
93
99
  # note: possible ending w/ . -> thus cannot use /b will not work w/ .; use zero look-ahead
94
- ET_REGEX = /\b
100
+ ET_RE = /\b
95
101
  (?<score1>\d{1,2})
96
102
  [:\-xX]
97
103
  (?<score2>\d{1,2})
@@ -105,7 +111,7 @@ class ScoresFinder
105
111
 
106
112
 
107
113
  # note: possible ending w/ . -> thus cannot use /b will not work w/ .; use zero look-ahead
108
- P_REGEX = /\b
114
+ P_RE = /\b
109
115
  (?<score1>\d{1,2})
110
116
  [:\-xX]
111
117
  (?<score2>\d{1,2})
@@ -153,72 +159,78 @@ class ScoresFinder
153
159
  score2p = nil
154
160
 
155
161
 
156
- if (md = EN__P_ET_FT_HT__REGEX.match( line ))
157
- score1i = md[:score1i].to_i
158
- score2i = md[:score2i].to_i
159
- score1 = md[:score1].to_i
160
- score2 = md[:score2].to_i
161
- score1et = md[:score1et].to_i
162
- score2et = md[:score2et].to_i
163
- score1p = md[:score1p].to_i
164
- score2p = md[:score2p].to_i
162
+ if (m = EN__P_ET_FT_HT__RE.match( line ))
163
+ if m[:score1i] && m[:score2i] ## note: half time (HT) score is optional now
164
+ score1i = m[:score1i].to_i
165
+ score2i = m[:score2i].to_i
166
+ end
167
+
168
+ score1 = m[:score1].to_i
169
+ score2 = m[:score2].to_i
170
+ score1et = m[:score1et].to_i
171
+ score2et = m[:score2et].to_i
172
+ score1p = m[:score1p].to_i
173
+ score2p = m[:score2p].to_i
165
174
 
166
175
  logger.debug " score.en__p_et_ft_ht: >#{score1p}-#{score2p} pen. #{score1et}-#{score2et} a.e.t. (#{score1}-#{score2}, #{score1i}-#{score2i})<"
167
176
 
168
- line.sub!( md[0], '[SCORES.EN__P_ET_FT_HT]' )
177
+ line.sub!( m[0], '[SCORES.EN__P_ET_FT_HT]' )
178
+
179
+ elsif (m = EN__ET_FT_HT__RE.match( line ))
180
+ if m[:score1i] && m[:score2i] ## note: half time (HT) score is optional now
181
+ score1i = m[:score1i].to_i
182
+ score2i = m[:score2i].to_i
183
+ end
169
184
 
170
- elsif (md = EN__ET_FT_HT__REGEX.match( line ))
171
- score1i = md[:score1i].to_i
172
- score2i = md[:score2i].to_i
173
- score1 = md[:score1].to_i
174
- score2 = md[:score2].to_i
175
- score1et = md[:score1et].to_i
176
- score2et = md[:score2et].to_i
185
+ score1 = m[:score1].to_i
186
+ score2 = m[:score2].to_i
187
+ score1et = m[:score1et].to_i
188
+ score2et = m[:score2et].to_i
177
189
 
178
190
  logger.debug " score.en__et_ft_ht: >#{score1et}-#{score2et} a.e.t. (#{score1}-#{score2}, #{score1i}-#{score2i})<"
179
191
 
180
- line.sub!( md[0], '[SCORES.EN__ET_FT_HT]' )
192
+ line.sub!( m[0], '[SCORES.EN__ET_FT_HT]' )
181
193
 
182
- elsif (md = EN__FT_HT__REGEX.match( line ))
183
- score1i = md[:score1i].to_i
184
- score2i = md[:score2i].to_i
185
- score1 = md[:score1].to_i
186
- score2 = md[:score2].to_i
194
+ elsif (m = EN__FT_HT__RE.match( line ))
195
+ score1i = m[:score1i].to_i
196
+ score2i = m[:score2i].to_i
197
+ score1 = m[:score1].to_i
198
+ score2 = m[:score2].to_i
187
199
 
188
200
  logger.debug " score.en__ft_ht: >#{score1}-#{score2} (#{score1i}-#{score2i})<"
189
201
 
190
- line.sub!( md[0], '[SCORES.EN__FT_HT]' )
202
+ line.sub!( m[0], '[SCORES.EN__FT_HT]' )
191
203
  else
192
204
  #######################################################
193
205
  ## try "standard" generic patterns for fallbacks
194
206
 
195
- if (md = ET_REGEX.match( line ))
196
- score1et = md[:score1].to_i
197
- score2et = md[:score2].to_i
207
+ if (m = ET_RE.match( line ))
208
+ score1et = m[:score1].to_i
209
+ score2et = m[:score2].to_i
198
210
 
199
211
  logger.debug " score.et: >#{score1et}-#{score2et}<"
200
212
 
201
- line.sub!( md[0], '[SCORE.ET]' )
213
+ line.sub!( m[0], '[SCORE.ET]' )
202
214
  end
203
215
 
204
- if (md = P_REGEX.match( line ))
205
- score1p = md[:score1].to_i
206
- score2p = md[:score2].to_i
216
+ if (m = P_RE.match( line ))
217
+ score1p = m[:score1].to_i
218
+ score2p = m[:score2].to_i
207
219
 
208
220
  logger.debug " score.p: >#{score1p}-#{score2p}<"
209
221
 
210
- line.sub!( md[0], '[SCORE.P]' )
222
+ line.sub!( m[0], '[SCORE.P]' )
211
223
  end
212
224
 
213
225
  ## let full time (ft) standard regex go last - has no marker
214
226
 
215
- if (md = FT_REGEX.match( line ))
216
- score1 = md[:score1].to_i
217
- score2 = md[:score2].to_i
227
+ if (m = FT_RE.match( line ))
228
+ score1 = m[:score1].to_i
229
+ score2 = m[:score2].to_i
218
230
 
219
231
  logger.debug " score: >#{score1}-#{score2}<"
220
232
 
221
- line.sub!( md[0], '[SCORE]' )
233
+ line.sub!( m[0], '[SCORE]' )
222
234
  end
223
235
  end
224
236
 
@@ -6,7 +6,7 @@ module Formats
6
6
 
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
8
  MINOR = 2
9
- PATCH = 0
9
+ PATCH = 1
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
data/test/test_scores.rb CHANGED
@@ -70,6 +70,10 @@ class TestScores < MiniTest::Test
70
70
  [ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
71
71
  [ '3-4p 2-2aet (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
72
72
  [ '3-4PSO 2-2AET (1-1, 1-1)', [1,1,1,1,2,2,3,4]],
73
+
74
+ [ '4-3 pen. 1-0 a.e.t. (1-0, )', [nil,nil,1,0,1,0,4,3]],
75
+ [ '3-4 pen. 2-1 a.e.t. (2-1, )', [nil,nil,2,1,2,1,3,4]],
76
+ [ '4-1 a.e.t. (3-1, )', [nil,nil,3,1,4,1]],
73
77
  ]
74
78
 
75
79
  assert_scores( data )
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: 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: 2019-12-29 00:00:00.000000000 Z
11
+ date: 2020-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphabets