fbtok 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Manifest.txt +1 -0
- data/README.md +14 -0
- data/Rakefile +2 -2
- data/bin/fbchk +177 -0
- data/bin/fbx +1 -1
- data/lib/fbtok.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4ab88883b8f80ee4824cab352297f037e2afcb72351bf6956a8e48bddd5a164
|
4
|
+
data.tar.gz: 6bd75bea2015124e34b01f506757a54a5537ca0544559a0377b6f0a6a0533c0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94b3582db70136fdeadeebe003fefdff304ca923bd76edcc0a40d28731c64e73f372b7c0ecf74e58623358102c32ad51e0a233becee4555d5ccd322552d53d80
|
7
|
+
data.tar.gz: dca47c3d3e134ed9c103ba873e76e0c4793d690bbaf6ced8a34693e4c2fea3fc1ff43af0d45ebc62738022f02bb02a0e0bcc04c153dd752a49c7a50d62ba6bba
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,20 @@ $ gem install fbtok
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
+
|
23
|
+
### fbtok - use tokenizer/parser
|
24
|
+
|
25
|
+
- depends on sportdb-parser
|
26
|
+
|
27
|
+
### fbt - use quick match reader & fbx - dump match schedule - uses quick league & match readers
|
28
|
+
|
29
|
+
- depends on sportdb-quick
|
30
|
+
|
31
|
+
### fbchk - use quick match linter; check league and team names via search & more
|
32
|
+
|
33
|
+
- depends on sportdb-formats (incl. sportdb-search & sportdb-catalogs)
|
34
|
+
|
35
|
+
|
22
36
|
...
|
23
37
|
|
24
38
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'hoe'
|
|
2
2
|
|
3
3
|
|
4
4
|
Hoe.spec 'fbtok' do
|
5
|
-
self.version = '0.1.
|
5
|
+
self.version = '0.1.1'
|
6
6
|
|
7
7
|
self.summary = "fbtok - football.txt lint tools incl. tokenizer, parser & more"
|
8
8
|
self.description = summary
|
@@ -22,7 +22,7 @@ Hoe.spec 'fbtok' do
|
|
22
22
|
# ['sportdb-parser', '>= 0.2.2'],
|
23
23
|
# ['sportdb-structs', '>= 0.5.0'],
|
24
24
|
# ['logutils', '>= 0.6.1'],
|
25
|
-
['sportdb-
|
25
|
+
['sportdb-formats', '>= 2.1.2'],
|
26
26
|
]
|
27
27
|
|
28
28
|
self.spec_extras = {
|
data/bin/fbchk
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
## tip: to test run:
|
4
|
+
## ruby -I ./lib bin/fbchk
|
5
|
+
|
6
|
+
|
7
|
+
## local hack for debugging
|
8
|
+
## use local versions if present
|
9
|
+
$LOAD_PATH.unshift( File.expand_path( '/sports/sportdb/sport.db/sportdb-structs/lib' ))
|
10
|
+
$LOAD_PATH.unshift( File.expand_path( '/sports/sportdb/sport.db/sportdb-catalogs/lib' ))
|
11
|
+
$LOAD_PATH.unshift( File.expand_path( '/sports/sportdb/sport.db/sportdb-search/lib' ))
|
12
|
+
|
13
|
+
|
14
|
+
## our own code
|
15
|
+
require 'fbtok'
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
## local hack
|
20
|
+
## if exists up-to-date catalog db (use local version NOT built-in)
|
21
|
+
catalog_path = '/sports/sportdb/sport.db/catalog/catalog.db'
|
22
|
+
if File.exist?( catalog_path )
|
23
|
+
SportDb::Import.config.catalog_path = catalog_path
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
args = ARGV
|
28
|
+
opts = { debug: false,
|
29
|
+
file: nil,
|
30
|
+
teams: true, ## check/lint teams (name errros etc.)
|
31
|
+
}
|
32
|
+
|
33
|
+
parser = OptionParser.new do |parser|
|
34
|
+
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
35
|
+
|
36
|
+
##
|
37
|
+
## check if git has a offline option?? (use same)
|
38
|
+
## check for other tools - why? why not?
|
39
|
+
# parser.on( "-q", "--quiet",
|
40
|
+
# "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
|
41
|
+
# opts[:debug] = false
|
42
|
+
# end
|
43
|
+
parser.on( "--verbose", "--debug",
|
44
|
+
"turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
|
45
|
+
opts[:debug] = true
|
46
|
+
end
|
47
|
+
|
48
|
+
parser.on( "-f FILE", "--file FILE",
|
49
|
+
"read datafiles (pathspecs) via .csv file") do |file|
|
50
|
+
opts[:file] = file
|
51
|
+
end
|
52
|
+
|
53
|
+
parser.on( "--[no-]teams",
|
54
|
+
"turn on/off team name checks (default: #{opts[:teams]})") do |teams|
|
55
|
+
opts[:teams] = teams
|
56
|
+
end
|
57
|
+
end
|
58
|
+
parser.parse!( args )
|
59
|
+
|
60
|
+
|
61
|
+
puts "OPTS:"
|
62
|
+
p opts
|
63
|
+
puts "ARGV:"
|
64
|
+
p args
|
65
|
+
|
66
|
+
|
67
|
+
## todo/check - use packs or projects or such
|
68
|
+
## instead of specs - why? why not?
|
69
|
+
specs = []
|
70
|
+
if opts[:file]
|
71
|
+
recs = read_csv( opts[:file] )
|
72
|
+
pp recs
|
73
|
+
## note - make pathspecs relative to passed in file arg!!!
|
74
|
+
basedir = File.dirname( opts[:file] )
|
75
|
+
recs.each do |rec|
|
76
|
+
paths = SportDb::Parser::Opts.find( rec['path'], dir: basedir )
|
77
|
+
specs << [paths, rec]
|
78
|
+
end
|
79
|
+
else
|
80
|
+
paths = if args.empty?
|
81
|
+
[]
|
82
|
+
else
|
83
|
+
## check for directories
|
84
|
+
## and auto-expand
|
85
|
+
SportDb::Parser::Opts.expand_args( args )
|
86
|
+
end
|
87
|
+
specs << [paths, {}]
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
if opts[:debug]
|
92
|
+
SportDb::QuickMatchLinter.debug = true
|
93
|
+
SportDb::QuickMatchReader.debug = true
|
94
|
+
SportDb::MatchParser.debug = true
|
95
|
+
else
|
96
|
+
SportDb::QuickMatchLinter.debug = false
|
97
|
+
SportDb::QuickMatchReader.debug = false
|
98
|
+
SportDb::MatchParser.debug = false
|
99
|
+
LogUtils::Logger.root.level = :info
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
specs.each_with_index do |(paths, rec),i|
|
104
|
+
errors = []
|
105
|
+
paths.each_with_index do |path,j|
|
106
|
+
puts "==> [#{j+1}/#{paths.size}] reading >#{path}<..."
|
107
|
+
quick = SportDb::QuickMatchLinter.new( read_text( path ),
|
108
|
+
check_teams: opts[:teams] )
|
109
|
+
matches = quick.parse
|
110
|
+
|
111
|
+
|
112
|
+
if quick.errors?
|
113
|
+
puts "!! #{quick.errors.size} error(s):"
|
114
|
+
pp quick.errors
|
115
|
+
|
116
|
+
quick.errors.each do |err|
|
117
|
+
errors << [ path, *err ] # note: use splat (*) to add extra values (starting with msg)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
puts " #{matches.size} match(es)"
|
121
|
+
end
|
122
|
+
|
123
|
+
if errors.size > 0
|
124
|
+
puts
|
125
|
+
puts "!! #{errors.size} PARSE ERRORS in #{paths.size} datafile(s)"
|
126
|
+
pp errors
|
127
|
+
else
|
128
|
+
puts
|
129
|
+
puts " OK - no parse errors in #{paths.size} datafile(s)"
|
130
|
+
end
|
131
|
+
|
132
|
+
## add errors to rec via rec['errors'] to allow
|
133
|
+
## for further processing/reporting
|
134
|
+
rec['errors'] = errors
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
###
|
140
|
+
## generate a report if --file option used
|
141
|
+
if opts[:file]
|
142
|
+
|
143
|
+
buf = String.new
|
144
|
+
|
145
|
+
buf << "# fbchk summary report - #{specs.size} dataset(s)\n\n"
|
146
|
+
|
147
|
+
specs.each_with_index do |(paths, rec),i|
|
148
|
+
errors = rec['errors']
|
149
|
+
|
150
|
+
if errors.size > 0
|
151
|
+
buf << "!! #{errors.size} ERROR(S) "
|
152
|
+
else
|
153
|
+
buf << " OK "
|
154
|
+
end
|
155
|
+
buf << "%-20s" % rec['path']
|
156
|
+
buf << " - #{paths.size} datafile(s)"
|
157
|
+
buf << "\n"
|
158
|
+
|
159
|
+
if errors.size > 0
|
160
|
+
buf << errors.pretty_inspect
|
161
|
+
buf << "\n"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
puts
|
166
|
+
puts "SUMMARY:"
|
167
|
+
puts buf
|
168
|
+
|
169
|
+
basedir = File.dirname( opts[:file] )
|
170
|
+
basename = File.basename( opts[:file], File.extname( opts[:file] ))
|
171
|
+
outpath = "#{basedir}/fbcheck.#{basename}.txt"
|
172
|
+
write_text( outpath, buf )
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
puts "bye"
|
177
|
+
|
data/bin/fbx
CHANGED
@@ -84,7 +84,7 @@ paths.each_with_index do |path,i|
|
|
84
84
|
puts "==> [#{i+1}/#{paths.size}] reading >#{path}<..."
|
85
85
|
|
86
86
|
txt = read_text( path )
|
87
|
-
secs = SportDb::
|
87
|
+
secs = SportDb::QuickLeagueOutlineReader.parse( txt )
|
88
88
|
## pp secs
|
89
89
|
|
90
90
|
secs.each_with_index do |sec,j| ## sec(tion)s
|
data/lib/fbtok.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbtok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
@@ -11,19 +11,19 @@ cert_chain: []
|
|
11
11
|
date: 2025-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: sportdb-
|
14
|
+
name: sportdb-formats
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.1.2
|
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:
|
26
|
+
version: 2.1.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +61,7 @@ dependencies:
|
|
61
61
|
description: fbtok - football.txt lint tools incl. tokenizer, parser & more
|
62
62
|
email: gerald.bauer@gmail.com
|
63
63
|
executables:
|
64
|
+
- fbchk
|
64
65
|
- fbt
|
65
66
|
- fbtok
|
66
67
|
- fbx
|
@@ -74,6 +75,7 @@ files:
|
|
74
75
|
- Manifest.txt
|
75
76
|
- README.md
|
76
77
|
- Rakefile
|
78
|
+
- bin/fbchk
|
77
79
|
- bin/fbt
|
78
80
|
- bin/fbtok
|
79
81
|
- bin/fbx
|