sportdb-parser 0.6.7 → 0.6.9

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.
@@ -13,6 +13,39 @@ RefereeLine = Struct.new( :name, :country ) do
13
13
  end
14
14
  end
15
15
 
16
+ AttendanceLine = Struct.new( :att ) do
17
+ def pretty_print( printer )
18
+ printer.text( "<AttendanceLine #{self.att}>" )
19
+ end
20
+ end
21
+
22
+
23
+
24
+ PenaltiesLine = Struct.new( :penalties ) do
25
+ def pretty_print( printer )
26
+ printer.text( "<PenaltiesLine " )
27
+ printer.text( self.penalties.pretty_inspect )
28
+ printer.text( ">" )
29
+ end
30
+ end
31
+
32
+ Penalty = Struct.new( :name, :score, :note ) do
33
+ def to_s
34
+ buf = String.new
35
+ buf << "#{self.score} " if self.score
36
+ buf << self.name
37
+ buf << " (#{self.note})" if self.note
38
+ buf
39
+ end
40
+
41
+ def pretty_print( printer )
42
+ printer.text( to_s )
43
+ end
44
+ end
45
+
46
+
47
+
48
+
16
49
  ## find a better name for player (use bookings?) - note - red/yellow card for trainer possible
17
50
  CardsLine = Struct.new( :type, :bookings ) do
18
51
  def pretty_print( printer )
@@ -30,30 +30,30 @@ PROP_NAME_RE = %r{
30
30
  (?:
31
31
  (?<![ ]) ## use negative lookbehind
32
32
  [ ]
33
- (?=\p{L}|') ## use lookahead
33
+ (?=\p{L}|['"]) ## use lookahead
34
34
  )
35
- |
35
+ ## support (inline) quoted name e.g. "Rodri" or such
36
+ |
37
+ (?:
38
+ (?<=[ ]) ## use positive lookbehind
39
+ " \p{L}+ "
40
+ ## require space here too - why? why not?
41
+ )
42
+ |
36
43
  (?:
37
44
  (?<=\p{L}) ## use lookbehind
38
- ['-] ## must be surrounded by letters
45
+ [-] ## must be surrounded by letters
39
46
  ## e.g. One/Two NOT
40
47
  ## One/ Two or One / Two or One /Two etc.
41
48
  (?=\p{L}) ## use lookahead
42
49
  )
43
50
  |
44
- (?:
45
- (?<=[ ]) ## use lookbehind -- add letter (plus dot) or such - why? why not?
46
- ['] ## must be surrounded by leading space and
47
- ## traling letters (e.g. UDI 'Beter Bed)
48
- (?=\p{L}) ## use lookahead
49
- )
50
- |
51
- (?:
52
- (?<=\p{L}) ## use lookbehind
53
- ['] ## must be surrounded by leading letter and
54
- ## trailing space PLUS letter (e.g. UDI' Beter Bed)
55
- (?=[ ]\p{L}) ## use lookahead (space WITH letter
56
- )
51
+ (?: ## flex rule for quote - allow any
52
+ ## only check for double quotes e.g. cannot follow other ' for now - why? why not?
53
+ ## allows rodrigez 'rodri' for example
54
+ (?<!') ## use negative lookbehind
55
+ '
56
+ )
57
57
  | ## standard case with letter(s) and optinal dot
58
58
  (?: \p{L}+
59
59
  \.? ## optional dot
@@ -148,6 +148,39 @@ PROP_NAME_RE = %r{
148
148
  )
149
149
  }ix
150
150
 
151
+
152
+ PROP_NUM_RE = %r{
153
+ \b
154
+ (?<num>
155
+ ## note allow underscore inline or space e.g.
156
+ ## 5_000
157
+ ## allow space inline (e.g. 5 000) - why? why not?
158
+ (?<value> [1-9]
159
+ (?: _?
160
+ [0-9]+
161
+ )*
162
+ )
163
+ )
164
+ \b
165
+ }ix
166
+
167
+ ### todo/fix - allow more chars in enclosed name - why? why not?
168
+ ## e.g. (') - Cote D'Ivore etc.
169
+ ## change to PAREN_NAME or PARENTHESIS or such - why? why not?
170
+ ENCLOSED_NAME_RE = %r{
171
+ (?<enclosed_name>
172
+ \(
173
+ (?<name>
174
+ \p{L}+
175
+ (?:
176
+ [ ]
177
+ \p{L}+
178
+ )*
179
+ )
180
+ \)
181
+ )
182
+ }ix
183
+
151
184
 
152
185
 
153
186
  PROP_BASICS_RE = %r{
@@ -160,22 +193,47 @@ PROP_BASICS_RE = %r{
160
193
  }ix
161
194
 
162
195
  PROP_RE = Regexp.union(
163
- PROP_BASICS_RE,
164
196
  MINUTE_RE,
165
197
  PROP_KEY_INLINE_RE,
166
198
  PROP_NAME_RE,
199
+ PROP_BASICS_RE,
167
200
  ## todo/fix - add ANY_RE here too!!!
168
201
  )
169
202
 
170
203
  ## note - no inline keys possible
171
204
  ## todo/fix - use custom (limited) prop basics too
172
205
  PROP_CARDS_RE = Regexp.union(
173
- PROP_BASICS_RE,
174
206
  MINUTE_RE,
175
207
  PROP_NAME_RE,
208
+ PROP_BASICS_RE,
176
209
  ## todo/fix - add ANY_RE here too!!!
177
210
  )
178
211
 
212
+
213
+ PROP_PENALTIES_RE = Regexp.union(
214
+ SCORE_RE, # e.g. 1-1 etc.
215
+ ENCLOSED_NAME_RE, # e.g. (save), (post), etc.
216
+ PROP_NAME_RE,
217
+ PROP_BASICS_RE,
218
+ ## todo/fix - add ANY_RE here too!!!
219
+ )
220
+
221
+
222
+ PROP_REFEREE_RE = Regexp.union(
223
+ ENCLOSED_NAME_RE, # e.g. (sold out) etc. why? why not?
224
+ PROP_NUM_RE, # e.g. 28 000 or 28_000 (NOT 28,000 is not valid!!!)
225
+ PROP_KEY_INLINE_RE,
226
+ PROP_NAME_RE,
227
+ PROP_BASICS_RE,
228
+ ## todo/fix - add ANY_RE here too!!!
229
+ )
230
+
231
+ PROP_ATTENDANCE_RE = Regexp.union(
232
+ ENCLOSED_NAME_RE, # e.g. (sold out) etc. why? why not?
233
+ PROP_NUM_RE, # e.g. 28 000 or 28_000 (NOT 28,000 is not valid!!!)
234
+ PROP_BASICS_RE,
235
+ ## todo/fix - add ANY_RE here too!!!
236
+ )
179
237
 
180
238
  end # class Lexer
181
239
  end # module SportDb
@@ -56,8 +56,12 @@ TEXT_RE = %r{
56
56
  \p{L}+
57
57
  |
58
58
  ## opt 3 - add weirdo case
59
+ ## e.g. 1/8 Finals 1/4 1/2 ...
60
+ 1/ \d{1,2} [ ] \p{L}+
61
+ |
62
+ ## opt 4 - add another weirdo case
59
63
  ## e.g. 5.-8. Platz Playoffs - keep - why? why not?
60
- \d+\.-\d+\. [ ]? \p{L}+
64
+ \d+\.-\d+\. [ ]? \p{L}+
61
65
  )
62
66
 
63
67
  (?:(?: (?:[ ]
@@ -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 = 6
7
- PATCH = 7
7
+ PATCH = 9
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.6.7
4
+ version: 0.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-01 00:00:00.000000000 Z
11
+ date: 2025-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos