sportdb-quick 0.7.0 → 0.8.0
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/Manifest.txt +0 -1
- data/README.md +4 -5
- data/Rakefile +1 -1
- data/lib/sportdb/quick/match_tree/goal.rb +11 -11
- data/lib/sportdb/quick/match_tree/group.rb +5 -7
- data/lib/sportdb/quick/match_tree/match.rb +2 -0
- data/lib/sportdb/quick/match_tree/round.rb +9 -11
- data/lib/sportdb/quick/match_tree.rb +3 -39
- data/lib/sportdb/quick/match_tree_on/on_date_header.rb +3 -3
- data/lib/sportdb/quick/match_tree_on/on_goal_line.rb +11 -3
- data/lib/sportdb/quick/match_tree_on/on_group_def.rb +1 -1
- data/lib/sportdb/quick/match_tree_on/on_match_line.rb +1 -1
- data/lib/sportdb/quick/match_tree_on/on_round_def.rb +4 -4
- data/lib/sportdb/quick/match_tree_on/on_round_outline.rb +2 -2
- data/lib/sportdb/quick/quick_match_reader.rb +81 -81
- data/lib/sportdb/quick/version.rb +1 -1
- data/lib/sportdb/quick.rb +0 -7
- metadata +2 -17
- data/lib/sportdb/quick/match_parser.rb +0 -76
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cdf8bc6becd8ace3f8b616c8df1686e7905568b0080691c2d4dfbf20daa0741f
|
|
4
|
+
data.tar.gz: abbe9c9a47123a7488ced14991e1a7b3690db730d21ea8e86aa88832cc483350
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11ca56e156063c9d42a36e451ce4ebc38f85e659a3a68efe0d620325bfe77b431dffcdeb888db48ded01b8253b3ba14955362d96f44f36a6d45b542ec885a515
|
|
7
|
+
data.tar.gz: e89f9960f7b9217ef8c9eb72a333a7171f0797444481a7113c3d6cfe34fd4b43b93e9fe019bdfd642707f41f03546f1e66e0e791bbcf838e5c863ee0e8ccc3f5
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
## Usage
|
|
7
8
|
|
|
8
9
|
|
|
@@ -13,12 +14,10 @@ require 'sportdb/quick'
|
|
|
13
14
|
# path = "./euro/2024--germany/euro.txt"
|
|
14
15
|
path = "./deutschland/2024-25/1-bundesliga.txt"
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
pp
|
|
17
|
+
doc = Fbtxt::Document.read( path )
|
|
18
|
+
pp doc
|
|
18
19
|
|
|
19
20
|
# try json for matches
|
|
20
|
-
data = matches.map {|match| match.as_json }
|
|
21
|
+
data = doc.matches.map {|match| match.as_json }
|
|
21
22
|
pp data
|
|
22
23
|
```
|
|
23
|
-
|
|
24
|
-
|
data/Rakefile
CHANGED
|
@@ -47,18 +47,18 @@ class Goal ### nested (non-freestanding) inside match (match is parent)
|
|
|
47
47
|
o.class == self.class && o.state == state
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def pretty_print(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
buf << " (p)" if @penalty
|
|
58
|
-
buf << " for #{@team}" ### team 1 or 2 - use home/away
|
|
59
|
-
buf << ">"
|
|
50
|
+
def pretty_print( q )
|
|
51
|
+
q.group( 4, '<Goal', '>') do ## group( indent, open, close)
|
|
52
|
+
buf = String.new
|
|
53
|
+
buf << " #{@player} #{@minute}"
|
|
54
|
+
buf << "+#{@offset}" if @offset && @offset > 0
|
|
55
|
+
buf << "'"
|
|
56
|
+
q.text( buf )
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
q.text( "(og)" ) if @owngoal
|
|
59
|
+
q.text( "(p)" ) if @penalty
|
|
60
|
+
q.text( " for #{@team}" ) ### team 1 or 2 - use home/away
|
|
61
|
+
end
|
|
62
62
|
end
|
|
63
63
|
end # class Goal
|
|
64
64
|
|
|
@@ -10,13 +10,11 @@ class Group
|
|
|
10
10
|
@teams = teams
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def pretty_print(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
printer.text( buf )
|
|
13
|
+
def pretty_print( q )
|
|
14
|
+
q.group( 4, '<Group', '>') do ## group( indent, open, close)
|
|
15
|
+
q.text( " #{@name} " )
|
|
16
|
+
q.pp( @teams )
|
|
17
|
+
end
|
|
20
18
|
end
|
|
21
19
|
end # class Group
|
|
22
20
|
|
|
@@ -16,18 +16,16 @@ class MatchTree
|
|
|
16
16
|
@auto = auto # auto-created (inline reference/header without proper definition before)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def pretty_print(
|
|
19
|
+
def pretty_print( q )
|
|
20
20
|
## todo/check - how to display/format key - use () or not - why? why not?
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
printer.text( buf )
|
|
21
|
+
q.group( 4, '<Round', '>') do ## group( indent, open, close)
|
|
22
|
+
q.text( " AUTO" ) if @auto
|
|
23
|
+
q.text( " #{@name}" )
|
|
24
|
+
if @start_date
|
|
25
|
+
q.text( " : #{@start_date}" )
|
|
26
|
+
q.text( " - #{@end_date}" ) if @start_date != @end_date
|
|
27
|
+
end
|
|
28
|
+
end
|
|
31
29
|
end
|
|
32
30
|
end # class Round
|
|
33
31
|
|
|
@@ -4,12 +4,7 @@ module SportDb
|
|
|
4
4
|
##############################
|
|
5
5
|
## simple (match) parse tree to structs walker/handler/converter
|
|
6
6
|
class MatchTree
|
|
7
|
-
|
|
8
|
-
def self.debug?() @@debug ||= false; end ## note: default is FALSE
|
|
9
|
-
def debug?() self.class.debug?; end
|
|
10
|
-
|
|
11
|
-
include Logging ## e.g. logger#debug, logger#info, etc.
|
|
12
|
-
|
|
7
|
+
include Debuggable
|
|
13
8
|
|
|
14
9
|
|
|
15
10
|
##
|
|
@@ -27,6 +22,7 @@ class MatchTree
|
|
|
27
22
|
def errors?() @errors.size > 0; end
|
|
28
23
|
|
|
29
24
|
|
|
25
|
+
|
|
30
26
|
def convert
|
|
31
27
|
## note: every (new) read call - resets errors list to empty
|
|
32
28
|
@errors = []
|
|
@@ -69,8 +65,6 @@ class MatchTree
|
|
|
69
65
|
on_date_header( node )
|
|
70
66
|
elsif node.is_a? RaccMatchParser::MatchLine
|
|
71
67
|
on_match_line( node )
|
|
72
|
-
elsif node.is_a? RaccMatchParser::MatchLineWalkover
|
|
73
|
-
on_match_line_walkover( node )
|
|
74
68
|
elsif node.is_a? RaccMatchParser::MatchLineBye
|
|
75
69
|
on_match_line_bye( node )
|
|
76
70
|
elsif node.is_a? RaccMatchParser::GoalLine
|
|
@@ -103,38 +97,8 @@ class MatchTree
|
|
|
103
97
|
|
|
104
98
|
|
|
105
99
|
|
|
106
|
-
def on_match_line_walkover( node )
|
|
107
|
-
logger.debug( "on match (w/o): >#{node}<" )
|
|
108
|
-
|
|
109
|
-
## note - w/o (walkover) records NO date/time or ground (or score etc.)
|
|
110
|
-
## for now only team1/team2 and match status!!
|
|
111
|
-
## plus inherited round/group
|
|
112
|
-
|
|
113
|
-
status = 'walkover' ## use w/o - why? why not?
|
|
114
|
-
|
|
115
|
-
team1 = node.team1
|
|
116
|
-
team2 = node.team2
|
|
117
|
-
|
|
118
|
-
@teams[ team1 ] += 1
|
|
119
|
-
@teams[ team2 ] += 1
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
group = nil
|
|
123
|
-
group = @last_group if @last_group
|
|
124
|
-
|
|
125
|
-
round = nil
|
|
126
|
-
round = @last_round if @last_round
|
|
127
|
-
|
|
128
|
-
@matches << Match.new( team1: team1, ## note: for now always use mapping value e.g. rec (NOT string e.g. team1.name)
|
|
129
|
-
team2: team2, ## note: for now always use mapping value e.g. rec (NOT string e.g. team2.name)
|
|
130
|
-
round: round ? round.name : nil, ## note: for now always use string (assume unique canonical name for event)
|
|
131
|
-
group: group ? group.name : nil, ## note: for now always use string (assume unique canonical name for event)
|
|
132
|
-
status: status )
|
|
133
|
-
### todo: cache team lookups in hash?
|
|
134
|
-
end
|
|
135
|
-
|
|
136
100
|
def on_match_line_bye( node )
|
|
137
|
-
|
|
101
|
+
_trace( "on match (bye): >#{node}<" )
|
|
138
102
|
|
|
139
103
|
## note - bye records NO date/time or ground (or score etc.)
|
|
140
104
|
## for now only team1/team2 and match status!!
|
|
@@ -5,7 +5,7 @@ class MatchTree
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def on_date_header( node )
|
|
8
|
-
|
|
8
|
+
_trace( "date header: >#{node}<")
|
|
9
9
|
|
|
10
10
|
date = _build_date( m: node.date[:m],
|
|
11
11
|
d: node.date[:d],
|
|
@@ -15,7 +15,7 @@ class MatchTree
|
|
|
15
15
|
start: @start,
|
|
16
16
|
last_year: true )
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
_trace( " date: #{date} with start: #{@start}")
|
|
19
19
|
|
|
20
20
|
@last_date = date # keep a reference for later use
|
|
21
21
|
@last_time = nil
|
|
@@ -31,7 +31,7 @@ class MatchTree
|
|
|
31
31
|
=begin
|
|
32
32
|
if @start.month != 1
|
|
33
33
|
if date.year == @start.year+1
|
|
34
|
-
|
|
34
|
+
_trace( "!! hack - extending start date to full (next/end) year; assumes all dates are chronologigal - always moving forward" )
|
|
35
35
|
@start_org = @start ## keep a copy of the original (old) start date - why? why not? - not used for now
|
|
36
36
|
@start = Date.new( @start.year+1, 1, 1 )
|
|
37
37
|
end
|
|
@@ -3,10 +3,15 @@ class MatchTree
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def on_goal_line( node )
|
|
6
|
-
|
|
6
|
+
_trace( "on goal line: >#{node}<" )
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
if node.goals[0].is_a?( Array )
|
|
10
|
+
goals1, goals2 = node.goals[0], node.goals[1]
|
|
11
|
+
else
|
|
12
|
+
goals1 = node.goals
|
|
13
|
+
goals2 = []
|
|
14
|
+
end
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
pp [goals1,goals2] if debug?
|
|
@@ -38,6 +43,9 @@ class MatchTree
|
|
|
38
43
|
|
|
39
44
|
|
|
40
45
|
|
|
46
|
+
##
|
|
47
|
+
## todo/fix - sort goals by minute (+offset) !!!
|
|
48
|
+
|
|
41
49
|
goals = []
|
|
42
50
|
|
|
43
51
|
goals1.each do |rec|
|
|
@@ -3,7 +3,7 @@ class MatchTree
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
def on_round_def( node )
|
|
6
|
-
|
|
6
|
+
_trace( "on round def: >#{node}<" )
|
|
7
7
|
|
|
8
8
|
## e.g. [[:round_def, "Matchday 1"], [:duration, "Fri Jun 14 - Tue Jun 18"]]
|
|
9
9
|
## [[:round_def, "Matchday 2"], [:duration, "Wed Jun 19 - Sat Jun 22"]]
|
|
@@ -68,9 +68,9 @@ class MatchTree
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
_trace( " start_date: #{start_date}" )
|
|
72
|
+
_trace( " end_date: #{end_date}" )
|
|
73
|
+
_trace( " name: >#{name}<" )
|
|
74
74
|
|
|
75
75
|
round = Round.new( name: name,
|
|
76
76
|
start_date: start_date,
|
|
@@ -4,7 +4,7 @@ class MatchTree
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def on_round_outline( node )
|
|
7
|
-
|
|
7
|
+
_trace( "on round outline: >#{node}<" )
|
|
8
8
|
|
|
9
9
|
## always reset dates - why? why not?
|
|
10
10
|
## note - needs last_date for year
|
|
@@ -20,7 +20,7 @@ class MatchTree
|
|
|
20
20
|
## todo/fix - use only names from group def for lookup/is_group match!!!
|
|
21
21
|
## do NOT use (generic) regex!!
|
|
22
22
|
if level == 1 && _is_group?( name )
|
|
23
|
-
|
|
23
|
+
_trace( "on group header: >#{node}<" )
|
|
24
24
|
|
|
25
25
|
group = @groups[ name ]
|
|
26
26
|
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
#####
|
|
2
|
-
## quick match reader for datafiles with league outlines
|
|
3
1
|
|
|
4
|
-
module
|
|
5
|
-
class
|
|
2
|
+
module Fbtxt
|
|
3
|
+
class Document
|
|
4
|
+
include Debuggable
|
|
6
5
|
|
|
7
|
-
def self.debug=(value) @@debug = value; end
|
|
8
|
-
def self.debug?() @@debug ||= false; end ## note: default is FALSE
|
|
9
|
-
def debug?() self.class.debug?; end
|
|
10
6
|
|
|
7
|
+
def self.read( path )
|
|
8
|
+
## note - use read_text from cocos - why? why not?
|
|
9
|
+
txt = read_text( path )
|
|
10
|
+
parse( txt )
|
|
11
|
+
end
|
|
11
12
|
|
|
13
|
+
def self.parse( txt )
|
|
14
|
+
new( txt )
|
|
15
|
+
end
|
|
12
16
|
|
|
13
|
-
def self.read( path ) ## use - rename to read_file or from_file etc. - why? why not?
|
|
14
|
-
txt = File.open( path, 'r:utf-8' ) {|f| f.read }
|
|
15
|
-
parse( txt )
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.parse( txt )
|
|
19
|
-
new( txt ).parse
|
|
20
|
-
end
|
|
21
17
|
|
|
22
18
|
|
|
23
|
-
include Logging
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@txt = txt
|
|
20
|
+
attr_reader :title ## e.g. league name (England | Premier League 2026/27) or such
|
|
21
|
+
attr_reader :matches
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
attr_reader :teams
|
|
24
|
+
attr_reader :groups
|
|
25
|
+
attr_reader :rounds
|
|
32
26
|
|
|
33
27
|
attr_reader :errors
|
|
34
28
|
def errors?() @errors.size > 0; end
|
|
35
29
|
|
|
30
|
+
##
|
|
31
|
+
## keep/store a reference to (source) txt - why? why not?
|
|
32
|
+
def initialize( txt, start: nil )
|
|
33
|
+
_parse( txt, start: start )
|
|
34
|
+
end
|
|
35
|
+
|
|
36
36
|
|
|
37
|
-
###
|
|
38
|
-
# helpers get matches & more after parse; all stored in data
|
|
39
|
-
#
|
|
40
|
-
## change/rename to event - why? why not?
|
|
41
|
-
## note - may or may not include season
|
|
42
|
-
def league_name() @league_name; end
|
|
43
|
-
def matches() @matches; end
|
|
44
|
-
|
|
45
37
|
|
|
46
38
|
## try to find season in heading
|
|
47
39
|
## e.g. Österr. Bundesliga 2015/16 or 2015-16
|
|
48
40
|
## World Cup 2018 or 2018 World Cup etc.
|
|
49
41
|
SEASON_IN_HEADING_RE = %r{
|
|
50
|
-
|
|
51
|
-
(?<season
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
\b
|
|
43
|
+
(?<season>
|
|
44
|
+
\d{4}
|
|
45
|
+
(?: [\/-]
|
|
46
|
+
\d{1,4} )? ## optional 2nd year in season
|
|
47
|
+
)
|
|
48
|
+
\b
|
|
49
|
+
}x
|
|
55
50
|
|
|
56
51
|
|
|
57
|
-
def
|
|
52
|
+
def _parse( txt, start: nil )
|
|
58
53
|
## note: every (new) read call - resets errors list to empty
|
|
59
|
-
@
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
@
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
@title = nil ## or use '? or use '' - why? why not?
|
|
55
|
+
@matches = []
|
|
56
|
+
|
|
57
|
+
@teams = []
|
|
58
|
+
@groups = []
|
|
59
|
+
@rounds = []
|
|
60
|
+
|
|
61
|
+
@errors = []
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
parser = SportDb::Parser.new( txt ) ## use own parser instance (not shared) - why? why not?
|
|
65
|
+
tree, errors = parser.parse_with_errors
|
|
66
|
+
|
|
67
|
+
@errors = errors
|
|
68
|
+
|
|
69
|
+
## note - source file MUST always start with heading 1 for now
|
|
70
|
+
|
|
71
71
|
##
|
|
72
72
|
## !! (QUICK) PARSE ERROR - source MUST start with Heading1; got 34 nodes:
|
|
73
73
|
## [<BlankLine>,
|
|
@@ -76,62 +76,62 @@ class QuickMatchReader
|
|
|
76
76
|
|
|
77
77
|
## remove leading BlankLines if any!!
|
|
78
78
|
while tree[0].is_a? RaccMatchParser::BlankLine
|
|
79
|
-
tree.shift ## remove (leading) blank line from parse tree
|
|
79
|
+
tree.shift ## remove (leading) blank line from parse tree
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
|
|
83
|
+
## try to get league and season
|
|
83
84
|
if tree[0].is_a? RaccMatchParser::Heading1
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
@title = tree[0].text
|
|
86
|
+
|
|
87
|
+
if (m = SEASON_IN_HEADING_RE.match( @title ))
|
|
88
|
+
season = Season.parse( m[:season] ) ## convert (str) to season obj!!!
|
|
89
|
+
start = if season.year?
|
|
90
|
+
Date.new( season.start_year, 1, 1 )
|
|
91
|
+
else
|
|
92
|
+
Date.new( season.start_year, 7, 1 )
|
|
93
|
+
end
|
|
94
|
+
else
|
|
95
|
+
puts "!! (DOCUMENT) WARN - no season found in Heading1 >#{@title}<"
|
|
96
|
+
end
|
|
97
|
+
else
|
|
87
98
|
### report error - source MUST start with heading 1
|
|
88
|
-
puts "!! (
|
|
99
|
+
puts "!! (DOCUMENT) WARN - source SHOULD start with Heading1; got #{tree.size} nodes:"
|
|
89
100
|
pp tree
|
|
90
|
-
exit
|
|
91
101
|
end
|
|
92
102
|
|
|
93
|
-
## todo/fix
|
|
94
|
-
## make season optional
|
|
95
|
-
m = SEASON_IN_HEADING_RE.match( @league_name )
|
|
96
|
-
if m.nil?
|
|
97
|
-
puts "!! (QUICK) PARSE ERROR - no season found in Heading1 >#{@league_name}; sorry"
|
|
98
|
-
exit
|
|
99
|
-
end
|
|
100
|
-
season = Season.parse( m[:season] ) ## convert (str) to season obj!!!
|
|
101
|
-
start = if season.year?
|
|
102
|
-
Date.new( season.start_year, 1, 1 )
|
|
103
|
-
else
|
|
104
|
-
Date.new( season.start_year, 7, 1 )
|
|
105
|
-
end
|
|
106
103
|
|
|
107
104
|
|
|
108
105
|
############
|
|
109
106
|
### "walk" tree to get structs (matches/teams/etc.)
|
|
110
|
-
conv = MatchTree.new( tree, start: start )
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
conv = SportDb::MatchTree.new( tree, start: start )
|
|
108
|
+
|
|
109
|
+
teams, matches, rounds, groups = conv.convert
|
|
113
110
|
|
|
114
111
|
|
|
115
112
|
## auto-add "upstream" errors from parser
|
|
116
113
|
## @errors += parser.errors if parser.errors?
|
|
117
114
|
|
|
118
115
|
if debug?
|
|
119
|
-
puts ">>> #{
|
|
120
|
-
pp
|
|
121
|
-
puts ">>> #{matches.size} matches:"
|
|
122
|
-
## pp matches
|
|
123
|
-
puts ">>> #{rounds.size} rounds:"
|
|
124
|
-
pp rounds
|
|
116
|
+
puts ">>> #{teams.size} teams:"
|
|
117
|
+
pp teams
|
|
125
118
|
puts ">>> #{groups.size} groups:"
|
|
126
119
|
pp groups
|
|
120
|
+
puts ">>> #{rounds.size} rounds:"
|
|
121
|
+
pp rounds
|
|
122
|
+
puts ">>> #{matches.size} matches:"
|
|
123
|
+
## pp matches
|
|
127
124
|
end
|
|
128
125
|
|
|
129
126
|
|
|
130
127
|
@matches = matches
|
|
131
|
-
## note - skip teams, rounds, and groups for now
|
|
132
|
-
@matches
|
|
133
|
-
end # method parse
|
|
134
128
|
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
@teams = teams
|
|
130
|
+
@groups = groups
|
|
131
|
+
@rounds = rounds
|
|
132
|
+
|
|
133
|
+
self
|
|
134
|
+
end # method _parse
|
|
137
135
|
|
|
136
|
+
end # class Document
|
|
137
|
+
end # module Fbtxt
|
data/lib/sportdb/quick.rb
CHANGED
|
@@ -4,12 +4,6 @@ require 'season-formats'
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
require 'logutils'
|
|
8
|
-
module SportDb
|
|
9
|
-
## logging machinery shortcut; use LogUtils for now
|
|
10
|
-
Logging = LogUtils::Logging
|
|
11
|
-
end
|
|
12
|
-
|
|
13
7
|
|
|
14
8
|
|
|
15
9
|
## our own code
|
|
@@ -32,7 +26,6 @@ require_relative 'quick/match_tree_on/on_match_line'
|
|
|
32
26
|
require_relative 'quick/match_tree_on/on_goal_line'
|
|
33
27
|
|
|
34
28
|
|
|
35
|
-
require_relative 'quick/match_parser'
|
|
36
29
|
require_relative 'quick/quick_match_reader'
|
|
37
30
|
|
|
38
31
|
|
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.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gerald Bauer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sportdb-parser
|
|
@@ -38,20 +38,6 @@ dependencies:
|
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 0.1.0
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: logutils
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.6.1
|
|
48
|
-
type: :runtime
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.6.1
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
42
|
name: rdoc
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,7 +86,6 @@ files:
|
|
|
100
86
|
- README.md
|
|
101
87
|
- Rakefile
|
|
102
88
|
- lib/sportdb/quick.rb
|
|
103
|
-
- lib/sportdb/quick/match_parser.rb
|
|
104
89
|
- lib/sportdb/quick/match_tree-helpers.rb
|
|
105
90
|
- lib/sportdb/quick/match_tree.rb
|
|
106
91
|
- lib/sportdb/quick/match_tree/goal.rb
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
module SportDb
|
|
2
|
-
|
|
3
|
-
class MatchParser ## simple match parser for team match schedules
|
|
4
|
-
|
|
5
|
-
def self.debug=(value) @@debug = value; end
|
|
6
|
-
def self.debug?() @@debug ||= false; end ## note: default is FALSE
|
|
7
|
-
def debug?() self.class.debug?; end
|
|
8
|
-
|
|
9
|
-
include Logging ## e.g. logger#debug, logger#info, etc.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def self.parse( txt, start: )
|
|
14
|
-
## todo/check - add teams: option like start: why? why not?
|
|
15
|
-
parser = new( txt, start: start )
|
|
16
|
-
parser.parse
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def initialize( txt, start: )
|
|
20
|
-
@txt = txt
|
|
21
|
-
@start = start
|
|
22
|
-
|
|
23
|
-
@errors = []
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
attr_reader :errors
|
|
28
|
-
def errors?() @errors.size > 0; end
|
|
29
|
-
|
|
30
|
-
def parse
|
|
31
|
-
## note: every (new) read call - resets errors list to empty
|
|
32
|
-
@errors = []
|
|
33
|
-
@warns = [] ## track list of warnings (unmatched lines) too - why? why not?
|
|
34
|
-
|
|
35
|
-
if debug?
|
|
36
|
-
puts "lines:"
|
|
37
|
-
pp @txt
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
=begin
|
|
41
|
-
t, error_messages = @parser.parse_with_errors( line )
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if error_messages.size > 0
|
|
45
|
-
## add to "global" error list
|
|
46
|
-
## make a triplet tuple (file / msg / line text)
|
|
47
|
-
error_messages.each do |msg|
|
|
48
|
-
@errors << [ '<file>', ## add filename here
|
|
49
|
-
msg,
|
|
50
|
-
line
|
|
51
|
-
]
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
pp t if debug?
|
|
56
|
-
|
|
57
|
-
@tree << t
|
|
58
|
-
=end
|
|
59
|
-
|
|
60
|
-
parser = RaccMatchParser.new( @txt ) ## use own parser instance (not shared) - why? why not?
|
|
61
|
-
tree = parser.parse
|
|
62
|
-
## pp @tree
|
|
63
|
-
|
|
64
|
-
## report parse errors here - why? why not?
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
## note - team keys are names and values are "internal" stats e.g. usage count!!
|
|
69
|
-
## and NOT team/club/nat_team structs!!
|
|
70
|
-
## returns [@teams.keys, @matches, @rounds.values, @groups.values]
|
|
71
|
-
conv = MatchTree.new( tree, start: @start )
|
|
72
|
-
conv.convert
|
|
73
|
-
end # method parse
|
|
74
|
-
end # class MatchParser
|
|
75
|
-
end # module SportDb
|
|
76
|
-
|