sportdb-quick 0.5.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +1 -1
- data/Rakefile +1 -1
- data/lib/sportdb/quick/match_parser.rb +42 -69
- data/lib/sportdb/quick/quick_match_reader.rb +8 -0
- data/lib/sportdb/quick/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71f76e171de23b5062c30f432d5fece7bcb2cb0e7283d658dcf8ff79aefb6aa3
|
4
|
+
data.tar.gz: 74fc864d5c4b9ca42270abd3fdb941cebdb9857c072c7515e7e422829c018891
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83fa67d7c4bbd0952ad9e02f93be65c488bd728b52f8a9a1159ab42bd299b6b9b37ff5e75573582ef4a7f20ebef1d97ff7da111334dd5f6b4b71bf4793ea84af
|
7
|
+
data.tar.gz: 9f832375e9d03fe1de7d83d14083428d0f3eda704645cf585449d13cf7929030552075549d68e0d91892be0d66c4bf92fbc41a2403cecee362025ed2b2058513
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -9,7 +9,19 @@ class MatchParser ## simple match parser for team match schedules
|
|
9
9
|
|
10
10
|
include Logging ## e.g. logger#debug, logger#info, etc.
|
11
11
|
|
12
|
+
def log( msg )
|
13
|
+
## append msg to ./logs.txt
|
14
|
+
## use ./errors.txt - why? why not?
|
15
|
+
File.open( './logs.txt', 'a:utf-8' ) do |f|
|
16
|
+
f.write( msg )
|
17
|
+
f.write( "\n" )
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
12
21
|
|
22
|
+
|
23
|
+
|
24
|
+
|
13
25
|
def self.parse( lines, start: )
|
14
26
|
## todo/fix: add support for txt and lines
|
15
27
|
## check if lines_or_txt is an array or just a string
|
@@ -26,8 +38,8 @@ class MatchParser ## simple match parser for team match schedules
|
|
26
38
|
lines = []
|
27
39
|
txt.each_line do |line| ## preprocess
|
28
40
|
line = line.strip
|
29
|
-
|
30
41
|
next if line.empty? || line.start_with?('#') ### skip empty lines and comments
|
42
|
+
|
31
43
|
line = line.sub( /#.*/, '' ).strip ### cut-off end-of line comments too
|
32
44
|
lines << line
|
33
45
|
end
|
@@ -35,29 +47,7 @@ class MatchParser ## simple match parser for team match schedules
|
|
35
47
|
end
|
36
48
|
|
37
49
|
|
38
|
-
|
39
|
-
## make sure mon feb 12 18:10 will not match
|
40
|
-
## allow 1. FC Köln etc.
|
41
|
-
## Mainz 05:
|
42
|
-
## limit to 30 chars max
|
43
|
-
## only allow chars incl. intl buut (NOT ()[]/;)
|
44
|
-
##
|
45
|
-
## Group A:
|
46
|
-
## Group B: - remove colon
|
47
|
-
## or lookup first
|
48
|
-
|
49
|
-
ATTRIB_RE = %r{^
|
50
|
-
[ ]*? # slurp leading spaces
|
51
|
-
(?<key>[^:|\]\[()\/; -]
|
52
|
-
[^:|\]\[()\/;]{0,30}
|
53
|
-
)
|
54
|
-
[ ]*? # slurp trailing spaces
|
55
|
-
:[ ]+
|
56
|
-
(?<value>.+)
|
57
|
-
[ ]*? # slurp trailing spaces
|
58
|
-
$
|
59
|
-
}ix
|
60
|
-
|
50
|
+
|
61
51
|
#
|
62
52
|
# todo/fix: change start to start: too!!!
|
63
53
|
# might be optional in the future!! - why? why not?
|
@@ -99,41 +89,20 @@ class MatchParser ## simple match parser for team match schedules
|
|
99
89
|
|
100
90
|
@tree = []
|
101
91
|
|
102
|
-
attrib_found = false
|
103
|
-
|
104
|
-
|
105
|
-
lines = []
|
106
|
-
@lines.each_with_index do |line,i|
|
107
92
|
|
93
|
+
## flatten lines
|
94
|
+
txt = []
|
95
|
+
@lines.each_with_index do |line,i|
|
96
|
+
txt << line
|
97
|
+
txt << "\n"
|
98
|
+
end
|
99
|
+
txt = txt.join
|
100
|
+
|
108
101
|
if debug?
|
109
|
-
puts
|
110
|
-
|
102
|
+
puts "lines:"
|
103
|
+
pp txt
|
111
104
|
end
|
112
105
|
|
113
|
-
## skip new (experimental attrib syntax)
|
114
|
-
if attrib_found == false &&
|
115
|
-
ATTRIB_RE.match?( line )
|
116
|
-
## note: check attrib regex AFTER group def e.g.:
|
117
|
-
## Group A:
|
118
|
-
## Group B: etc.
|
119
|
-
## todo/fix - change Group A: to Group A etc.
|
120
|
-
## Group B: to Group B
|
121
|
-
attrib_found = true
|
122
|
-
## logger.debug "skipping key/value line - >#{line}<"
|
123
|
-
next
|
124
|
-
end
|
125
|
-
|
126
|
-
if attrib_found
|
127
|
-
## check if line ends with dot
|
128
|
-
## if not slurp up lines to the next do!!!
|
129
|
-
## logger.debug "skipping key/value line - >#{line}<"
|
130
|
-
attrib_found = false if line.end_with?( '.' )
|
131
|
-
# logger.debug "skipping key/value line (cont.) - >#{line}<"
|
132
|
-
next
|
133
|
-
end
|
134
|
-
|
135
|
-
lines << line
|
136
|
-
|
137
106
|
=begin
|
138
107
|
t, error_messages = @parser.parse_with_errors( line )
|
139
108
|
|
@@ -153,15 +122,11 @@ class MatchParser ## simple match parser for team match schedules
|
|
153
122
|
|
154
123
|
@tree << t
|
155
124
|
=end
|
156
|
-
end # each lines
|
157
125
|
|
158
|
-
txt = lines.join( "\n") + "\n"
|
159
126
|
parser = RaccMatchParser.new( txt ) ## use own parser instance (not shared) - why? why not?
|
160
127
|
@tree = parser.parse
|
161
128
|
## pp @tree
|
162
129
|
|
163
|
-
## pp @tree
|
164
|
-
|
165
130
|
## report parse errors here - why? why not?
|
166
131
|
|
167
132
|
|
@@ -188,9 +153,13 @@ class MatchParser ## simple match parser for team match schedules
|
|
188
153
|
on_goal_line( node )
|
189
154
|
else
|
190
155
|
## report error
|
191
|
-
|
156
|
+
msg = "!! WARN - unknown node (parse tree type) - #{node.class.name}"
|
157
|
+
puts msg
|
192
158
|
pp node
|
193
|
-
|
159
|
+
|
160
|
+
log( msg )
|
161
|
+
log( node.pretty_inspect )
|
162
|
+
## exit 1
|
194
163
|
end
|
195
164
|
end # tree.each
|
196
165
|
|
@@ -478,7 +447,8 @@ class GoalStruct
|
|
478
447
|
## note - there's no time (-only) type in ruby
|
479
448
|
## use string (e.g. '14:56', '1:44')
|
480
449
|
## use 01:44 or 1:44 ?
|
481
|
-
## check for 0:00 or 24:00 possible?
|
450
|
+
## check for 0:00 or 24:00 possible?
|
451
|
+
time = nil
|
482
452
|
time = ('%d:%02d' % [node.time[:h], node.time[:m]]) if node.time
|
483
453
|
|
484
454
|
|
@@ -497,17 +467,20 @@ class GoalStruct
|
|
497
467
|
score = Score.new( *values )
|
498
468
|
end
|
499
469
|
|
500
|
-
more = []
|
501
470
|
|
502
471
|
status = nil
|
472
|
+
status = node.status if node.status ### assume text for now
|
503
473
|
## if node_type == :status # e.g. awarded, canceled, postponed, etc.
|
504
474
|
## status = node[1]
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
##
|
509
|
-
|
510
|
-
|
475
|
+
#
|
476
|
+
## todo - add ## find (optional) match status e.g. [abandoned] or [replay] or [awarded]
|
477
|
+
## or [cancelled] or [postponed] etc.
|
478
|
+
## status = find_status!( line ) ## todo/check: allow match status also in geo part (e.g. after @) - why? why not?
|
479
|
+
|
480
|
+
|
481
|
+
###############
|
482
|
+
# add more for ground (and timezone!!!)
|
483
|
+
more = []
|
511
484
|
#
|
512
485
|
# elsif node_type == :'@' ||
|
513
486
|
# node_type == :',' ||
|
@@ -73,6 +73,14 @@ class QuickMatchReader
|
|
73
73
|
Date.new( season.start_year, 7, 1 )
|
74
74
|
end
|
75
75
|
|
76
|
+
# if debug?
|
77
|
+
# puts " (sec) lines:"
|
78
|
+
# pp lines
|
79
|
+
# end
|
80
|
+
|
81
|
+
### note - skip section if no lines !!!!!
|
82
|
+
next if lines.empty? ## or use lines.size == 0
|
83
|
+
|
76
84
|
|
77
85
|
parser = MatchParser.new( lines,
|
78
86
|
start ) ## note: keep season start_at date for now (no need for more specific stage date need for now)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-quick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.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: 2025-01-
|
11
|
+
date: 2025-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.
|
19
|
+
version: 0.5.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.5.
|
26
|
+
version: 0.5.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sportdb-structs
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|