sportdb-parser 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 810f7cacd444fa67848438b267081211851a2ab8ff8e2da633bdf9c885bf102b
4
- data.tar.gz: f15d3dc28d68c4d12737ace20fbc0f1110f1b0b864a96cf33950c6cb6b946a87
3
+ metadata.gz: 6c262398deab4e59ae7f57655a5ab67b03e4ad6290c66aa1b68f082448619c9c
4
+ data.tar.gz: 4c9b0c700f3bc472b27975cd1c4e7698eabf2e3965e0c1dbbed6feb4271103d6
5
5
  SHA512:
6
- metadata.gz: 7ccc2618cfb5400f869a18cb6fcbb5f1f7323515e439983c5ac65fe3c9fbd6a9bb53b501e3196cca01f00db921e1f08153854167d78fa0509da4cd2e99d7445a
7
- data.tar.gz: 92395315b0e90b501584b48dfbd1dea206c35e8cf91dae3d2a2357e6d18f8948e5fd5ee3b855c77dd5c201205e0592451cb149487b17315bc58733aa304e8897
6
+ metadata.gz: dbfeb90c1e8499e67c653bc313696cdafd18c8f56af2b752aa6466e3ea76515d45ac91433741ba106b0ced8a55178aff54b348bf37463a86ec81127b87bec58d
7
+ data.tar.gz: f98cb825168e198601b43a70e8e19173ddbec39a93f04f4d277d632dc5d8f45577190e3f780b88fe48c9d6c194e7e59c1caf67897aebcdaa8c9a6527e1bbc2c1
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.5.4
1
+ ### 0.5.5
2
2
  ### 0.0.1 / 2024-07-12
3
3
 
4
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -9,7 +9,6 @@ config/rounds_misc.txt
9
9
  config/rounds_pt.txt
10
10
  lib/sportdb/parser.rb
11
11
  lib/sportdb/parser/lang.rb
12
- lib/sportdb/parser/outline_reader.rb
13
12
  lib/sportdb/parser/parser.rb
14
13
  lib/sportdb/parser/token-date.rb
15
14
  lib/sportdb/parser/token-score.rb
data/Rakefile CHANGED
@@ -22,8 +22,7 @@ Hoe.spec 'sportdb-parser' do
22
22
 
23
23
  self.extra_deps = [
24
24
  ['cocos', '>= 0.4.0'],
25
- ['season-formats'],
26
- ['racc'],
25
+ ['racc'], ## maybe inline runtime later if possible - why? why not?
27
26
  ]
28
27
 
29
28
  self.spec_extras = {
@@ -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 = 5
7
- PATCH = 4
7
+ PATCH = 5
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -1,8 +1,5 @@
1
1
  ## pulls in
2
2
  require 'cocos'
3
- require 'season/formats' # e.g. Season() support machinery
4
-
5
-
6
3
 
7
4
 
8
5
  ####
@@ -30,12 +27,6 @@ require_relative 'parser/tokenizer'
30
27
  require_relative 'parser/parser'
31
28
 
32
29
 
33
- ####
34
- ## todo/check - move outline reader upstream to cocos - why? why not?
35
- ## use read_outline(), parse_outline() - why? why not?
36
- require_relative 'parser/outline_reader'
37
-
38
-
39
30
 
40
31
  ###
41
32
  # make parser api (easily) available - why? why not?
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.5.4
4
+ version: 0.5.5
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-18 00:00:00.000000000 Z
11
+ date: 2025-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.0
27
- - !ruby/object:Gem::Dependency
28
- name: season-formats
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: racc
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -111,7 +97,6 @@ files:
111
97
  - config/rounds_pt.txt
112
98
  - lib/sportdb/parser.rb
113
99
  - lib/sportdb/parser/lang.rb
114
- - lib/sportdb/parser/outline_reader.rb
115
100
  - lib/sportdb/parser/parser.rb
116
101
  - lib/sportdb/parser/token-date.rb
117
102
  - lib/sportdb/parser/token-score.rb
@@ -1,155 +0,0 @@
1
-
2
-
3
- module SportDb
4
-
5
- ###
6
- # add a simple Outline convenience class
7
- # for processing OUtlines with OUtlineReader
8
-
9
- class QuickMatchOutline
10
- def self.read( path )
11
- nodes = OutlineReader.read( path )
12
- new( nodes )
13
- end
14
-
15
- def initialize( nodes )
16
- @nodes = nodes
17
- end
18
-
19
- def each_para( &blk )
20
- ## note: every (new) read call - resets errors list to empty
21
- ### @errors = []
22
-
23
- ## process nodes
24
- h1 = nil
25
- h2 = nil
26
- orphans = 0 ## track paragraphs's with no heading
27
-
28
- @nodes.each do |node|
29
- type = node[0]
30
-
31
- if type == :h1
32
- h1 = node[1] ## get heading text
33
- puts " = Heading 1 >#{node[1]}<"
34
- elsif type == :h2
35
- if h1.nil?
36
- puts "!! WARN - no heading for subheading; skipping processing"
37
- next
38
- end
39
- h2 = node[1] ## get heading text
40
- puts " == Heading 2 >#{node[1]}<"
41
- elsif type == :p
42
- if h1.nil?
43
- orphans += 1 ## only warn once
44
- puts "!! WARN - no heading for #{orphans} text paragraph(s); skipping parse"
45
- next
46
- end
47
-
48
- lines = node[1]
49
- blk.call( lines )
50
- else
51
- pp node
52
- raise ArgumentError, "unsupported (node) type >#{type}<"
53
- end
54
- end # each node
55
- end # each_para
56
- alias_method :each_paragraph, :each_para
57
- alias_method :each_p, :each_para
58
- end # class QuickMatchOutline
59
-
60
-
61
-
62
-
63
- class OutlineReader
64
-
65
- def self.debug=(value) @@debug = value; end
66
- def self.debug?() @@debug ||= false; end
67
- def debug?() self.class.debug?; end
68
-
69
-
70
-
71
- def self.read( path ) ## use - rename to read_file or from_file etc. - why? why not?
72
- txt = File.open( path, 'r:utf-8' ) {|f| f.read }
73
- parse( txt )
74
- end
75
-
76
- def self.parse( txt )
77
- new( txt ).parse
78
- end
79
-
80
- def initialize( txt )
81
- @txt = txt
82
- end
83
-
84
- ## note: skip "decorative" only heading e.g. ========
85
- ## todo/check: find a better name e.g. HEADING_EMPTY_RE or HEADING_LINE_RE or ???
86
- HEADING_BLANK_RE = %r{\A
87
- ={1,}
88
- \z}x
89
-
90
- ## note: like in wikimedia markup (and markdown) all optional trailing ==== too
91
- HEADING_RE = %r{\A
92
- (?<marker>={1,}) ## 1. leading ======
93
- [ ]*
94
- (?<text>[^=]+) ## 2. text (note: for now no "inline" = allowed)
95
- [ ]*
96
- =* ## 3. (optional) trailing ====
97
- \z}x
98
-
99
- def parse
100
- outline=[] ## outline structure
101
- start_para = true ## start new para(graph) on new text line?
102
-
103
- @txt.each_line do |line|
104
- line = line.strip ## todo/fix: keep leading and trailing spaces - why? why not?
105
-
106
- if line.empty? ## todo/fix: keep blank line nodes?? and just remove comments and process headings?! - why? why not?
107
- start_para = true
108
- next
109
- end
110
-
111
- break if line == '__END__'
112
-
113
- next if line.start_with?( '#' ) ## skip comments too
114
- ## strip inline (until end-of-line) comments too
115
- ## e.g Eupen | KAS Eupen ## [de]
116
- ## => Eupen | KAS Eupen
117
- ## e.g bq Bonaire, BOE # CONCACAF
118
- ## => bq Bonaire, BOE
119
- line = line.sub( /#.*/, '' ).strip
120
- pp line if debug?
121
-
122
- ## todo/check: also use heading blank as paragraph "breaker" or treat it like a comment ?? - why? why not?
123
- next if HEADING_BLANK_RE.match( line ) # skip "decorative" only heading e.g. ========
124
-
125
- ## note: like in wikimedia markup (and markdown) all optional trailing ==== too
126
- if m=HEADING_RE.match( line )
127
- start_para = true
128
-
129
- heading_marker = m[:marker]
130
- heading_level = heading_marker.length ## count number of = for heading level
131
- heading = m[:text].strip
132
-
133
- puts "heading #{heading_level} >#{heading}<" if debug?
134
- outline << [:"h#{heading_level}", heading]
135
- else ## assume it's a (plain/regular) text line
136
- if start_para
137
- outline << [:p, [line]]
138
- start_para = false
139
- else
140
- node = outline[-1] ## get last entry
141
- if node[0] == :p ## assert it's a p(aragraph) node!!!
142
- node[1] << line ## add line to p(aragraph)
143
- else
144
- puts "!! ERROR - invalid outline state / format - expected p(aragraph) node; got:"
145
- pp node
146
- exit 1
147
- end
148
- end
149
- end
150
- end
151
- outline
152
- end # method read
153
- end # class OutlineReader
154
-
155
- end # module SportDb