fbtxt2json 0.2.0 → 0.2.2
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/bin/fbtxt2json +54 -5
- 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: 66b36b917ccd87f925171e33aadc3edd58db330f7f46af0a8c7ca7f36060ba2d
|
4
|
+
data.tar.gz: 324a37bb90fdb2badf86e187c8e422eca9ecead101cbc057a638aac247b86e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4c5dcac2a7ba88ab44943536bbad963bc5897d641076ae4f9af078d87d49be40e7a0cd853547a6bd247ae39f69a83c08d12ef941cc7fb5b4a1f9d36820370dd
|
7
|
+
data.tar.gz: 1336d12e9b6009b970ac4f7401146790a6dca5cd08098add1956fba224a5f6aef8ec82da36b0310c0c0296f35ee24041eb097d3178215ba27e6bcf1233e5aace
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
data/bin/fbtxt2json
CHANGED
@@ -4,6 +4,13 @@
|
|
4
4
|
## ruby -I ./lib bin/fbtxt2json
|
5
5
|
|
6
6
|
|
7
|
+
#####
|
8
|
+
## todo
|
9
|
+
## add option for [no]-halt-on-error (default: false)
|
10
|
+
## or use a different (shorter) name e.g. --resume?
|
11
|
+
|
12
|
+
|
13
|
+
|
7
14
|
## our own code
|
8
15
|
require 'sportdb/quick'
|
9
16
|
|
@@ -16,8 +23,10 @@ require 'optparse'
|
|
16
23
|
|
17
24
|
|
18
25
|
args = ARGV
|
19
|
-
opts = {
|
26
|
+
opts = { debug: false,
|
20
27
|
output: nil,
|
28
|
+
summary: false,
|
29
|
+
seasons: [],
|
21
30
|
}
|
22
31
|
|
23
32
|
parser = OptionParser.new do |parser|
|
@@ -40,15 +49,30 @@ parser.banner = "Usage: #{$PROGRAM_NAME} [options] PATH"
|
|
40
49
|
"output to file / dir" ) do |output|
|
41
50
|
opts[:output] = output
|
42
51
|
end
|
52
|
+
|
53
|
+
parser.on( "--summary",
|
54
|
+
"(auto-)generate summary (index.html) page (default: #{opts[:summary]})" ) do |summary|
|
55
|
+
opts[:summary] = summary
|
56
|
+
end
|
57
|
+
|
58
|
+
parser.on( "--seasons SEASONS",
|
59
|
+
"turn on processing only seasons (default: #{!opts[:seasons].empty?}" ) do |seasons|
|
60
|
+
pp seasons
|
61
|
+
seasons = seasons.split( /[, ]/ )
|
62
|
+
seasons = seasons.map {|season| Season.parse(season) }
|
63
|
+
opts[:seasons] = seasons
|
64
|
+
end
|
43
65
|
end
|
44
66
|
parser.parse!( args )
|
45
67
|
|
68
|
+
|
46
69
|
puts "OPTS:"
|
47
70
|
p opts
|
48
71
|
puts "ARGV:"
|
49
72
|
p args
|
50
73
|
|
51
74
|
|
75
|
+
|
52
76
|
paths = if args.empty?
|
53
77
|
['/sports/openfootball/euro/2021--europe/euro.txt']
|
54
78
|
else
|
@@ -89,7 +113,9 @@ end
|
|
89
113
|
|
90
114
|
|
91
115
|
|
92
|
-
def parse( txt,
|
116
|
+
def parse( txt,
|
117
|
+
summary: nil,
|
118
|
+
dump: false ) ### check - name parse_txt or txt_to_json or such - why? why not?
|
93
119
|
quick = SportDb::QuickMatchReader.new( txt )
|
94
120
|
matches = quick.parse
|
95
121
|
name = quick.league_name ## quick hack - get league+season via league_name
|
@@ -109,6 +135,12 @@ def parse( txt, dump: false ) ### check - name parse_txt or txt_to_json or suc
|
|
109
135
|
exit 1
|
110
136
|
end
|
111
137
|
|
138
|
+
|
139
|
+
if summary
|
140
|
+
## add stats to summary page
|
141
|
+
summary << "- #{name} | #{matches.size} match(es)\n"
|
142
|
+
end
|
143
|
+
|
112
144
|
data
|
113
145
|
end
|
114
146
|
|
@@ -130,19 +162,29 @@ if files > 0
|
|
130
162
|
write_json( opts[:output], data )
|
131
163
|
end
|
132
164
|
elsif dirs > 0
|
165
|
+
|
166
|
+
## use a html pre(formatted) text
|
167
|
+
summary = String.new
|
168
|
+
summary << "<pre>\n"
|
169
|
+
summary << "run on #{Time.now.to_s}\n\n" ## add version and such - why? why not?
|
170
|
+
|
133
171
|
paths.each_with_index do |path,i|
|
134
172
|
puts "==> reading dir [#{i+1}/#{paths.size}] >#{path}<..."
|
173
|
+
summary << "==> [#{i+1}/#{paths.size}] dir #{path}\n"
|
174
|
+
|
135
175
|
|
136
|
-
datafiles = SportDb::Parser::Opts._find( path )
|
176
|
+
datafiles = SportDb::Parser::Opts._find( path, seasons: opts[:seasons] )
|
137
177
|
pp datafiles
|
138
178
|
puts " #{datafiles.size} datafile(s)"
|
179
|
+
summary << " #{datafiles.size} datafile(s)\n\n"
|
139
180
|
|
140
181
|
datafiles.each do |datafile|
|
141
182
|
txt = read_text( datafile )
|
142
|
-
data = parse( txt )
|
183
|
+
data = parse( txt, summary: summary )
|
143
184
|
|
144
185
|
if opts[:output]
|
145
|
-
### norm - File.
|
186
|
+
### norm - File.expand_path !!!
|
187
|
+
## note - use '.' to use (relative to) local directory !!!
|
146
188
|
reldir = File.expand_path(File.dirname( path )) ## keep last dir (in relative name)
|
147
189
|
relpath = datafile.sub( reldir+'/', '' )
|
148
190
|
dir = File.dirname( relpath )
|
@@ -159,6 +201,13 @@ elsif dirs > 0
|
|
159
201
|
write_json( outpath, data )
|
160
202
|
end
|
161
203
|
end
|
204
|
+
|
205
|
+
summary << "</pre>"
|
206
|
+
puts summary
|
207
|
+
## note - do NOT write-out summary if seasons filter is used!!!
|
208
|
+
if opts[:summary] && opts[:seasons].size == 0
|
209
|
+
write_text( "#{opts[:output]}/index.html", summary )
|
210
|
+
end
|
162
211
|
else
|
163
212
|
## do nothing; no args
|
164
213
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbtxt2json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
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-
|
11
|
+
date: 2025-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-quick
|