fbtxt 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/Manifest.txt +1 -0
  4. data/Rakefile +1 -1
  5. data/bin/fbgen +123 -0
  6. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 607e238a0ed74389bf774972372fc544e390d55a6a4c37fe6d1c891b52b1b931
4
- data.tar.gz: 92ba22ae0d4283bf1fedaa676d30f12f1dfd65180fa67a6278d9beb958eac9f3
3
+ metadata.gz: c2c09360d4d28c2ae6f0b4bc82cb5fb30137694a07dfa6ff328278bc921b8b71
4
+ data.tar.gz: af255308ddabdc3a64c83c88eeaa122b1b70ede8c97cda2567e906abc7dae9da
5
5
  SHA512:
6
- metadata.gz: '059d3068e7aab584ec387a676c20b4fb7f64fd3720b7878bbaf2785f539985f20f0cd0358b2f1e301582ce57a0ae22dbc7fd47fd53d324f9e3b95d2d5cbba968'
7
- data.tar.gz: 63dabb09c90b0421f7cde8fc86793cc006c7a731ea1415959710dd56bbf09f3cf1f5b31de97e5c60c70e7a9642b6e2842235e835cbc6113a292620178037d802
6
+ metadata.gz: 0e659f4548c33171abd5cb26e22b9297755e7990227a5ef5811977ae241d4ec4433c1ee59220fd083cf873e2c8f179c63e6c11b9ed1adc92b7543a907156aa9d
7
+ data.tar.gz: b7383348831a26c274f36de7038013adcadc5da918da0d81a34c132e13abe3ae052f0b8fefd69b8f4c829cbd3979aad9e1a45d8088da6d32b070bcbec856cf19
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.1.0
1
+ ### 0.1.1
2
2
  ### 0.0.1 / 2024-12-28
3
3
 
4
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -2,4 +2,5 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/fbgen
5
6
  bin/fbtxt
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'hoe'
2
2
 
3
3
 
4
4
  Hoe.spec 'fbtxt' do
5
- self.version = '0.1.0'
5
+ self.version = '0.1.1'
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_datasets( opts[:file] )
67
+ else
68
+ parse_datasets_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.0
4
+ version: 0.1.1
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: