sportdb-writers 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 +2 -0
- data/Rakefile +2 -4
- data/bin/fbgen +99 -0
- data/bin/fbtxt +52 -0
- data/lib/sportdb/leagues/leagues_europe.rb +7 -0
- data/lib/sportdb/writers/txt_writer.rb +8 -1
- data/lib/sportdb/writers/version.rb +4 -5
- data/lib/sportdb/writers.rb +1 -9
- metadata +9 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c4a35292a78b32475f88dc7d43246c1782dcd82c15afed36aec0b6e1143e94
|
4
|
+
data.tar.gz: 6ec7868264b09d86494f86b2a30c7577212e7e262901df415b36d2bd3c4d4d06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca5e6e0ec314d83328900e159d6f561869ba4f93d160628b012c1f16b571df3b2d7c92fb418b74fcf474bf3fd8451c03590e629318309b4cb93ee2eaee7c491
|
7
|
+
data.tar.gz: 4ed5b4c8538c9438532fb80432a7c7087f3b84c991a38d4026a4e74981759093fed3d475d9191b2f28d6c3ae776de87c3826e1f80f7531e00da28f6d4a009a3d
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -18,15 +18,13 @@ Hoe.spec 'sportdb-writers' do
|
|
18
18
|
self.history_file = 'CHANGELOG.md'
|
19
19
|
|
20
20
|
self.extra_deps = [
|
21
|
-
['sportdb-
|
21
|
+
['sportdb-quick'],
|
22
22
|
['gitti'],
|
23
|
-
['cocos'], ### fix - move upstream (incl. in sportdb-format)
|
24
23
|
]
|
25
24
|
|
26
25
|
self.licenses = ['Public Domain']
|
27
26
|
|
28
27
|
self.spec_extras = {
|
29
|
-
required_ruby_version: '>=
|
28
|
+
required_ruby_version: '>= 3.1.0'
|
30
29
|
}
|
31
|
-
|
32
30
|
end
|
data/bin/fbgen
ADDED
@@ -0,0 +1,99 @@
|
|
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
|
+
require 'optparse'
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
args=ARGV
|
14
|
+
|
15
|
+
|
16
|
+
opts = {
|
17
|
+
}
|
18
|
+
|
19
|
+
parser = OptionParser.new do |parser|
|
20
|
+
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
21
|
+
end
|
22
|
+
parser.parse!( args )
|
23
|
+
|
24
|
+
puts "OPTS:"
|
25
|
+
p opts
|
26
|
+
puts "ARGV:"
|
27
|
+
p args
|
28
|
+
|
29
|
+
|
30
|
+
### split args in datasets with leagues and seasons
|
31
|
+
datasets = []
|
32
|
+
|
33
|
+
|
34
|
+
args.each do |arg|
|
35
|
+
if arg =~ %r{^[0-9/-]+$} ## season
|
36
|
+
if datasets.empty?
|
37
|
+
puts "!! ERROR - league required before season arg; sorry"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
season = Season.parse( arg ) ## check season
|
42
|
+
datasets[-1][1] << season
|
43
|
+
else ## assume league key
|
44
|
+
key = arg.downcase
|
45
|
+
league_info = Writer::LEAGUES[ key ]
|
46
|
+
|
47
|
+
if league_info.nil?
|
48
|
+
puts "!! ERROR - no league found for >#{key}<; sorry"
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
|
52
|
+
datasets << [key, []]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
pp datasets
|
57
|
+
|
58
|
+
|
59
|
+
datasets.each do |league_key, seasons|
|
60
|
+
seasons = [ Season('2024/25') ] if seasons.empty?
|
61
|
+
|
62
|
+
puts "==> gen #{league_key} - #{seasons.size} seasons(s)..."
|
63
|
+
|
64
|
+
league_info = Writer::LEAGUES[ league_key ]
|
65
|
+
pp league_info
|
66
|
+
|
67
|
+
seasons.each do |season|
|
68
|
+
### get matches
|
69
|
+
src_dir = "/sports/cache.wfb"
|
70
|
+
path = "#{src_dir}/#{season.to_path}/#{league_key}.csv"
|
71
|
+
puts " ---> reading matches in #{path} ..."
|
72
|
+
matches = SportDb::CsvMatchParser.read( path )
|
73
|
+
puts " #{matches.size} matches"
|
74
|
+
|
75
|
+
## build
|
76
|
+
txt = SportDb::TxtMatchWriter.build( matches )
|
77
|
+
puts txt
|
78
|
+
|
79
|
+
league_name = league_info[ :name ] # e.g. Brasileiro Série A
|
80
|
+
basename = league_info[ :basename] #.e.g 1-seriea
|
81
|
+
|
82
|
+
league_name = league_name.call( season ) if league_name.is_a?( Proc ) ## is proc/func - name depends on season
|
83
|
+
basename = basename.call( season ) if basename.is_a?( Proc ) ## is proc/func - name depends on season
|
84
|
+
|
85
|
+
buf = String.new
|
86
|
+
buf << "= #{league_name} #{season}\n\n"
|
87
|
+
buf << txt
|
88
|
+
|
89
|
+
## note - repo_path moved!!!
|
90
|
+
## repo_path = league_info[ :path ] # e.g. brazil or world/europe/portugal etc.
|
91
|
+
repo_path = SportDb::GitHubSync::REPOS[ league_key ]
|
92
|
+
|
93
|
+
outpath = "./o/#{repo_path}/#{season.to_path}/#{basename}.txt"
|
94
|
+
write_text( outpath, buf )
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
puts "bye"
|
data/bin/fbtxt
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
## tip: to test run:
|
4
|
+
## ruby -I ./lib bin/fbtxt
|
5
|
+
|
6
|
+
# $LOAD_PATH.unshift( '../../../sportdb/sport.db/parser/lib' )
|
7
|
+
# $LOAD_PATH.unshift( '../../../sportdb/sport.db/sportdb-structs/lib' )
|
8
|
+
# $LOAD_PATH.unshift( '../../../sportdb/sport.db/quick/lib' )
|
9
|
+
|
10
|
+
require 'sportdb/writers'
|
11
|
+
|
12
|
+
require 'optparse'
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
args=ARGV
|
17
|
+
|
18
|
+
|
19
|
+
opts = {
|
20
|
+
}
|
21
|
+
|
22
|
+
parser = OptionParser.new do |parser|
|
23
|
+
parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
24
|
+
end
|
25
|
+
parser.parse!( args )
|
26
|
+
|
27
|
+
puts "OPTS:"
|
28
|
+
p opts
|
29
|
+
puts "ARGV:"
|
30
|
+
p args
|
31
|
+
|
32
|
+
|
33
|
+
matches = []
|
34
|
+
|
35
|
+
## step 1 - get all matches via csv
|
36
|
+
args.each do |arg|
|
37
|
+
path = arg
|
38
|
+
puts "==> reading matches in #{path} ..."
|
39
|
+
more_matches = SportDb::CsvMatchParser.read( path )
|
40
|
+
matches += more_matches
|
41
|
+
end
|
42
|
+
|
43
|
+
puts "#{matches.size} matches"
|
44
|
+
puts
|
45
|
+
|
46
|
+
|
47
|
+
txt = SportDb::TxtMatchWriter.build( matches )
|
48
|
+
puts txt
|
49
|
+
puts
|
50
|
+
|
51
|
+
puts "bye"
|
52
|
+
|
@@ -46,7 +46,14 @@ def self.build( matches, rounds: true )
|
|
46
46
|
buf << "#{round} #{match.round}"
|
47
47
|
else ## use as is from match
|
48
48
|
## note: for now assume english names
|
49
|
-
|
49
|
+
if match.round.nil?
|
50
|
+
## warn
|
51
|
+
puts "!! ERROR - match with round nil?"
|
52
|
+
pp match
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
|
56
|
+
buf << (round_translations[match.round] || match.round)
|
50
57
|
end
|
51
58
|
buf << "\n"
|
52
59
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
|
2
2
|
module SportDb
|
3
|
-
|
3
|
+
module Module
|
4
4
|
module Writers
|
5
|
-
|
6
5
|
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
7
6
|
MINOR = 1
|
8
|
-
PATCH =
|
7
|
+
PATCH = 1
|
9
8
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
10
9
|
|
11
10
|
def self.version
|
@@ -21,5 +20,5 @@ module SportDb
|
|
21
20
|
end
|
22
21
|
|
23
22
|
end # module Writers
|
24
|
-
|
25
|
-
|
23
|
+
end # module Module
|
24
|
+
end # module SportDb
|
data/lib/sportdb/writers.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
|
-
## just use sportdb/catalogs ?! - why? why not?
|
2
|
-
# require 'sportdb/importers' # -- requires db support
|
3
|
-
# require 'sportdb/readers' # -- requires db support
|
4
|
-
#
|
5
|
-
# note - for now only requires sportdb/formats !!!
|
6
|
-
# normalize moved out as a proc!!!
|
7
|
-
require 'sportdb/formats'
|
8
1
|
|
2
|
+
require 'sportdb/quick'
|
9
3
|
|
10
|
-
## todo/fix - make sure upstream cocos is included/required
|
11
|
-
require 'cocos'
|
12
4
|
|
13
5
|
|
14
6
|
module Writer
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-writers
|
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
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: sportdb-
|
14
|
+
name: sportdb-quick
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: cocos
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rdoc
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,7 +75,9 @@ dependencies:
|
|
89
75
|
description: sportdb-writers - sport.db writers for match schedules and results, and
|
90
76
|
more
|
91
77
|
email: gerald.bauer@gmail.com
|
92
|
-
executables:
|
78
|
+
executables:
|
79
|
+
- fbgen
|
80
|
+
- fbtxt
|
93
81
|
extensions: []
|
94
82
|
extra_rdoc_files:
|
95
83
|
- CHANGELOG.md
|
@@ -100,6 +88,8 @@ files:
|
|
100
88
|
- Manifest.txt
|
101
89
|
- README.md
|
102
90
|
- Rakefile
|
91
|
+
- bin/fbgen
|
92
|
+
- bin/fbtxt
|
103
93
|
- lib/sportdb/leagues/leagues_at.rb
|
104
94
|
- lib/sportdb/leagues/leagues_de.rb
|
105
95
|
- lib/sportdb/leagues/leagues_eng.rb
|
@@ -129,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
119
|
requirements:
|
130
120
|
- - ">="
|
131
121
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
122
|
+
version: 3.1.0
|
133
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
124
|
requirements:
|
135
125
|
- - ">="
|