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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3106f4f09e01a5434628f1818c445de04b332df0d2b9b57787eee944444dc715
4
- data.tar.gz: aeb997f0576680cf2500f118ebac827303983021992a714ca0fd65ad03e395fe
3
+ metadata.gz: f5b6e14ffd7c59f250270651861e017f01fdc1fd28ed191f2267d6bed3a2a21d
4
+ data.tar.gz: 45011876b106ff65f3ef3dc7d2d243c10c40c3cc986bbbbef512d32f729555d4
5
5
  SHA512:
6
- metadata.gz: 53a96142090a0b7edbc2dadda557cff02124103e655bf801f47b08d61d658b8218c13f03220f86cf7d29cc0afebab329461d3e42c88000dafeff57e79306aeef
7
- data.tar.gz: 6a7b9ceab580231e026a7b2dfe232ae14bad110bfa8c727e4e20a6329252994412916339354f6a93f9f7a61003a87f2969ecdbef7a94a189a0a1a21027d0cf4d
6
+ metadata.gz: efb7a560598e3257d40a87a9c8eeb8f8bd8fc5eb8fb7070ad6dd8c45b8468e429c7bf36ec8a9318f461281ed63da2ec7439d1083f93aa62578c7187a15547193
7
+ data.tar.gz: 870215a2d271b92a86b08f7904db21e77e6e1dbae25d7db981c8fb78b781332f2b2dae808e341cac0431268c466422b33b4887c66f03d5466246f87387c48c78
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.4.0
1
+ ### 0.4.1
2
2
  ### 0.0.1 / 2020-11-15
3
3
 
4
4
  * Everything is new. First release.
data/Rakefile CHANGED
@@ -18,8 +18,7 @@ Hoe.spec 'sportdb-writers' do
18
18
  self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['football-timezones'],
22
- ['sportdb-quick'],
21
+ ['sportdb-structs', '>= 0.5.0'],
23
22
  ]
24
23
 
25
24
  self.licenses = ['Public Domain']
@@ -1,6 +1,7 @@
1
1
  ######
2
2
  # goals helper
3
3
  # todo/check/fix: move upstream for (re)use - why? why not?
4
+ ### yes, fix - move to csv in sportdb-structs!!!!
4
5
 
5
6
 
6
7
  module Writer
@@ -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 << "#{round} #{match.round}"
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 << (round_translations[match.round] || match.round)
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 << "[#{format_date.call( date )}]\n"
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
- line << " #{format_score.call( match )} " ## note: separate by at least two spaces for now
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
 
@@ -4,7 +4,7 @@ module Module
4
4
  module Writers
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 4
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -1,8 +1,10 @@
1
1
 
2
- require 'sportdb/quick'
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
- # fbtxt & friends tools - remove in future - why? why not?
32
- require 'football/timezones' ## pulls in read_datasets, etc.
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.0
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-29 00:00:00.000000000 Z
11
+ date: 2024-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: football-timezones
14
+ name: sportdb-structs
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
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: '0'
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