fbtxt-pp 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb82751c433e1b2a9495f545dde77a538f1cb08b66e55aa6c6af0e3830ef6cff
4
- data.tar.gz: 5cc0c7f57f4d5e79db8bba38d97dc3dbc4ca6374de7db8d51acf3fc7d351e681
3
+ metadata.gz: db5f011b7eb6f90695401a5de2672d1f210684df87033b2592831692f17fe92a
4
+ data.tar.gz: 04c710000abbf7f491bed97d92f86b06288902058a234a048fb4927c631c7625
5
5
  SHA512:
6
- metadata.gz: ec8a5d094a5054b95a7ee2fd7b2d798a181c4ad92e81f77a1d94bf571041032431d69fa85afbf90f07bd1bd3e35306a8d45a8a994a0989c6760e8321231d99d2
7
- data.tar.gz: 32dea04aa3ad82a0033c8505794e2dd6fb959f0fdef51a00dbacd53a083358f0a2ac81628f1feccb745169e163f6c1301400de2c26487167aa2b0064f734551d
6
+ metadata.gz: 3f194fdcf1896b83ed82d4fe6546e3918839bf0e65b0ebf69fe8ca0a63ad20219ca5183f5808b74333cf234c4961b747d2d937239086c54e2b7c24f3ca174e0e
7
+ data.tar.gz: 7b2f42b11e823c4f2668a8d7802c97c0b69754ea502e2985e1b15c1a2c0a016be18b70032917de1c95465e1af5adfcc31edba4a648e1f1cae94b72ff30e2d51c
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ ### 0.1.0
2
2
  ### 0.0.2 / 2026-07-23
3
3
 
4
4
  * Everything is new. First release.
data/bin/fbhub CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  ##
8
8
  ## note - always use latest (local) if present
9
- $LOAD_PATH.unshift( '/sports/yorobot/fbup/fbup/lib' )
10
- require 'fbup'
9
+ $LOAD_PATH.unshift( '/sports/yorobot/fbup/openfootball/lib' )
10
+ require 'openfootball'
11
11
 
12
12
  ##
13
13
  ## note - always use latest (local) if present
@@ -49,7 +49,7 @@ def read_config_pp( *paths )
49
49
  opts_full: {}.merge( FORMAT_OPTS_FULL_DEFAULTS, _parse_format_opts( rec['opts_full'] )),
50
50
  }
51
51
 
52
- config[ key ] = h
52
+ config[ key.to_sym ] = h
53
53
  end
54
54
  end
55
55
  config
@@ -4,20 +4,35 @@ code, name, seasons, opts, opts_full
4
4
  ##
5
5
  ## remove seasons - why? why not?
6
6
 
7
- at, Austria | Bundesliga, 2025/26,,
8
- de, Germany | Bundesliga, 2025/26,,
9
- eng, England | Premier League, 2025/26,,
7
+ at, Austria | Bundesliga, 2026/27 2025/26,,
8
+ at.cup, Austria | Cup, 2026/27 2025/26,,
10
9
 
10
+ de, Germany | Bundesliga, 2026/27 2025/26,,
11
+ eng, England | Premier League, 2026/27 2025/26,,
11
12
 
12
- fr, France | Ligue 1, 2025/26,,
13
- it, Italy | Serie A, 2025/26,,
14
- es, Spain | Primera División, 2025/26,,
15
13
 
16
- mx, Mexico | Liga MX, 2025/26,,
14
+ fr, France | Ligue 1, 2026/27 2025/26,,
15
+ it, Italy | Serie A, 2026/27 2025/26,,
16
+ es, Spain | Primera División, 2026/27 2025/26,,
17
17
 
18
- uefa.cl, UEFA | Champions League, 2025/26, country|city, country
19
- uefa.europa, UEFA | Europa League, 2025/26, country|city, country
20
- uefa.con, UEFA | Conference League, 2025/26, country|city, country
18
+
19
+ be, Belgium | First Division A, 2026/27,,
20
+ ch, Switzerland | Super League, 2026/27,,
21
+ cz, Czech Republic | First League, 2026/27,,
22
+
23
+ gr, Greece | Super League, 2026/27,,
24
+ tr, Turkey | Süper Lig, 2026/27,,
25
+
26
+ sco, Scotland | Premiership, 2026/27,,
27
+
28
+
29
+ uefa.cl, UEFA | Champions League, 2026/27 2025/26, country|city, country
30
+ uefa.europa, UEFA | Europa League, 2026/27 2025/26, country|city, country
31
+ uefa.con, UEFA | Conference League, 2026/27 2025/26, country|city, country
32
+
33
+
34
+
35
+ mx, Mexico | Liga MX, 2026/27 2025/26,,
21
36
 
22
37
  ###
23
38
  # opts
@@ -62,10 +62,8 @@ def calc_start_end_dates
62
62
 
63
63
  @data['matches'].each do |_m|
64
64
 
65
- ## date_utc = parse_date_utc( _m['datetime_utc'] )
66
- date_local = parse_date_local( _m['datetime_local'] )
67
-
68
65
  ## note - alway use local datetime for now
66
+ date_local = Date.strptime( _m['date_local'], '%Y-%m-%d' )
69
67
 
70
68
  if start_date.nil? || date_local < start_date
71
69
  start_date = date_local
@@ -8,7 +8,9 @@ class Match
8
8
 
9
9
  attr_reader :team1, :team2,
10
10
  :score,
11
- :date_utc, :date_local, :utc_offset,
11
+ :datetime_utc,
12
+ :date_local,
13
+ :time_local, :utc_offset,
12
14
  :stadium,
13
15
  :goals1, :goals2
14
16
 
@@ -25,21 +27,33 @@ def initialize( doc, data )
25
27
  @team2 = @doc.find_team!( @h['team2'] )
26
28
 
27
29
 
28
- @date_utc = parse_date_utc( @h['datetime_utc'] )
29
- @date_local = parse_date_local( @h['datetime_local'] )
30
30
 
31
- assert( @date_utc.sec == 0 && @date_local.sec == 0,
32
- "sec 00 expected" )
31
+ ####
32
+ # note - match might NOT be timed only scheduled (e.g. only date no time)
33
33
 
34
- ## note: returns Rational (e.g. 3/1 or 1/4 etc.) use to_f/to_i to convert
35
- ## diff_in_hours = ((localDateTime - dateTime) * 24).to_f
36
- ## diff_in_days = localDateTime.jd - dateTime.jd
34
+ ##
35
+ ## todo/fix
36
+ ## support different date style formats - why? why not?
37
+ ## for now use/prefer:
38
+ ## "datetime_utc": "2026-08-08T16:15Z",
39
+ ## "date_local": "2026-08-08",
40
+ ## "time_local": "18:15 UTC+2",
37
41
 
38
- # note - offset is in rational fraction of a day (e.g. 1/12 for 2hours)
39
- ## was diff_in_hours
40
- @utc_offset = (@date_local.offset * 24).to_i
41
42
 
42
- ## pp [@date_utc, @date_local, @utc_offset]
43
+ if @h['date_local'] && @h['time_local'].nil?
44
+ @date_local = Date.strptime( @h['date_local'], '%Y-%m-%d' )
45
+ else
46
+ @datetime_utc = parse_date_utc( @h['datetime_utc'] )
47
+ assert( @datetime_utc.sec == 0, "sec 00 expected" )
48
+
49
+ @date_local = Date.strptime( @h['date_local'], '%Y-%m-%d' )
50
+ ## 18:15 UTC+2
51
+ ## split into 18:15 and UTC+2
52
+ @time_local, @utc_offset = @h['time_local'].split( /[ ]+/, 2)
53
+
54
+ ## pp [@datetime_utc, @date_local, @time_local, @utc_offset]
55
+ end
56
+
43
57
 
44
58
  ## note - always lookup full stadium record (use match inline only as ref)
45
59
  @stadium = @doc.find_stadium!( @h['stadium'] )
@@ -61,7 +75,7 @@ def data() @h; end
61
75
 
62
76
  ## todo - find a better name for timezone offset
63
77
  ## use utc_offset - why? why not?
64
- alias_method :diff_in_hours, :utc_offset
78
+ ## alias_method :diff_in_hours, :utc_offset
65
79
 
66
80
 
67
81
  def stage() @h['stage']; end
@@ -6,7 +6,7 @@ def self.build( score )
6
6
  if score.nil?
7
7
  raise ArgumentError, "Score.build - expected Hash or Array; got nil"
8
8
  elsif score.is_a?(Hash)
9
- new( **score.transform_keys(&:to_sym) )
9
+ new( **score.transform_keys(&:to_sym).except( :type ) )
10
10
  elsif score.is_a?(Array)
11
11
  new( reported: score )
12
12
  else
@@ -24,9 +24,11 @@ def pp_matches( season:,
24
24
  buf << "\n"
25
25
 
26
26
 
27
- last_round = nil
28
- last_date = nil
29
- last_year = nil ## track running year
27
+ last_round = nil
28
+ last_date = nil
29
+ last_time = nil
30
+ last_utc_offset = nil
31
+ last_year = nil ## track running year
30
32
 
31
33
 
32
34
  doc.each_match do |m|
@@ -42,8 +44,8 @@ doc.each_match do |m|
42
44
  ## note - make round
43
45
  ## = stage + group (optional) + matchday (optional)
44
46
  round = m.stage
45
- round += ", #{m.group}" if m.group
46
47
  round += " - #{m.matchday}" if m.matchday
48
+ round += ", #{m.group}" if m.group
47
49
 
48
50
 
49
51
 
@@ -54,7 +56,9 @@ doc.each_match do |m|
54
56
  buf << "▪ #{round}\n"
55
57
 
56
58
  last_round = round
57
- last_date = nil
59
+ last_date = nil
60
+ last_time = nil
61
+ last_utc_offsset = nil
58
62
  end
59
63
 
60
64
 
@@ -70,15 +74,22 @@ doc.each_match do |m|
70
74
  else
71
75
  buf << "#{m.date_local.strftime('%a %b %-e')}\n"
72
76
  end
77
+ last_time = nil
78
+ last_utc_offsset = nil
73
79
  end
74
80
 
75
-
76
- ## always print time for now
77
- if opts.timezone?
78
- ## use 20:30 UTC+1 or 20:30 UTC-3
79
- buf << " #{m.date_local.strftime( '%H:%M' )} UTC%+d" % m.diff_in_hours
81
+ ## note - skip printing same time again (use inheritance)
82
+ if m.time_local.nil? ||
83
+ (last_time == m.time_local &&
84
+ last_utc_offset == m.utc_offset)
85
+ buf << " "
80
86
  else
81
- buf << " #{m.date_local.strftime( '%H:%M' )}"
87
+ if opts.timezone?
88
+ ## use 20:30 UTC+1 or 20:30 UTC-3
89
+ buf << " #{m.time_local} #{m.utc_offset}"
90
+ else
91
+ buf << " #{m.time_local}"
92
+ end
82
93
  end
83
94
 
84
95
 
@@ -111,8 +122,10 @@ doc.each_match do |m|
111
122
  buf << "\n"
112
123
 
113
124
 
114
- last_date = m.date_local
115
- last_year = m.date_local.year
125
+ last_date = m.date_local
126
+ last_year = m.date_local.year
127
+ last_time = m.time_local
128
+ last_utc_offset = m.utc_offset
116
129
 
117
130
 
118
131
  ## skip adding goals if teams not yet known!!
@@ -9,12 +9,19 @@ module Fbhub
9
9
 
10
10
 
11
11
  LEAGUE_CODES = {
12
- 'de' => 'de.1',
13
12
  'eng' => 'eng.1',
13
+ 'de' => 'de.1',
14
14
  'es' => 'es.1',
15
15
  'it' => 'it.1',
16
16
  'fr' => 'fr.1',
17
+
17
18
  'at' => 'at.1',
19
+ 'ch' => 'ch.1',
20
+ 'cz' => 'cz.1',
21
+ 'tr' => 'tr.1',
22
+ 'gr' => 'gr.1',
23
+ 'sco' => 'sco.1',
24
+
18
25
  'mx' => 'mx.1',
19
26
  }
20
27
 
@@ -26,7 +33,9 @@ opts = {
26
33
  push: false,
27
34
  ffwd: false,
28
35
 
29
- full: true, ## add full details page - true|false
36
+ full: false,
37
+ ## full: true, ## add full details page - true|false
38
+
30
39
  test: true, ## true, ## sets push & ffwd to false
31
40
  test_dir: './o',
32
41
  convert_dir: '/sports/cache.api.fifa',
@@ -91,17 +100,17 @@ pp datasets
91
100
  root_dir = if opts[:test]
92
101
  opts[:test_dir]
93
102
  else
94
- Fbup::GitHubSync.root # e.g. "/sports"
103
+ Openfootball::GitHubSync.root # e.g. "/sports"
95
104
  end
96
105
 
97
106
  puts " (output) root_dir: >#{root_dir}<"
98
107
 
99
108
 
100
- repos = Fbup::GitHubSync.find_repos( datasets )
109
+ repos = Openfootball.find_repos( datasets )
101
110
  puts " #{repos.size} repo(s):"
102
111
  pp repos
103
112
 
104
- sync = Fbup::GitHubSync.new( repos )
113
+ sync = Openfootball::GitHubSync.new( repos )
105
114
  puts " sync:"
106
115
  pp sync
107
116
 
@@ -112,7 +121,7 @@ sync.git_fast_forward_if_clean if opts[:ffwd]
112
121
  datasets.each do |slug, seasons|
113
122
  puts "==> gen #{slug} - #{seasons.size} seasons(s)..."
114
123
 
115
- config = CONFIGS[ slug ]
124
+ config = CONFIGS[ slug.to_sym ] ## note - use symbol for lookup!!
116
125
  if config.nil?
117
126
  puts "!! no pp config found for slug >#{slug}<; keys/codes include:"
118
127
  pp CONFIGS.keys
@@ -120,54 +129,20 @@ datasets.each do |slug, seasons|
120
129
  end
121
130
 
122
131
  seasons.each do |season|
123
- ## get repo config for flags and more
124
- repo = Fbup::GitHubSync::REPOS[ slug ]
125
- flags = repo['flags'] || {}
126
- classic_flag = flags['classic'] || false
127
-
128
- pp repo
129
-
130
-
131
- basename = nil
132
- if classic_flag
133
- league_config = Fbup::LeagueConfig.find_by( code: LEAGUE_CODES[slug]||slug,
134
- season: season )
135
- if league_config.nil?
136
- puts "!! ERROR - basename league config required for classic format; no config found for #{league_query} #{season}; sorry"
137
- exit 1
138
- end
139
- basename = league_config['basename']
140
- else
141
- ## change base name to league key
142
- ## todo - fix - make gsub smarter
143
- ## change at.cup to at_cup - why? why not?
144
- basename = (LEAGUE_CODES[slug]||slug).gsub( '.', '' )
145
- end
146
-
147
-
148
- repo_path = "#{repo['owner']}/#{repo['name']}"
149
- repo_path << "/#{repo['path']}" if repo['path'] ## note: do NOT forget to add optional extra path!!!
150
132
 
133
+ repo_path = Openfootball.mkpath( code: LEAGUE_CODES[slug]||slug,
134
+ season: season )
135
+ repo_path_full = Openfootball.mkpath( code: LEAGUE_CODES[slug]||slug,
136
+ season: season,
137
+ suffix: 'full' )
151
138
 
152
- outpath = "#{root_dir}/#{repo_path}"
153
- outpath += if classic_flag
154
- "/#{season.to_path}/#{basename}.txt"
155
- else
156
- ## note - add season "inline" (to basename) or use dir
157
- "/#{season.to_path}_#{basename}.txt"
158
- end
159
-
160
- outpath_full = "#{root_dir}/#{repo_path}"
161
- outpath_full += if classic_flag
162
- "/#{season.to_path}/#{basename}-full.txt"
163
- else
164
- ## note - add season "inline" (to basename) or use dir
165
- "/#{season.to_path}_#{basename}-full.txt"
166
- end
139
+ outpath = "#{root_dir}/#{repo_path}"
140
+ outpath_full = "#{root_dir}/#{repo_path_full}"
167
141
 
168
142
  puts " writing to >#{outpath}<..."
169
143
  puts " writing (full) to >#{outpath_full}<..."
170
144
 
145
+
171
146
  league_name = config[:name]
172
147
  format_opts = config[:opts]
173
148
  format_opts_full = config[:opts_full]
@@ -61,6 +61,7 @@ pp config
61
61
 
62
62
  if config.nil?
63
63
  ## auto-fill with defaults!!
64
+ puts "note - no config found for #{key}; using defaults"
64
65
  config = { slug: key,
65
66
  name: "#{key}",
66
67
  seasons: [],
@@ -3,8 +3,8 @@ module Fbtxt
3
3
  module Module
4
4
  module Fbpp
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 0
7
- PATCH = 2
6
+ MINOR = 1
7
+ PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbtxt-pp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-12 00:00:00.000000000 Z
11
+ date: 2026-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos