sportdb-parser 0.6.7 → 0.6.8

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,32 @@ RefereeLine = Struct.new( :name, :country ) do
13
13
  end
14
14
  end
15
15
 
16
+
17
+ PenaltiesLine = Struct.new( :penalties ) do
18
+ def pretty_print( printer )
19
+ printer.text( "<PenaltiesLine " )
20
+ printer.text( self.penalties.pretty_inspect )
21
+ printer.text( ">" )
22
+ end
23
+ end
24
+
25
+ Penalty = Struct.new( :name, :score, :note ) do
26
+ def to_s
27
+ buf = String.new
28
+ buf << "#{self.score} " if self.score
29
+ buf << self.name
30
+ buf << " (#{self.note})" if self.note
31
+ buf
32
+ end
33
+
34
+ def pretty_print( printer )
35
+ printer.text( to_s )
36
+ end
37
+ end
38
+
39
+
40
+
41
+
16
42
  ## find a better name for player (use bookings?) - note - red/yellow card for trainer possible
17
43
  CardsLine = Struct.new( :type, :bookings ) do
18
44
  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,23 @@ PROP_NAME_RE = %r{
148
148
  )
149
149
  }ix
150
150
 
151
+
152
+ ### todo/fix - allow more chars in enclosed name - why? why not?
153
+ ## e.g. (') - Cote D'Ivore etc.
154
+ ENCLOSED_NAME_RE = %r{
155
+ (?<enclosed_name>
156
+ \(
157
+ (?<name>
158
+ \p{L}+
159
+ (?:
160
+ [ ]
161
+ \p{L}+
162
+ )*
163
+ )
164
+ \)
165
+ )
166
+ }ix
167
+
151
168
 
152
169
 
153
170
  PROP_BASICS_RE = %r{
@@ -160,22 +177,32 @@ PROP_BASICS_RE = %r{
160
177
  }ix
161
178
 
162
179
  PROP_RE = Regexp.union(
163
- PROP_BASICS_RE,
164
180
  MINUTE_RE,
165
181
  PROP_KEY_INLINE_RE,
166
182
  PROP_NAME_RE,
183
+ PROP_BASICS_RE,
167
184
  ## todo/fix - add ANY_RE here too!!!
168
185
  )
169
186
 
170
187
  ## note - no inline keys possible
171
188
  ## todo/fix - use custom (limited) prop basics too
172
189
  PROP_CARDS_RE = Regexp.union(
173
- PROP_BASICS_RE,
174
190
  MINUTE_RE,
175
191
  PROP_NAME_RE,
192
+ PROP_BASICS_RE,
176
193
  ## todo/fix - add ANY_RE here too!!!
177
194
  )
178
195
 
196
+
197
+ PROP_PENALTIES_RE = Regexp.union(
198
+ SCORE_RE, # e.g. 1-1 etc.
199
+ ENCLOSED_NAME_RE, # e.g. (save), (post), etc.
200
+ PROP_NAME_RE,
201
+ PROP_BASICS_RE,
202
+ ## todo/fix - add ANY_RE here too!!!
203
+ )
204
+
205
+
179
206
 
180
207
  end # class Lexer
181
208
  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 = 8
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
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.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer