fbtxt 0.1.0 → 0.1.2
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/Rakefile +1 -1
- data/bin/fbgen +123 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa1d684ed4bf49ce8ebdebd6ca72cddb34e4379052b96f8136c2855229b88f67
|
4
|
+
data.tar.gz: 2b001ecf44442cb28373e1b4b23cde60fc0dec71895b7b13517fed74acf65a26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1432593f8fd07d96b9de05608afc755d9101473e4173472fb2e8297e0646307fcb098352b5b41bf9fad62d7eb2949786710f7f34a7eb73fb10046544bcf2dd35
|
7
|
+
data.tar.gz: bdabed007d1b924e7dd517bd1399cfe05d8eb20fb5c24fe5a5f9f2c36ce48c9d5d92a141fcfc440da55a9f0edc42c89731e828d81f5e5e6599b710a2c4b1f6bc
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'hoe'
|
|
2
2
|
|
3
3
|
|
4
4
|
Hoe.spec 'fbtxt' do
|
5
|
-
self.version = '0.1.
|
5
|
+
self.version = '0.1.2'
|
6
6
|
|
7
7
|
self.summary = "fbtxt - convert football match schedules & more in tabular comma-separated values (csv) format to (future-proof & evergreen) football.txt"
|
8
8
|
self.description = summary
|
data/bin/fbgen
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
## tip: to test run:
|
4
|
+
## ruby -I ./lib bin/fbgen
|
5
|
+
|
6
|
+
|
7
|
+
require 'sportdb/writers'
|
8
|
+
|
9
|
+
|
10
|
+
args = ARGV
|
11
|
+
opts = {
|
12
|
+
source_path: [],
|
13
|
+
dry: false,
|
14
|
+
debug: true,
|
15
|
+
file: nil,
|
16
|
+
}
|
17
|
+
|
18
|
+
parser = OptionParser.new do |parser|
|
19
|
+
parser.banner = "Usage: #{$PROGRAM_NAME} [options] [args]"
|
20
|
+
|
21
|
+
parser.on( "--dry",
|
22
|
+
"dry run; do NOT write - default is (#{opts[:dry]})" ) do |dry|
|
23
|
+
opts[:dry] = true
|
24
|
+
end
|
25
|
+
parser.on( "-q", "--quiet",
|
26
|
+
"less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
|
27
|
+
opts[:debug] = false
|
28
|
+
end
|
29
|
+
|
30
|
+
parser.on( "-I DIR", "--include DIR",
|
31
|
+
"add directory to (source) search path - default is (#{opts[:source_path].join(',')})") do |dir|
|
32
|
+
opts[:source_path] += path
|
33
|
+
end
|
34
|
+
|
35
|
+
parser.on( "-f FILE", "--file FILE",
|
36
|
+
"read leagues (and seasons) via .csv file") do |file|
|
37
|
+
opts[:file] = file
|
38
|
+
end
|
39
|
+
end
|
40
|
+
parser.parse!( args )
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
if opts[:source_path].empty? &&
|
45
|
+
File.exist?( '/sports/cache.api.fbdat') &&
|
46
|
+
File.exist?( '/sports/cache.wfb' )
|
47
|
+
opts[:source_path] << '/sports/cache.api.fbdat'
|
48
|
+
opts[:source_path] << '/sports/cache.wfb'
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
if opts[:source_path].empty?
|
53
|
+
opts[:source_path] = ['.'] ## use ./ as default
|
54
|
+
end
|
55
|
+
|
56
|
+
source_path = opts[:source_path]
|
57
|
+
|
58
|
+
|
59
|
+
puts "OPTS:"
|
60
|
+
p opts
|
61
|
+
puts "ARGV:"
|
62
|
+
p args
|
63
|
+
|
64
|
+
|
65
|
+
datasets = if opts[:file]
|
66
|
+
read_leagueset( opts[:file] )
|
67
|
+
else
|
68
|
+
parse_leagueset_args( args )
|
69
|
+
end
|
70
|
+
|
71
|
+
puts "datasets:"
|
72
|
+
pp datasets
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
root_dir = './o'
|
77
|
+
puts " (output) root_dir: >#{root_dir}<"
|
78
|
+
|
79
|
+
|
80
|
+
### step 0 - validate and fill-in seasons etc.
|
81
|
+
datasets.validate!( source_path: source_path )
|
82
|
+
|
83
|
+
|
84
|
+
## step 1 - generate
|
85
|
+
datasets.each do |league_key, seasons|
|
86
|
+
puts "==> gen #{league_key} - #{seasons.size} seasons(s)..."
|
87
|
+
|
88
|
+
league_info = find_league_info( league_key )
|
89
|
+
pp league_info
|
90
|
+
|
91
|
+
seasons.each do |season|
|
92
|
+
filename = "#{season.to_path}/#{league_key}.csv"
|
93
|
+
path = find_file( filename, path: source_path )
|
94
|
+
|
95
|
+
## get matches
|
96
|
+
puts " ---> reading matches in #{path} ..."
|
97
|
+
matches = SportDb::CsvMatchParser.read( path )
|
98
|
+
puts " #{matches.size} matches"
|
99
|
+
|
100
|
+
## build
|
101
|
+
txt = SportDb::TxtMatchWriter.build( matches )
|
102
|
+
puts txt if opts[:debug]
|
103
|
+
|
104
|
+
league_name = league_info[ :name ] # e.g. Brasileiro Série A
|
105
|
+
league_name = league_name.call( season ) if league_name.is_a?( Proc ) ## is proc/func - name depends on season
|
106
|
+
|
107
|
+
buf = String.new
|
108
|
+
buf << "= #{league_name} #{season}\n\n"
|
109
|
+
buf << txt
|
110
|
+
|
111
|
+
outpath = "#{root_dir}/foot/#{season.to_path}/#{league_key}.txt"
|
112
|
+
|
113
|
+
if opts[:dry]
|
114
|
+
puts " (dry) writing to >#{outpath}<..."
|
115
|
+
else
|
116
|
+
write_text( outpath, buf )
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
puts
|
123
|
+
puts "bye"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbtxt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
@@ -62,6 +62,7 @@ description: fbtxt - convert football match schedules & more in tabular comma-se
|
|
62
62
|
values (csv) format to (future-proof & evergreen) football.txt
|
63
63
|
email: gerald.bauer@gmail.com
|
64
64
|
executables:
|
65
|
+
- fbgen
|
65
66
|
- fbtxt
|
66
67
|
extensions: []
|
67
68
|
extra_rdoc_files:
|
@@ -73,6 +74,7 @@ files:
|
|
73
74
|
- Manifest.txt
|
74
75
|
- README.md
|
75
76
|
- Rakefile
|
77
|
+
- bin/fbgen
|
76
78
|
- bin/fbtxt
|
77
79
|
homepage: https://github.com/sportdb/sport.db
|
78
80
|
licenses:
|