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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b48a679900d31129e10a922ffa2bdea28bd919d6effe565e958d915cfc69a18
4
- data.tar.gz: '089b0cf75426611e738012751e446cc8b3e319027a6ed4f6872fe1d773467bac'
3
+ metadata.gz: cdf8bc6becd8ace3f8b616c8df1686e7905568b0080691c2d4dfbf20daa0741f
4
+ data.tar.gz: abbe9c9a47123a7488ced14991e1a7b3690db730d21ea8e86aa88832cc483350
5
5
  SHA512:
6
- metadata.gz: 677234ed2602b3b153713c58d4a398c3e73a72d48c19f83667c4fa0764331c8971db60f1091800380c146a10041e281b48df8299ac1d493604f5f5dfc59aebf9
7
- data.tar.gz: c66fb17fae6acf92fe4aa1177aa3758d8073b7e88f7e25de73942e275b8bf6652a1239fbcea7ee7221c87e87634b3f5d53c312edf97b637e358da3602b1494a7
6
+ metadata.gz: 11ca56e156063c9d42a36e451ce4ebc38f85e659a3a68efe0d620325bfe77b431dffcdeb888db48ded01b8253b3ba14955362d96f44f36a6d45b542ec885a515
7
+ data.tar.gz: e89f9960f7b9217ef8c9eb72a333a7171f0797444481a7113c3d6cfe34fd4b43b93e9fe019bdfd642707f41f03546f1e66e0e791bbcf838e5c863ee0e8ccc3f5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.7.0
1
+ ### 0.8.0
2
2
  ### 0.0.1 / 2024-08-27
3
3
 
4
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -3,7 +3,6 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  lib/sportdb/quick.rb
6
- lib/sportdb/quick/match_parser.rb
7
6
  lib/sportdb/quick/match_tree-helpers.rb
8
7
  lib/sportdb/quick/match_tree.rb
9
8
  lib/sportdb/quick/match_tree/goal.rb
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
- matches = SportDb::QuickMatchReader.read( path )
17
- pp matches
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
@@ -23,7 +23,7 @@ Hoe.spec 'sportdb-quick' do
23
23
  self.extra_deps = [
24
24
  ['sportdb-parser', '>= 0.7.0'],
25
25
  ['season-formats', '>= 0.1.0'],
26
- ['logutils', '>= 0.6.1'],
26
+ ## ['logutils', '>= 0.6.1'],
27
27
  ]
28
28
 
29
29
  self.spec_extras = {
@@ -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( printer )
51
- buf = String.new
52
- buf << "<Goal"
53
- buf << " #{@player} #{@minute}"
54
- buf << "+#{@offset}" if @offset && @offset > 0
55
- buf << "'"
56
- buf << " (og)" if @owngoal
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
- printer.text( buf )
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( printer )
14
- buf = String.new
15
- buf << "<Group #{@name} "
16
- buf << @teams.pretty_print_inspect
17
- buf << ">"
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
 
@@ -149,6 +149,8 @@ def as_json
149
149
 
150
150
 
151
151
  data['num'] = @num if @num
152
+
153
+
152
154
  if @date
153
155
  ## assume 2020-09-19 date format!!
154
156
  data['date'] = @date.is_a?( String ) ? @date : @date.strftime('%Y-%m-%d')
@@ -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( printer )
19
+ def pretty_print( q )
20
20
  ## todo/check - how to display/format key - use () or not - why? why not?
21
- buf = String.new
22
- buf << "<Round"
23
- buf << " AUTO" if @auto
24
- buf << ": "
25
- buf << "#{@name}, "
26
- buf << "#{@start_date}"
27
- buf << " - #{@end_date}" if @start_date != @end_date
28
- buf << ">"
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
- 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
-
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
- logger.debug( "on match (bye): >#{node}<" )
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
- logger.debug( "date header: >#{node}<")
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
- logger.debug( " date: #{date} with start: #{@start}")
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
- logger.debug( "!! hack - extending start date to full (next/end) year; assumes all dates are chronologigal - always moving forward" )
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
- logger.debug "on goal line: >#{node}<"
6
+ _trace( "on goal line: >#{node}<" )
7
7
 
8
- goals1 = node.goals1
9
- goals2 = node.goals2
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_group_def( node )
6
- logger.debug "on group def: >#{node}<"
6
+ _trace( "on group def: >#{node}<" )
7
7
 
8
8
  ## e.g
9
9
  ## [:group_def, "Group A"],
@@ -4,7 +4,7 @@ class MatchTree
4
4
 
5
5
 
6
6
  def on_match_line( node )
7
- logger.debug( "on match: >#{node}<" )
7
+ _trace( "on match: >#{node}<" )
8
8
 
9
9
  ## collect (possible) nodes by type
10
10
  num = nil
@@ -3,7 +3,7 @@ class MatchTree
3
3
 
4
4
 
5
5
  def on_round_def( node )
6
- logger.debug "on round def: >#{node}<"
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
- logger.debug " start_date: #{start_date}"
72
- logger.debug " end_date: #{end_date}"
73
- logger.debug " name: >#{name}<"
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
- logger.debug "on round outline: >#{node}<"
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
- logger.debug "on group header: >#{node}<"
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 SportDb
5
- class QuickMatchReader
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
- def initialize( txt )
26
- @errors = []
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
- @league_name = ''
30
- @matches = []
31
- end
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
- \b
51
- (?<season>\d{4}
52
- (?:[\/-]\d{1,4})? ## optional 2nd year in season
53
- )\b
54
- }x
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 parse
52
+ def _parse( txt, start: nil )
58
53
  ## note: every (new) read call - resets errors list to empty
59
- @errors = []
60
-
61
- @league_name = ''
62
- @matches = []
63
-
64
-
65
- ## note - source file MUST always start with heading 1 for now
66
- tree = []
67
- parser = RaccMatchParser.new( @txt, debug: debug? ) ## use own parser instance (not shared) - why? why not?
68
- tree = parser.parse
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
- ## try to get league and season
85
- @league_name = tree[0].text
86
- else
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 "!! (QUICK) PARSE ERROR - source MUST start with Heading1; got #{tree.size} nodes:"
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
- auto_conf_teams, matches, rounds, groups = conv.convert
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 ">>> #{auto_conf_teams.size} teams:"
120
- pp auto_conf_teams
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
- end # class QuickMatchReader
136
- end # module SportDb
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
@@ -3,7 +3,7 @@ module SportDb
3
3
  module Module
4
4
  module Quick
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 7
6
+ MINOR = 8
7
7
  PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
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.7.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-05-22 00:00:00.000000000 Z
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
-