fbup 0.1.0 → 0.1.2

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: c7c21387f2e4887a83be8e19d6982447e6b3dd4e67cbf253cab5a56188628903
4
- data.tar.gz: aba15ec79f46ea99ea056157fc4d2da66b62aea9a7be6706bf735c4f27fc0d1c
3
+ metadata.gz: 33923b42a018912296afcb27db14743f78423e51544fbe92824e2e82517e3d76
4
+ data.tar.gz: 6bad9339c925d0422c7bd0f32993ea5974027d30ace711a8a6c81cf9cdf9fbd6
5
5
  SHA512:
6
- metadata.gz: acc5ee75647505da96b41bfbf0628983ced24a35e0a6acef133ce1e7c8b3f44176dbb0ad6ccd6b0b0bc4572905379f94ab2826b3bf73638ab11d4e2461f70cf9
7
- data.tar.gz: a83a02c677b5392be9b83dd90f106086769140dfeb24c80d7e60c81f63e40706e8167ea5640c7aea185ba13f43d4359aaa40ffb7c509f733ebe8e42a9f5a328c
6
+ metadata.gz: 81044d7cb605d472b002aab5c9ba181b51f80f9333d62c59ca09318c1f49884eb55f6744217d83e7acda2ea9a4bdfca0100afa9a483bd8f7047b5d992b5ad6fd
7
+ data.tar.gz: 2a9cf3a2fdbe49b3a27c5aafa8e8ba2471461e6c4f7ca3b7e4dde39fec782a59155cb37096e591459fa8b3640ee6d21451f8dc758fd1cd198baed9f5fceffd4b
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.1.0
1
+ ### 0.1.2
2
2
  ### 0.0.1 / 2024-12-29
3
3
 
4
4
  * Everything is new. First release.
data/bin/fbup CHANGED
@@ -6,7 +6,9 @@
6
6
  ## ruby -I fbup/lib fbup/bin/fbup
7
7
 
8
8
 
9
-
9
+ ## note - quick hack - auto-add local football timezones
10
+ $LOAD_PATH.unshift( '/sports/sportdb/sport.db/timezones/lib' )
11
+ $LOAD_PATH.unshift( '/sports/sportdb/sport.db/fifa/lib' )
10
12
  require 'fbup'
11
13
 
12
14
 
@@ -1,117 +1,153 @@
1
- key, path
1
+ key, path, flags
2
2
 
3
- at, austria
3
+ ## note - flags - defaults for now are v2 | flat
4
+ ##
5
+ ## v2 - v2 format (football.txt)
6
+ ## flat - add season to basename (no season directory)
7
+ ## e.g. 2023-24_at1.txt
8
+ ## classic - use season directory AND league slug for basename
9
+ ## e.g. 2023-24/1-bundesliga.txt
10
+ ##
11
+ ##
12
+ ## add archive flag for using archive style names before 2000 or such - why? why not?
4
13
 
5
- de, deutschland
6
- eng, england
7
- es, espana
8
- it, italy
9
14
 
10
- fr, europe/france
15
+ at, austria, classic
11
16
 
12
- hu, europe/hungary
13
- gr, europe/greece
14
- pt, europe/portugal
17
+ de, deutschland, classic
18
+ eng, england, classic
19
+ es, espana, classic
20
+ it, italy, classic
15
21
 
16
- ch, europe/switzerland
17
22
 
18
- tr, europe/turkey
23
+ ## todo/fix - add aliases WITHOUT repeating conifg - why? why not?
24
+ uefa.cl, champions-league, classic
25
+ uefa.champs, champions-league, classic
26
+ uefa.el, champions-league, classic
27
+ uefa.europa, champions-league, classic
28
+ uefa.conf, champions-league, classic
29
+ uefa.con, champions-league, classic
19
30
 
20
- is, europe/iceland
21
- sco, europe/scotland
22
- ie, europe/ireland
23
31
 
24
- fi, europe/finland
25
- se, europe/sweden
26
- no, europe/norway
27
- dk, europe/denmark
32
+ fr, europe/france,
28
33
 
29
- lu, europe/luxembourg
30
- be, europe/belgium
31
- nl, europe/netherlands
32
- cz, europe/czech-republic
34
+ hu, europe/hungary,
35
+ gr, europe/greece,
36
+ pt, europe/portugal,
33
37
 
34
- sk, europe/slovakia
35
- hr, europe/croatia
36
- pl, europe/poland
38
+ ch, europe/switzerland,
37
39
 
38
- ro, europe/romania
40
+ tr, europe/turkey,
39
41
 
40
- ua, europe/ukraine
42
+ is, europe/iceland,
43
+ sco, europe/scotland,
44
+ ie, europe/ireland,
41
45
 
42
- ru, europe/russia
46
+ fi, europe/finland,
47
+ se, europe/sweden,
48
+ no, europe/norway,
49
+ dk, europe/denmark,
43
50
 
51
+ lu, europe/luxembourg,
52
+ be, europe/belgium,
53
+ nl, europe/netherlands,
54
+ cz, europe/czech-republic,
44
55
 
45
- al, europe/albania
46
- ad, europe/andorra
47
- by, europe/belarus
48
- ba, europe/bosnia-herzegovina ## use bosnia-n-herzegovina ??
49
- bg, europe/bulgaria
50
- cy, europe/cyprus
51
- ee, europe/estonia
52
- lv, europe/latvia
53
- li, europe/liechtenstein
54
- lt, europe/lithuania
55
- mk, europe/north-macedonia
56
- mt, europe/malta
57
- md, europe/moldova
58
- me, europe/montenegro
56
+ sk, europe/slovakia,
57
+ hr, europe/croatia,
58
+ pl, europe/poland,
59
59
 
60
- sm, europe/san-marino
61
- rs, europe/serbia
62
- si, europe/slovenia
60
+ ro, europe/romania,
63
61
 
64
- xk, europe/kosovo
65
- kos, europe/kosovo
62
+ ua, europe/ukraine,
66
63
 
67
- am, europe/armenia
68
- az, europe/azerbaijan
69
- ge, europe/georgia
70
- fo, europe/faroe-islands
71
- gi, europe/gibraltar
64
+ ru, europe/russia,
72
65
 
73
- wal, europe/wales
74
- nir, europe/northern-ireland
75
66
 
67
+ al, europe/albania,
68
+ ad, europe/andorra,
69
+ by, europe/belarus,
70
+ ba, europe/bosnia-herzegovina, ## use bosnia-n-herzegovina ??
71
+ bg, europe/bulgaria,
72
+ cy, europe/cyprus,
73
+ ee, europe/estonia,
74
+ lv, europe/latvia,
75
+ li, europe/liechtenstein,
76
+ lt, europe/lithuania,
77
+ mk, europe/north-macedonia,
78
+ mt, europe/malta,
79
+ md, europe/moldova,
80
+ me, europe/montenegro,
76
81
 
82
+ sm, europe/san-marino,
83
+ rs, europe/serbia,
84
+ si, europe/slovenia,
77
85
 
78
- uefa.cl, champions-league
79
- uefa.champs, champions-league
80
- uefa.el, champions-league
81
- uefa.europa, champions-league
82
- uefa.conf, champions-league
83
- uefa.con, champions-league
84
86
 
85
- euro, euro
87
+ xk, europe/kosovo,
88
+ kos, europe/kosovo,
86
89
 
90
+ am, europe/armenia,
91
+ az, europe/azerbaijan,
92
+ ge, europe/georgia,
93
+ fo, europe/faroe-islands,
94
+ gi, europe/gibraltar,
87
95
 
96
+ wal, europe/wales,
97
+ nir, europe/northern-ireland,
88
98
 
89
- mx, mexico
90
99
 
91
100
 
92
- ar, south-america/argentina
93
- br, south-america/brazil
94
- co, south-america/colombia
101
+ euro, euro, ## add custom flag - why? why not?
95
102
 
96
- copa.l, south-america/copa-libertadores
97
- copa.s, south-america/copa-libertadores
98
103
 
99
104
 
100
- eg, africa/egypt
101
- ma, africa/morocco
102
- dz, africa/algeria
103
- afl, africa/african-football-league
104
- caf.cl, africa/champions-league
105
- caf.champs, africa/champions-league
106
105
 
107
106
 
108
- cn, world/asia/china
109
- jp, world/asia/japan
107
+ ar, south-america/argentina,
108
+ br, south-america/brazil,
109
+ co, south-america/colombia,
110
110
 
111
- kz, world/asia/kazakhstan
111
+ copa.l, south-america/copa-libertadores,
112
+ copa.s, south-america/copa-libertadores,
112
113
 
113
- il, world/middle-east/israel
114
114
 
115
115
 
116
+ ###
117
+ # world repo
116
118
 
117
- world, worldcup
119
+ eg, world/africa/egypt,
120
+ ma, world/africa/morocco,
121
+ dz, world/africa/algeria,
122
+
123
+ afl, world/africa/african-football-league,
124
+ caf.cl, world/africa/champions-league,
125
+ caf.champs, world/africa/champions-league,
126
+
127
+
128
+ cn, world/asia/china,
129
+ jp, world/asia/japan,
130
+
131
+ kz, world/asia/kazakhstan,
132
+
133
+ il, world/middle-east/israel,
134
+
135
+
136
+ mls, world/north-america/major-league-soccer,
137
+
138
+
139
+ mx, world/north-america/mexico,
140
+ ## todo/check - why mx config is not enough?
141
+ ## mx.2.expansion, world/north-america/mexico
142
+
143
+
144
+ ## fix/change concacaf.cl to concacaf.champs !!!
145
+ concacaf.cl, world/north-america/champions-league,
146
+ concacaf.champs, world/north-america/champions-league,
147
+
148
+
149
+
150
+ au, world/pacific/australia,
151
+
152
+
153
+ world, worldcup, ## add custom flag - why? why not?
@@ -55,7 +55,16 @@ def add( recs )
55
55
  'name' => name, ## (required)
56
56
  'path' => path ## extra/inner/inside/local path (optional)
57
57
  }
58
+
59
+ ## check for/add flags
60
+ flags = rec['flags'].split( /[ ]*[|][ ]*/ )
61
+ ## generte hash
62
+ ## e.g. v2 | flat => { 'v2' => true, 'flat' => true } etc.
63
+ flags = flags.map { |flag| [flag, true] }.to_h
64
+ @table[ rec['key'] ]['flags'] = flags if flags.size > 0
58
65
  end
66
+
67
+
59
68
  end
60
69
 
61
70
 
data/lib/fbup/main.rb CHANGED
@@ -1,5 +1,23 @@
1
1
 
2
2
  module Fbup
3
+
4
+ LEAGUE_NAMES_V2 = {
5
+ 'jp.1' => 'Japan | J1 League',
6
+ 'cn.1' => 'China | Super League',
7
+ 'kz.1' => 'Kazakhstan | Premier League',
8
+ 'eg.1' => 'Egypt | Premiership',
9
+ 'ma.1' => 'Morocco | Botola Pro 1',
10
+ 'dz.1' => 'Algeria | Ligue 1',
11
+ 'il.1' => 'Israel | Premier League',
12
+ 'au.1' => 'Australia | A-League',
13
+ ############
14
+ ## international
15
+ ## note - will fetch team pages one-by-one too to get country (codes)
16
+ 'afl' => 'African Football League',
17
+ 'caf.cl' => 'CAF Champions League',
18
+ }
19
+
20
+
3
21
  def self.main( args=ARGV )
4
22
 
5
23
  opts = {
@@ -11,9 +29,15 @@ opts = {
11
29
  debug: true,
12
30
  file: nil,
13
31
  test_dir: './o',
32
+
33
+ v1: false,
34
+ classic: false,
35
+ ## v2: false, ## v2 Football.TXT generation fromat
36
+ ## flat: false, ## use "flat" naming convention for datafile
14
37
  }
15
38
 
16
39
 
40
+
17
41
  parser = OptionParser.new do |parser|
18
42
  parser.banner = "Usage: #{$PROGRAM_NAME} [options] [args]"
19
43
 
@@ -47,6 +71,18 @@ parser = OptionParser.new do |parser|
47
71
  opts[:debug] = false
48
72
  end
49
73
 
74
+ parser.on( "--v1",
75
+ "v1 text format - default is (#{opts[:v1]})" ) do |v1|
76
+ opts[:v1] = true
77
+ end
78
+
79
+ parser.on( "--classic",
80
+ "classic names; use season in directory NOT basename - default is (#{opts[:classic]})" ) do |classic|
81
+ opts[:classic] = true
82
+ end
83
+
84
+
85
+
50
86
  parser.on( "-I DIR", "--include DIR",
51
87
  "add directory to (source) search path - default is (#{opts[:source_path].join(',')})") do |dir|
52
88
  opts[:source_path] += path
@@ -115,7 +151,6 @@ sync.git_fast_forward_if_clean if opts[:ffwd]
115
151
  datasets.validate!( source_path: source_path )
116
152
 
117
153
 
118
-
119
154
  datasets.each do |league_key, seasons|
120
155
  puts "==> gen #{league_key} - #{seasons.size} seasons(s)..."
121
156
 
@@ -131,25 +166,62 @@ datasets.each do |league_key, seasons|
131
166
  matches = SportDb::CsvMatchParser.read( path )
132
167
  puts " #{matches.size} matches"
133
168
 
169
+
170
+ ## get repo config for flags and more
171
+ repo = GitHubSync::REPOS[ league_key ]
172
+ flags = repo['flags'] || {}
173
+ classic_flag = flags['classic'] || false
174
+
175
+
134
176
  ## build
135
- txt = SportDb::TxtMatchWriter.build( matches )
177
+ txt = if opts[:v1]
178
+ ## todo - change upstream build to build_v1
179
+ SportDb::TxtMatchWriter.build( matches )
180
+ else
181
+ SportDb::TxtMatchWriter.build_v2( matches )
182
+ end
183
+
136
184
  puts txt if opts[:debug]
137
185
 
186
+
138
187
  league_name = league_info[ :name ] # e.g. Brasileiro Série A
139
188
  basename = league_info[ :basename] #.e.g 1-seriea
140
189
 
141
190
  league_name = league_name.call( season ) if league_name.is_a?( Proc ) ## is proc/func - name depends on season
142
191
  basename = basename.call( season ) if basename.is_a?( Proc ) ## is proc/func - name depends on season
143
192
 
193
+
194
+ if classic_flag || opts[:classic]
195
+ ## do nothing
196
+ else
197
+ ## add quick fix for new league name overwrites
198
+ league_name = LEAGUE_NAMES_V2[league_key] || league_name
199
+ end
200
+
201
+
202
+
144
203
  buf = String.new
145
204
  buf << "= #{league_name} #{season}\n\n"
146
205
  buf << txt
147
-
148
- repo = GitHubSync::REPOS[ league_key ]
206
+
149
207
  repo_path = "#{repo['owner']}/#{repo['name']}"
150
208
  repo_path << "/#{repo['path']}" if repo['path'] ## note: do NOT forget to add optional extra path!!!
151
209
 
152
- outpath = "#{root_dir}/#{repo_path}/#{season.to_path}/#{basename}.txt"
210
+
211
+ outpath = "#{root_dir}/#{repo_path}"
212
+
213
+
214
+ outpath += if classic_flag || opts[:classic]
215
+ "/#{season.to_path}/#{basename}.txt"
216
+ else
217
+ ## add season "inline" (to basename) or use dir
218
+ ## change base name to league key
219
+ ## todo - fix - make gsub smarter
220
+ ## change at.cup to at_cup - why? why not?
221
+ basename = league_key.gsub( '.', '' )
222
+ "/#{season.to_path}_#{basename}.txt"
223
+ end
224
+
153
225
 
154
226
  if opts[:dry]
155
227
  puts " (dry) writing to >#{outpath}<..."
data/lib/fbup/version.rb CHANGED
@@ -4,7 +4,7 @@ module Module
4
4
  module Fbup
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 1
7
- PATCH = 0
7
+ PATCH = 2
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: fbup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
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-30 00:00:00.000000000 Z
11
+ date: 2025-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitti