fbtok 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/fbtok/fbquick.rb +9 -1
- data/lib/fbtok/fbtok.rb +13 -6
- data/lib/fbtok/fbtree.rb +27 -9
- data/lib/fbtok/pathspec.rb +61 -33
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6bb0384d86033771326222bc9284264b9bfc44c55210261e6b598fffb3ddf925
|
|
4
|
+
data.tar.gz: a7692e7b0f394373c364234ec7b7c57933d6bd1344b58d4139beb41381a59921
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 854430fe426e69eb27651930db928cb24bf7f4b489503a222f7ff67178fb087b465718e71cc4a9421a591ab87c784e35f2a26514c99de9151ddb9a1a13c4ec53
|
|
7
|
+
data.tar.gz: e602fe075cfbd20eeed1e744f4bdfa35314f2e42db69537cb8ff14ccc87b8fed50400d5f3aa53974e342a0b09c00b7110e0614e0d06ede5595c19e6e652de63d
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/lib/fbtok/fbquick.rb
CHANGED
|
@@ -67,7 +67,14 @@ specs = if opts[:file]
|
|
|
67
67
|
nil
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
path = SportDb::Pathspec.path(
|
|
71
|
+
['/sports/sportdb/sport.db.v2/parser/fbtxt-specs',
|
|
72
|
+
'/sports/sportdb/sport.db.v2/parser/fbtxt-samples',
|
|
73
|
+
'/sports/openfootball'])
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
build_pathspecs( args, path: path,
|
|
77
|
+
filepack: filepack )
|
|
71
78
|
end
|
|
72
79
|
|
|
73
80
|
pp specs
|
|
@@ -101,6 +108,7 @@ pp specs
|
|
|
101
108
|
pp errors
|
|
102
109
|
else
|
|
103
110
|
puts
|
|
111
|
+
pp datafiles
|
|
104
112
|
puts " OK - no parse errors in #{datafiles.size} datafile(s)"
|
|
105
113
|
end
|
|
106
114
|
|
data/lib/fbtok/fbtok.rb
CHANGED
|
@@ -6,8 +6,8 @@ def self.main( args=ARGV )
|
|
|
6
6
|
|
|
7
7
|
opts = {
|
|
8
8
|
debug: true,
|
|
9
|
-
warn: false,
|
|
10
9
|
file: nil,
|
|
10
|
+
# warn: false,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
@@ -23,10 +23,10 @@ parser = OptionParser.new do |parser|
|
|
|
23
23
|
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
|
24
24
|
opts[:debug] = true
|
|
25
25
|
end
|
|
26
|
-
parser.on( "-w", "--warn",
|
|
27
|
-
"turn warnings into errors (default: #{opts[:warn]})" ) do |warn|
|
|
28
|
-
opts[:warn] = true
|
|
29
|
-
end
|
|
26
|
+
# parser.on( "-w", "--warn",
|
|
27
|
+
# "turn warnings into errors (default: #{opts[:warn]})" ) do |warn|
|
|
28
|
+
# opts[:warn] = true
|
|
29
|
+
# end
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
parser.on( "-f FILE", "--file FILE",
|
|
@@ -65,7 +65,13 @@ specs = if opts[:file]
|
|
|
65
65
|
nil
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
path = SportDb::Pathspec.path(
|
|
69
|
+
['/sports/sportdb/sport.db.v2/parser/fbtxt-specs',
|
|
70
|
+
'/sports/sportdb/sport.db.v2/parser/fbtxt-samples',
|
|
71
|
+
'/sports/openfootball'])
|
|
72
|
+
|
|
73
|
+
build_pathspecs( args, path: path,
|
|
74
|
+
filepack: filepack )
|
|
69
75
|
end
|
|
70
76
|
|
|
71
77
|
|
|
@@ -109,6 +115,7 @@ specs.each_with_index do |rec,i|
|
|
|
109
115
|
puts "!! #{errors.size} tokenize error(s) in #{datafiles.size} datafiles(s)"
|
|
110
116
|
else
|
|
111
117
|
puts
|
|
118
|
+
pp datafiles
|
|
112
119
|
puts "OK no tokenize errors found in #{datafiles.size} datafile(s)"
|
|
113
120
|
end
|
|
114
121
|
|
data/lib/fbtok/fbtree.rb
CHANGED
|
@@ -6,8 +6,8 @@ def self.main( args=ARGV )
|
|
|
6
6
|
|
|
7
7
|
opts = {
|
|
8
8
|
debug: true,
|
|
9
|
-
warn: false,
|
|
10
9
|
file: nil,
|
|
10
|
+
## warn: false,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
parser = OptionParser.new do |parser|
|
|
@@ -22,10 +22,10 @@ parser = OptionParser.new do |parser|
|
|
|
22
22
|
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
|
23
23
|
opts[:debug] = true
|
|
24
24
|
end
|
|
25
|
-
parser.on( "-w", "--warn",
|
|
26
|
-
"turn warnings into errors (default: #{opts[:warn]})" ) do |warn|
|
|
27
|
-
opts[:warn] = true
|
|
28
|
-
end
|
|
25
|
+
# parser.on( "-w", "--warn",
|
|
26
|
+
# "turn warnings into errors (default: #{opts[:warn]})" ) do |warn|
|
|
27
|
+
# opts[:warn] = true
|
|
28
|
+
# end
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
parser.on( "-f FILE", "--file FILE",
|
|
@@ -38,7 +38,6 @@ parser = OptionParser.new do |parser|
|
|
|
38
38
|
end
|
|
39
39
|
parser.parse!( args )
|
|
40
40
|
|
|
41
|
-
|
|
42
41
|
if opts[:debug]
|
|
43
42
|
puts "OPTS:"
|
|
44
43
|
p opts
|
|
@@ -47,8 +46,6 @@ if opts[:debug]
|
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
|
|
50
|
-
# SportDb::Parser::Linter.debug = opts[:debug]
|
|
51
|
-
# SportDb::Parser::Linter.warn = opts[:warn]
|
|
52
49
|
|
|
53
50
|
|
|
54
51
|
|
|
@@ -65,10 +62,30 @@ specs = if opts[:file]
|
|
|
65
62
|
nil
|
|
66
63
|
end
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
path = SportDb::Pathspec.path(
|
|
66
|
+
['/sports/sportdb/sport.db.v2/parser/fbtxt-specs',
|
|
67
|
+
'/sports/sportdb/sport.db.v2/parser/fbtxt-samples',
|
|
68
|
+
'/sports/openfootball'])
|
|
69
|
+
|
|
70
|
+
build_pathspecs( args, path: path,
|
|
71
|
+
filepack: filepack )
|
|
69
72
|
end
|
|
70
73
|
|
|
71
74
|
|
|
75
|
+
pp specs
|
|
76
|
+
|
|
77
|
+
## if more than single datafile
|
|
78
|
+
## auto-switch into quite mode for now
|
|
79
|
+
## if specs.size > 0 && specs[0]['datafiles'].size > 1
|
|
80
|
+
## opts[:debug] = false
|
|
81
|
+
## end
|
|
82
|
+
|
|
83
|
+
# SportDb::Parser::Linter.debug = opts[:debug]
|
|
84
|
+
# SportDb::Parser::Linter.warn = opts[:warn]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
72
89
|
|
|
73
90
|
|
|
74
91
|
specs.each_with_index do |rec,i|
|
|
@@ -103,6 +120,7 @@ specs.each_with_index do |rec,i|
|
|
|
103
120
|
puts "!! #{errors.size} parse error(s) in #{datafiles.size} datafiles(s)"
|
|
104
121
|
else
|
|
105
122
|
puts
|
|
123
|
+
pp datafiles
|
|
106
124
|
puts "OK no parse errors found in #{datafiles.size} datafile(s)"
|
|
107
125
|
end
|
|
108
126
|
|
data/lib/fbtok/pathspec.rb
CHANGED
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
module SportDb
|
|
4
4
|
class Pathspec
|
|
5
5
|
|
|
6
|
-
def self.debug=(value) @@debug = value; end
|
|
7
|
-
def self.debug?() @@debug ||= false; end ## note: default is FALSE
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
6
|
SEASON_RE = %r{ (?:
|
|
12
7
|
(?<season>\d{4}-\d{2})
|
|
13
8
|
| (?<season>\d{4})
|
|
@@ -71,7 +66,7 @@ class Pathspec
|
|
|
71
66
|
## that will use generic **/*.txt and only use ignore filter!!!
|
|
72
67
|
|
|
73
68
|
|
|
74
|
-
def self.
|
|
69
|
+
def self.find( path, seasons: nil )
|
|
75
70
|
##
|
|
76
71
|
## note - only if seasons filter is turn on
|
|
77
72
|
## MATCH_RE gets used!!!
|
|
@@ -85,11 +80,11 @@ def self._find( path, seasons: nil )
|
|
|
85
80
|
|
|
86
81
|
## note: normalize path - use File.expand_path ??
|
|
87
82
|
## change all backslash to slash for now
|
|
88
|
-
## path = path.gsub( "\\", '/' )
|
|
89
83
|
fullpath = File.expand_path( path )
|
|
90
84
|
|
|
91
85
|
####
|
|
92
86
|
## note - make sure path exists; raise error if not
|
|
87
|
+
## ENOENT => Error No Entity
|
|
93
88
|
raise Errno::ENOENT, "No such directory - #{path})" unless Dir.exist?( fullpath )
|
|
94
89
|
|
|
95
90
|
|
|
@@ -150,15 +145,33 @@ def self._find( path, seasons: nil )
|
|
|
150
145
|
end
|
|
151
146
|
|
|
152
147
|
|
|
148
|
+
def self.path( default=[])
|
|
149
|
+
## check for FBPATH
|
|
150
|
+
## or FBTXT_PATH
|
|
151
|
+
path = ENV['FBPATH'] || ENV['FBTXT_PATH']
|
|
152
|
+
if path
|
|
153
|
+
path.split( /[:;]/)
|
|
154
|
+
else
|
|
155
|
+
default
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end # class Pathspec
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class Pathspecs ## change to a module - why? why not?
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def self.debug=(value) @@debug = value; end
|
|
168
|
+
def self.debug?() @@debug ||= false; end ## note: default is FALSE
|
|
153
169
|
|
|
154
170
|
|
|
155
|
-
##
|
|
156
|
-
## rename/change to read_csv - why? why not?
|
|
157
171
|
def self.read( src )
|
|
158
|
-
## note: normalize
|
|
159
|
-
## change all backslash to slash for now
|
|
160
|
-
|
|
161
|
-
fullsrc = File.expand_path( scr )
|
|
172
|
+
## note: normalize src - use File.expand_path ??
|
|
173
|
+
## change all backslash to slash for now (\ to /)
|
|
174
|
+
fullsrc = File.expand_path( src )
|
|
162
175
|
|
|
163
176
|
recs = read_csv( fullsrc )
|
|
164
177
|
pp recs if debug?
|
|
@@ -167,11 +180,13 @@ def self.read( src )
|
|
|
167
180
|
basedir = File.dirname( fullsrc )
|
|
168
181
|
|
|
169
182
|
recs.each do |rec|
|
|
183
|
+
##
|
|
184
|
+
## todo/check - check for season/seasons column - why? why not?
|
|
170
185
|
path = rec['path']
|
|
171
186
|
fullpath = File.expand_path( path, basedir )
|
|
172
|
-
datafiles =
|
|
187
|
+
datafiles = Pathspec.find( fullpath )
|
|
173
188
|
|
|
174
|
-
## add (new) datafiles column (from expanded pathspec)
|
|
189
|
+
## auto-add (new) datafiles column (from expanded pathspec)
|
|
175
190
|
rec['datafiles'] = datafiles
|
|
176
191
|
end
|
|
177
192
|
|
|
@@ -180,7 +195,8 @@ end
|
|
|
180
195
|
|
|
181
196
|
|
|
182
197
|
|
|
183
|
-
def self.build( args,
|
|
198
|
+
def self.build( args, path: [],
|
|
199
|
+
filepack: nil )
|
|
184
200
|
recs = []
|
|
185
201
|
|
|
186
202
|
## check fo no args case (and filepack present with default)
|
|
@@ -195,22 +211,34 @@ def self.build( args, filepack: nil )
|
|
|
195
211
|
## in single default pathspec node
|
|
196
212
|
more = []
|
|
197
213
|
|
|
198
|
-
|
|
199
214
|
args.each do |arg|
|
|
200
|
-
|
|
215
|
+
## note - ALWAYS give priority to existing directory matches (over filepack)
|
|
216
|
+
## e.g. euro or such - why? why not?
|
|
217
|
+
##
|
|
218
|
+
## todo/check if euro/ works too?
|
|
219
|
+
## check if directory
|
|
220
|
+
if Dir.exist?( arg )
|
|
221
|
+
recs << { 'path' => arg,
|
|
222
|
+
'datafiles' => Pathspec.find( arg ) }
|
|
223
|
+
elsif filepack && filepack.has_key?( arg.downcase )
|
|
201
224
|
recs << { 'path' => "<#{arg.downcase}>",
|
|
202
225
|
'datafiles' => filepack[arg.downcase] }
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
226
|
+
else ## assume it's a file
|
|
227
|
+
file = find_file( arg, path: path )
|
|
228
|
+
## check if file (exists) in any path lookup
|
|
229
|
+
if file
|
|
230
|
+
## todo/fix:
|
|
231
|
+
## add File.expand_path upstream in find_file !!!
|
|
232
|
+
## and remove later here
|
|
233
|
+
## also fix upstream Errorno::ENOENT to Errno::ENOENT !!!
|
|
234
|
+
##
|
|
235
|
+
## make sure path exists; raise error if not
|
|
236
|
+
## (auto-)expand path to normalize - yes why? why not?
|
|
237
|
+
more << File.expand_path(file)
|
|
238
|
+
else
|
|
239
|
+
raise Errno::ENOENT, "No such file or directory - #{arg}"
|
|
240
|
+
end
|
|
241
|
+
end
|
|
214
242
|
end
|
|
215
243
|
|
|
216
244
|
if more.size > 0
|
|
@@ -222,7 +250,7 @@ def self.build( args, filepack: nil )
|
|
|
222
250
|
recs
|
|
223
251
|
end
|
|
224
252
|
|
|
225
|
-
end # class
|
|
253
|
+
end # class Pathspecs
|
|
226
254
|
end # module Sportdb
|
|
227
255
|
|
|
228
256
|
|
|
@@ -237,12 +265,12 @@ end # module Sportdb
|
|
|
237
265
|
## - (ii) all files get bundled together into <input> pathspec entry/record
|
|
238
266
|
##
|
|
239
267
|
## note: was formerly known as expand_args
|
|
240
|
-
def build_pathspecs( args, filepack: nil )
|
|
241
|
-
SportDb::
|
|
268
|
+
def build_pathspecs( args, path: [], filepack: nil )
|
|
269
|
+
SportDb::Pathspecs.build( args, path: path, filepack: filepack )
|
|
242
270
|
end
|
|
243
271
|
|
|
244
272
|
####
|
|
245
273
|
## read pathspecs via csv file (using path column)
|
|
246
274
|
def read_pathspecs( src )
|
|
247
|
-
SportDb::
|
|
275
|
+
SportDb::Pathspecs.read( src )
|
|
248
276
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fbtok
|
|
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: 2026-06-
|
|
11
|
+
date: 2026-06-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sportdb-parser
|