sportdb-writers 0.4.0 → 0.4.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/Rakefile +1 -2
- data/lib/sportdb/writers/goals.rb +1 -0
- data/lib/sportdb/writers/txt_writer.rb +5 -25
- data/lib/sportdb/writers/version.rb +1 -1
- data/lib/sportdb/writers.rb +24 -5
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5b6e14ffd7c59f250270651861e017f01fdc1fd28ed191f2267d6bed3a2a21d
|
4
|
+
data.tar.gz: 45011876b106ff65f3ef3dc7d2d243c10c40c3cc986bbbbef512d32f729555d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb7a560598e3257d40a87a9c8eeb8f8bd8fc5eb8fb7070ad6dd8c45b8468e429c7bf36ec8a9318f461281ed63da2ec7439d1083f93aa62578c7187a15547193
|
7
|
+
data.tar.gz: 870215a2d271b92a86b08f7904db21e77e6e1dbae25d7db981c8fb78b781332f2b2dae808e341cac0431268c466422b33b4887c66f03d5466246f87387c48c78
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -127,12 +127,6 @@ def self._build_batch( matches, rounds: true )
|
|
127
127
|
## note: make sure rounds is a bool, that is, true or false (do NOT pass in strings etc.)
|
128
128
|
raise ArgumentError, "rounds flag - bool expected; got: #{rounds.inspect}" unless rounds.is_a?( TrueClass ) || rounds.is_a?( FalseClass )
|
129
129
|
|
130
|
-
## note: for now always english
|
131
|
-
round = 'Matchday'
|
132
|
-
format_date = ->(date) { date.strftime( '%a %b/%-d' ) }
|
133
|
-
format_score = ->(match) { match.score.to_s( lang: 'en' ) }
|
134
|
-
round_translations = ROUND_TRANSLATIONS
|
135
|
-
|
136
130
|
buf = String.new
|
137
131
|
|
138
132
|
last_round = nil
|
@@ -150,7 +144,7 @@ def self._build_batch( matches, rounds: true )
|
|
150
144
|
match.round =~ /^[0-9]+$/ ## all numbers/digits
|
151
145
|
## default "class format
|
152
146
|
## e.g. Runde 1, Spieltag 1, Matchday 1, Week 1
|
153
|
-
buf << "
|
147
|
+
buf << "Round #{match.round}"
|
154
148
|
else ## use as is from match
|
155
149
|
## note: for now assume english names
|
156
150
|
if match.round.nil?
|
@@ -160,7 +154,7 @@ def self._build_batch( matches, rounds: true )
|
|
160
154
|
exit 1
|
161
155
|
end
|
162
156
|
|
163
|
-
buf << (
|
157
|
+
buf << (ROUND_TRANSLATIONS[match.round] || match.round)
|
164
158
|
end
|
165
159
|
## note - reset last_date & last_time on every new round header
|
166
160
|
last_date = nil
|
@@ -196,7 +190,7 @@ def self._build_batch( matches, rounds: true )
|
|
196
190
|
if date_yyyymmdd != last_date
|
197
191
|
## note: add an extra leading blank line (if no round headings printed)
|
198
192
|
buf << "\n" unless rounds
|
199
|
-
buf << "[#{
|
193
|
+
buf << "[#{date.strftime( '%a %b/%-d' )}]\n"
|
200
194
|
last_time = nil
|
201
195
|
end
|
202
196
|
end
|
@@ -223,7 +217,8 @@ def self._build_batch( matches, rounds: true )
|
|
223
217
|
|
224
218
|
line << "%-23s" % team1 ## note: use %-s for left-align
|
225
219
|
|
226
|
-
|
220
|
+
## note: separate by at least two spaces for now
|
221
|
+
line << " #{match.score.to_s( lang: 'en' )} "
|
227
222
|
|
228
223
|
line << "%-23s" % team2
|
229
224
|
|
@@ -269,21 +264,6 @@ def self._build_batch( matches, rounds: true )
|
|
269
264
|
end
|
270
265
|
|
271
266
|
|
272
|
-
def self.write( path, matches, name:, rounds: true)
|
273
|
-
|
274
|
-
buf = build( matches, rounds: rounds )
|
275
|
-
|
276
|
-
## for convenience - make sure parent folders/directories exist
|
277
|
-
FileUtils.mkdir_p( File.dirname( path) ) unless Dir.exist?( File.dirname( path ))
|
278
|
-
|
279
|
-
puts "==> writing to >#{path}<..."
|
280
|
-
File.open( path, 'w:utf-8' ) do |f|
|
281
|
-
f.write( "= #{name}\n" )
|
282
|
-
f.write( buf )
|
283
|
-
end
|
284
|
-
end # method self.write
|
285
|
-
|
286
|
-
|
287
267
|
def self.build_goals( goals )
|
288
268
|
## todo/fix: for now assumes always minutes (without offset) - add offset support
|
289
269
|
|
data/lib/sportdb/writers.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
|
2
|
-
require 'sportdb/
|
3
|
-
|
2
|
+
require 'sportdb/structs'
|
4
3
|
|
5
4
|
|
5
|
+
##
|
6
|
+
### todo/fix - add SportDb namespace for config? why? why not?
|
7
|
+
## check where used?
|
6
8
|
module Writer
|
7
9
|
class Configuration
|
8
10
|
def out_dir() @out_dir || './tmp'; end
|
@@ -20,6 +22,7 @@ end # module Writer
|
|
20
22
|
|
21
23
|
|
22
24
|
|
25
|
+
|
23
26
|
###
|
24
27
|
# our own code
|
25
28
|
require_relative 'writers/version'
|
@@ -27,9 +30,25 @@ require_relative 'writers/goals'
|
|
27
30
|
require_relative 'writers/txt_writer'
|
28
31
|
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
|
34
|
+
module SportDb
|
35
|
+
class TxtMatchWriter
|
36
|
+
def self.write( path, matches, name:, rounds: true)
|
37
|
+
|
38
|
+
buf = build( matches, rounds: rounds )
|
39
|
+
|
40
|
+
## for convenience - make sure parent folders/directories exist
|
41
|
+
FileUtils.mkdir_p( File.dirname( path) ) unless Dir.exist?( File.dirname( path ))
|
42
|
+
|
43
|
+
puts "==> writing to >#{path}<..."
|
44
|
+
File.open( path, 'w:utf-8' ) do |f|
|
45
|
+
f.write( "= #{name}\n" )
|
46
|
+
f.write( buf )
|
47
|
+
end
|
48
|
+
end # method self.write
|
49
|
+
end # class TxtMatchWriter
|
50
|
+
end # module SportDb
|
51
|
+
|
33
52
|
|
34
53
|
|
35
54
|
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-writers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.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-12-
|
11
|
+
date: 2024-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: sportdb-structs
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: sportdb-quick
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: 0.5.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rdoc
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|