fbtxt2json 0.2.0 → 0.2.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Rakefile +1 -1
  4. data/bin/fbtxt2json +54 -4
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1110851daf4ad4e65784b4287e164d916a64dd6604fbe8c40c5f930c93deb19b
4
- data.tar.gz: 98581c266f12caa2845bdc88456b99881ff947a77d29eb2cef5ff6c70bfca799
3
+ metadata.gz: eda08bd194e92f91e52f319f99b158dd512ea80011b72bf75045cc08404ee1a9
4
+ data.tar.gz: 5c0046100b7d4f7d17d2217dca7ca0c782284cac0ad89f1d5ca422e8319548a4
5
5
  SHA512:
6
- metadata.gz: 0c6ff84e6043ac1eefe34cd8eed96ccc8249f93c7d668c1263bdcdb54001f5e9149412aeca9d9bc428d734f56f18bca17f89339084deb7034b2b7418c30523ef
7
- data.tar.gz: 6e0f34b49d0f3abf9a0d9cf1dedfb045a9f2a88163791d0175cae05fe706d4cc6ac2a6e97e7dc7bf80ae60e6a94901406e2ed4059808b1eca66edee8e3429589
6
+ metadata.gz: 7749effafe765758821fc38b7df011b782facf1a78fa80862c7c22e3d1bcfa0e3b7a5009c4e83bae730dc5c29949fb09c61ae3ffc69d9d171557ebd6b3d24b65
7
+ data.tar.gz: 19d8181d200b05948a6f78428201c48c96942495168e5d84812bd1df271269f90ea8f9a20e8e35cbc3f2f530e921b3042a09b19707c898669083919efeea7bfa
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.0
1
+ ### 0.2.1
2
2
  ### 0.0.1 / 2024-09-28
3
3
 
4
4
  * Everything is new. First release.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'hoe'
2
2
 
3
3
 
4
4
  Hoe.spec 'fbtxt2json' do
5
- self.version = '0.2.0'
5
+ self.version = '0.2.1'
6
6
 
7
7
  self.summary = "fbtxt2json - convert football.txt match schedules & more to json"
8
8
  self.description = summary
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 = { debug: false,
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, dump: false ) ### check - name parse_txt or txt_to_json or such - why? why not?
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,31 @@ 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
+
175
+ ### todo/fix: add seasons filter upstream??
176
+ ##
135
177
 
136
178
  datafiles = SportDb::Parser::Opts._find( path )
137
179
  pp datafiles
138
180
  puts " #{datafiles.size} datafile(s)"
181
+ summary << " #{datafiles.size} datafile(s)\n\n"
139
182
 
140
183
  datafiles.each do |datafile|
141
184
  txt = read_text( datafile )
142
- data = parse( txt )
185
+ data = parse( txt, summary: summary )
143
186
 
144
187
  if opts[:output]
145
- ### norm - File.expanddir !!!
188
+ ### norm - File.expand_path !!!
189
+ ## note - use '.' to use (relative to) local directory !!!
146
190
  reldir = File.expand_path(File.dirname( path )) ## keep last dir (in relative name)
147
191
  relpath = datafile.sub( reldir+'/', '' )
148
192
  dir = File.dirname( relpath )
@@ -159,6 +203,12 @@ elsif dirs > 0
159
203
  write_json( outpath, data )
160
204
  end
161
205
  end
206
+
207
+ summary << "</pre>"
208
+ puts summary
209
+ if opts[:summary]
210
+ write_text( "#{opts[:output]}/index.html", summary )
211
+ end
162
212
  else
163
213
  ## do nothing; no args
164
214
  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.0
4
+ version: 0.2.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: 2025-03-27 00:00:00.000000000 Z
11
+ date: 2025-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-quick