fbup 0.2.1 → 0.2.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: c0cc7c6bdb92fe41bd89ddf67258bf59ce8feb70ad16c9b1908fdda37f165c03
4
- data.tar.gz: 3d7cc168bd623108f549e4c531738350065a1c7743ffd42ab0a7d7e66d89c8d1
3
+ metadata.gz: 3702c807ac8aeba8d67f0dfa4376432a9e20c940cddfcc09e01e94130ec886f0
4
+ data.tar.gz: 050c128c6dd7d70c8f6a7a0c2e0bb753c7bb8b485de2200dd9861dee39352889
5
5
  SHA512:
6
- metadata.gz: 4851fcc456089aa461f5fa01f2866c414acfa5ed75e921e58e28224fa2a23e8190e581627d36637732d4065a7a01d06f1d7c0843b26f9e7d5e3154dc1041f1c4
7
- data.tar.gz: 5c38c8ea0aa370ad42e1f9a7be5b2df211bd0989af16d14efe7a634ec5ffe07c10884a4ff672035ae396a8ce8dd0ded746ee136c8bacf63806ccda4dc27ca856
6
+ metadata.gz: f6767ba7dac8c0964111b8478a35a43cf01d0f430040efb3f0f21e07fa744344ade9a422caea1b8a4a3e7e18b83f4828d8952cbb603aa44d328b2e5794f19025
7
+ data.tar.gz: fcb90df77da3dc26e260ba607354477fd9cfa8c21de3c24f4c253531b090e1070fa1c448de2c534658f5b3be3499d650f906aa0bf579901fc2be02475cfa0f8a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.1
1
+ ### 0.2.2
2
2
  ### 0.0.1 / 2024-12-29
3
3
 
4
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -3,11 +3,6 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  bin/fbup
6
- config/leagues.csv
7
- config/openfootball.csv
8
6
  lib/fbup.rb
9
- lib/fbup/github.rb
10
- lib/fbup/github_config.rb
11
- lib/fbup/league_config.rb
12
7
  lib/fbup/main.rb
13
8
  lib/fbup/version.rb
data/Rakefile CHANGED
@@ -20,9 +20,9 @@ Hoe.spec 'fbup' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['gitti', '>= 0.6.1'],
24
23
  ['sportdb-writers', '>= 0.4.3'],
25
24
  ['leagues', '>= 0.2.1'],
25
+ ['openfootball'],
26
26
  ]
27
27
 
28
28
  self.spec_extras = {
data/bin/fbup CHANGED
@@ -9,6 +9,8 @@
9
9
  ## note - quick hack - auto-add local football timezones
10
10
  $LOAD_PATH.unshift( '/sports/sportdb/sport.db/leagues/lib' )
11
11
  $LOAD_PATH.unshift( '/sports/sportdb/sport.db/fifa/lib' )
12
+ ## note - use latest (local) if available
13
+ $LOAD_PATH.unshift( '/sports/yorobot/fbup/fbup/lib' )
12
14
  require 'fbup'
13
15
 
14
16
 
data/lib/fbup/main.rb CHANGED
@@ -3,19 +3,20 @@ module Fbup
3
3
 
4
4
  LEAGUE_NAMES_V2 = {
5
5
  'jp.1' => 'Japan | J1 League',
6
- 'cn.1' => 'China | Super League',
7
- 'kz.1' => 'Kazakhstan | Premier League',
6
+ 'cn.1' => 'China | Super League',
7
+ 'kz.1' => 'Kazakhstan | Premier League',
8
8
  'eg.1' => 'Egypt | Premiership',
9
9
  'ma.1' => 'Morocco | Botola Pro 1',
10
- 'dz.1' => 'Algeria | Ligue 1',
10
+ 'dz.1' => 'Algeria | Ligue 1',
11
11
  'il.1' => 'Israel | Premier League',
12
- 'au.1' => 'Australia | A-League',
13
- ############
14
- ## international
12
+ 'au.1' => 'Australia | A-League',
13
+
14
+ ############
15
+ ## international
15
16
  ## note - will fetch team pages one-by-one too to get country (codes)
16
17
  'afl' => 'African Football League',
17
- 'caf.cl' => 'CAF Champions League',
18
- }
18
+ 'caf.cl' => 'CAF Champions League',
19
+ }
19
20
 
20
21
 
21
22
  def self.main( args=ARGV )
@@ -122,9 +123,9 @@ source_path = opts[:source_path]
122
123
  ## todo use new LeaguesetAutofiller class - why? why not?
123
124
  ## or move code of autofiller here - why? why not?
124
125
  ##
125
- autofiller = ->(league_query) {
126
+ autofiller = ->(league_query) {
126
127
  Leagueset.autofiller( league_query, source_path: source_path )
127
- }
128
+ }
128
129
 
129
130
  datasets = if opts[:file]
130
131
  read_leagueset( opts[:file], autofill: autofiller )
@@ -174,7 +175,7 @@ datasets.each do |league_query, seasons|
174
175
 
175
176
 
176
177
  seasons.each do |season|
177
- ## note - league info requires season
178
+ ## note - league info requires season
178
179
  ## PLUS use (canoncial) league code from info!!!
179
180
  league_info = LeagueCodes.find_by( code: league_query, season: season )
180
181
  pp league_info
@@ -182,11 +183,10 @@ datasets.each do |league_query, seasons|
182
183
  league_code = league_info[ 'code' ]
183
184
  league_name = league_info[ 'name' ] # e.g. Brasileiro Série A
184
185
 
185
- ### todo/fix - move basename out of league_info
186
- ### make it github/openfootball "legacy" code
187
- ## basename = league_info[ 'basename' ] #.e.g 1-seriea
188
-
189
-
186
+ league_name = LEAGUE_NAMES_V2[league_code] || league_name
187
+
188
+
189
+
190
190
  filename = "#{season.to_path}/#{league_code}.csv"
191
191
  path = find_file( filename, path: source_path )
192
192
 
@@ -196,61 +196,30 @@ datasets.each do |league_query, seasons|
196
196
  puts " #{matches.size} matches"
197
197
 
198
198
 
199
- ## get repo config for flags and more
200
- repo = GitHubSync::REPOS[ league_code ]
201
- flags = repo['flags'] || {}
202
- classic_flag = flags['classic'] || false
203
-
204
199
 
205
200
  ## build
206
201
  txt = if opts[:v1]
207
202
  ## todo - change upstream build to build_v1
208
203
  SportDb::TxtMatchWriter.build( matches )
209
- else
204
+ else
210
205
  SportDb::TxtMatchWriter.build_v2( matches )
211
206
  end
212
207
 
213
208
  puts txt if opts[:debug]
214
209
 
215
210
 
216
-
217
- basename = nil
218
- if classic_flag || opts[:classic]
219
- league_config = LeagueConfig.find_by( code: league_query, season: season )
220
- if league_config.nil?
221
- puts "!! ERROR - basename league config required for classic format; no config found for #{league_query} #{season}; sorry"
222
- exit 1
223
- end
224
- basename = league_config['basename']
225
- else
226
- ## change base name to league key
227
- ## todo - fix - make gsub smarter
228
- ## change at.cup to at_cup - why? why not?
229
- basename = league_code.gsub( '.', '' )
230
- ## bonus - add quick fix for new league name overwrites
231
- league_name = LEAGUE_NAMES_V2[league_code] || league_name
232
- end
233
-
234
211
 
235
212
 
236
213
  buf = String.new
237
214
  buf << "= #{league_name} #{season}\n\n"
238
215
  buf << txt
239
-
240
- repo_path = "#{repo['owner']}/#{repo['name']}"
241
- repo_path << "/#{repo['path']}" if repo['path'] ## note: do NOT forget to add optional extra path!!!
242
-
243
-
244
- outpath = "#{root_dir}/#{repo_path}"
245
216
 
246
217
 
247
- outpath += if classic_flag || opts[:classic]
248
- "/#{season.to_path}/#{basename}.txt"
249
- else
250
- ## note - add season "inline" (to basename) or use dir
251
- "/#{season.to_path}_#{basename}.txt"
252
- end
253
-
218
+ ## get repo config for flags and more
219
+ repo = GitHubSync::REPOS[ league_code ]
220
+ repo_path = repo.mkpath( code: league_code, season: season,
221
+ classic: opts[:classic] )
222
+ outpath = "#{root_dir}/#{repo_path}"
254
223
 
255
224
  if opts[:dry]
256
225
  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 = 2
7
- PATCH = 1
7
+ PATCH = 2
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
data/lib/fbup.rb CHANGED
@@ -1,25 +1,17 @@
1
1
 
2
- require 'sportdb/writers'
3
- require 'leagues' ## pulls-in find_league_info, etc.
4
2
 
3
+ ## use latest if available
4
+ $LOAD_PATH.unshift( '/sports/yorobot/fbup/openfootball/lib' )
5
+ require 'openfootball'
5
6
 
6
- require 'optparse' ## command-line processing; check if included updstream?
7
-
8
- ########################
9
- # push & pull github scripts
10
- require 'gitti' ## note - requires git machinery
11
7
 
8
+ require 'sportdb/writers'
9
+ require 'leagues' ## pulls-in find_league_info, etc.
12
10
 
13
11
 
14
12
  ###
15
13
  # our own code
16
14
  require_relative 'fbup/version'
17
-
18
- require_relative 'fbup/github_config'
19
- require_relative 'fbup/github' ## github helpers/update machinery
20
-
21
- require_relative 'fbup/league_config' ## for "classic" custom basenames e.g. eng.1 => 1-premierleague etc.
22
-
23
15
  require_relative 'fbup/main'
24
16
 
25
17
 
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.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: 2025-05-02 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
- name: gitti
14
+ name: sportdb-writers
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.1
19
+ version: 0.4.3
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.6.1
26
+ version: 0.4.3
27
27
  - !ruby/object:Gem::Dependency
28
- name: sportdb-writers
28
+ name: leagues
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.3
33
+ version: 0.2.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.3
40
+ version: 0.2.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: leagues
42
+ name: openfootball
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.1
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.1
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -103,12 +103,7 @@ files:
103
103
  - README.md
104
104
  - Rakefile
105
105
  - bin/fbup
106
- - config/leagues.csv
107
- - config/openfootball.csv
108
106
  - lib/fbup.rb
109
- - lib/fbup/github.rb
110
- - lib/fbup/github_config.rb
111
- - lib/fbup/league_config.rb
112
107
  - lib/fbup/main.rb
113
108
  - lib/fbup/version.rb
114
109
  homepage: https://github.com/sportdb/sport.db
data/config/leagues.csv DELETED
@@ -1,111 +0,0 @@
1
- code,basename,start_season,end_season
2
-
3
- ########
4
- ### use a "custom" basename for "classic" leagues
5
-
6
-
7
- ####
8
- ## /austria
9
- at.1,1-bundesliga,,
10
- ## -- add new name - Erste Liga => 2. Liga
11
- at.2,2-liga2,2018/19,
12
- at.2,2-liga1,,2017/18
13
- at.3.o,3-regionalliga-ost,,
14
- at.3.m,3-regionalliga-mitte,,
15
- at.3.w,3-regionalliga-west,,
16
- at.3.sbg,3-regionalliga-salzburg,,
17
- at.3.t,3-regionalliga-tirol,,
18
- at.3.v,3-regionalliga-vorarlberg,,
19
- at.cup,cup,,
20
-
21
- ####
22
- ## /deutschland
23
- de.1,1-bundesliga,,
24
- de.2,2-bundesliga2,,
25
- de.3,3-liga3,,
26
- de.cup,cup,,
27
- de.super,super,,
28
- de.4.nord,4-regionalliga-nord,,
29
- de.4.nordost,4-regionalliga-nordost,,
30
- de.4.west,4-regionalliga-west,,
31
- de.4.suedwest,4-regionalliga-suedwest,,
32
- de.4.bayern,4-regionalliga-bayern,,
33
- # -- add alternate keys for de.4
34
- # todo/fix - find a way to add alternate keys (WITHOUT repeating basename) !!!
35
- de.4.n,4-regionalliga-nord,,
36
- de.4.no,4-regionalliga-nordost,,
37
- de.4.w,4-regionalliga-west,,
38
- de.4.sw,4-regionalliga-suedwest,,
39
-
40
- ################
41
- ## /england
42
- eng.2,2-championship,2004/05,
43
- eng.3,3-league1,2004/05,
44
- eng.4,4-league2,2004/05,
45
-
46
- eng.1,1-premierleague,1992/93,
47
- eng.2,2-division1,1992/93,2003/04
48
- eng.3,3-division2,1992/93,2003/04
49
- eng.4,4-division3,1992/93,2003/04
50
- eng.5,5-nationalleague,1992/93,
51
-
52
- eng.1,1-division1,1892/93,1991/92
53
- eng.2,2-division2,1892/93,1991/92
54
- eng.3,3-division3,,1991/92
55
- eng.3.a,3-division3-north,,
56
- eng.3.b,3-division3-south,,
57
- eng.1,1-footballleague,1888/89,1891/92
58
-
59
-
60
- ###
61
- ## fix - always use fa.cup and efl.cup - why? why not?
62
- eng.cup,facup,, ## FA CuP
63
- eng.super,super,, ## FA Community Shield
64
- eng.cup.l,eflcup,, ## EFL Cup
65
- eng.cup.t,efltrophy,, ## EFL Trophy
66
- eng.cup.t.ii,fatrophy,, ## FA Trophy
67
-
68
- ## -- add alternate codes / keys
69
- eng.fa.cup,facup,, ## FA Cup
70
- eng.efl.cup,eflcup,, ## EFL Cup
71
-
72
-
73
- #######
74
- ## /espana
75
- es.1,1-liga,,
76
- es.2,2-liga2,,
77
- es.3,3-liga2b,, ## Segunda División B
78
- es.cup,cup,,
79
- es.super,supercopa,, ## check - use only super - why? why not?
80
-
81
-
82
- #####
83
- ## /italy
84
- it.1,1-seriea,,
85
- it.2,2-serieb,,
86
- it.3.a,3-seriec_a,, ## North & Central West
87
- it.3.b,3-seriec_b,, ## North & Central East
88
- it.3.c,3-seriec_c,, ## South
89
- it.cup,cup,,
90
- it.super,super,,
91
- ## it.cup.c -- Italian Coppa Italia Serie C
92
-
93
-
94
- #####
95
- ## /champions-league - uefa incl. europa & conference
96
- uefa.cl, cl,,
97
- uefa.champs, cl,,
98
- uefa.el, el,,
99
- uefa.europa, el,,
100
- uefa.conf, conf,,
101
- uefa.con, conf,,
102
-
103
- #####
104
- ## /club-worldcup
105
- world.clubs, clubworldcup,,
106
- world.club, clubworldcup,,
107
- ## - use world.clubs or club ??
108
-
109
-
110
-
111
-
@@ -1,159 +0,0 @@
1
- key, path, flags
2
-
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?
13
-
14
-
15
- at, austria, classic
16
-
17
- de, deutschland, classic
18
- eng, england, classic
19
- es, espana, classic
20
- it, italy, classic
21
-
22
-
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
30
-
31
-
32
- fr, europe/france,
33
-
34
- hu, europe/hungary,
35
- gr, europe/greece,
36
- pt, europe/portugal,
37
-
38
- ch, europe/switzerland,
39
-
40
- tr, europe/turkey,
41
-
42
- is, europe/iceland,
43
- sco, europe/scotland,
44
- ie, europe/ireland,
45
-
46
- fi, europe/finland,
47
- se, europe/sweden,
48
- no, europe/norway,
49
- dk, europe/denmark,
50
-
51
- lu, europe/luxembourg,
52
- be, europe/belgium,
53
- nl, europe/netherlands,
54
- cz, europe/czech-republic,
55
-
56
- sk, europe/slovakia,
57
- hr, europe/croatia,
58
- pl, europe/poland,
59
-
60
- ro, europe/romania,
61
-
62
- ua, europe/ukraine,
63
-
64
- ru, europe/russia,
65
-
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,
81
-
82
- sm, europe/san-marino,
83
- rs, europe/serbia,
84
- si, europe/slovenia,
85
-
86
-
87
- xk, europe/kosovo,
88
- kos, europe/kosovo,
89
-
90
- am, europe/armenia,
91
- az, europe/azerbaijan,
92
- ge, europe/georgia,
93
- fo, europe/faroe-islands,
94
- gi, europe/gibraltar,
95
-
96
- wal, europe/wales,
97
- nir, europe/northern-ireland,
98
-
99
-
100
-
101
- euro, euro, ## add custom flag - why? why not?
102
-
103
-
104
-
105
-
106
-
107
- ar, south-america/argentina,
108
- br, south-america/brazil,
109
- co, south-america/colombia,
110
-
111
- copa.l, south-america/copa-libertadores,
112
- copa.s, south-america/copa-libertadores,
113
-
114
-
115
-
116
- ###
117
- # /world repo
118
-
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
- sa, world/middle-east/saudi-arabia,
135
-
136
-
137
- mls, world/north-america/major-league-soccer,
138
-
139
-
140
- mx, world/north-america/mexico,
141
-
142
-
143
- ## fix/change concacaf.cl to concacaf.champs !!!
144
- concacaf.cl, world/north-america/champions-league,
145
- concacaf.champs, world/north-america/champions-league,
146
-
147
-
148
-
149
- au, world/pacific/australia,
150
-
151
-
152
- ## use world.clubs or club ??
153
- world.clubs, club-worldcup, classic ## use classic setup for now - why? why not?
154
- world.club, club-worldcup, classic
155
-
156
-
157
-
158
- world, worldcup, ## add custom flag - why? why not?
159
-
data/lib/fbup/github.rb DELETED
@@ -1,115 +0,0 @@
1
-
2
- module Fbup ### rename module to Up - why? why not?
3
-
4
- ###
5
- ## todo/fix:
6
- ## add -i/--interactive flag
7
- ## will prompt yes/no before git operations (with consequences)!!!
8
-
9
-
10
-
11
- class GitHubSync
12
-
13
- ########
14
- ## (auto)default to Writer.config.out_dir - why? why not?
15
- ##
16
- ## note - is monotree (that is, requires openfootball/england etc.
17
- ## for repo pathspecs)
18
- def self.root() @root || "/sports"; end
19
- def self.root=( dir ) @root = dir; end
20
- ## use root_dir (or add alias) - why? why not?
21
-
22
-
23
- REPOS = GitHubConfig.new
24
- recs = read_csv( "#{SportDb::Module::Fbup.root}/config/openfootball.csv" )
25
- REPOS.add( recs )
26
-
27
- ## note: datasets of format
28
- ##
29
- ## DATASETS = [
30
- ## ['it.1', %w[2020/21 2019/20]],
31
- ## ['it.2', %w[2019/20]],
32
- ## ['es.1', %w[2019/20]],
33
- ## ['es.2', %w[2019/20]],
34
- ## ]
35
-
36
- def self.find_repos( datasets )
37
- repos = []
38
- datasets.each do |league_key, seasons|
39
- repo = REPOS[ league_key ]
40
- ## pp repo
41
- if repo.nil?
42
- puts "!! ERROR - no repo config/path found for league >#{league_key}<; sorry"
43
- exit 1
44
- end
45
-
46
- repos << "#{repo['owner']}/#{repo['name']}"
47
- end
48
-
49
- pp repos
50
- repos.uniq ## note: remove duplicates (e.g. europe or world or such)
51
- end
52
-
53
-
54
-
55
- def initialize( repos )
56
- @repos = repos
57
- end
58
-
59
-
60
- def git_push_if_changes
61
- message = "auto-update week #{Date.today.cweek}" ## add /#{Date.today.cday - why? why not?
62
- puts message
63
-
64
- @repos.each do |pathspec|
65
- _git_push_if_changes( pathspec, message: message )
66
- end
67
- end
68
-
69
- def git_fast_forward_if_clean
70
- @repos.each do |pathspec|
71
- _git_fast_forward_if_clean( pathspec )
72
- end
73
- end
74
-
75
-
76
-
77
- ## todo/fix: rename to something like
78
- ## git_(auto_)commit_and_push_if_changes/if_dirty()
79
-
80
- def _git_push_if_changes( pathspec, message: )
81
- path = "#{self.class.root}/#{pathspec}"
82
-
83
- Gitti::GitProject.open( path ) do |proj|
84
- puts ''
85
- puts "###########################################"
86
- puts "## trying to commit & push repo in path >#{path}<"
87
- puts "Dir.getwd: #{Dir.getwd}"
88
- output = proj.changes
89
- if output.empty?
90
- puts "no changes found; skipping commit & push"
91
- else
92
- proj.add( '.' )
93
- proj.commit( message )
94
- proj.push
95
- end
96
- end
97
- end
98
-
99
-
100
- def _git_fast_forward_if_clean( pathspec )
101
- path = "#{self.class.root}/#{pathspec}"
102
-
103
- Gitti::GitProject.open( path ) do |proj|
104
- output = proj.changes
105
- unless output.empty?
106
- puts "FAIL - cannot git pull (fast-forward) - working tree has changes:"
107
- puts output
108
- exit 1
109
- end
110
-
111
- proj.fast_forward
112
- end
113
- end
114
- end # class GitHub
115
- end # module Fbup
@@ -1,106 +0,0 @@
1
-
2
- module Fbup
3
- class GitHubConfig
4
-
5
- ## map leagues to repo+path
6
- ## e.g. fr.1 => europe/france
7
- ## eng..1 => england
8
- ##
9
- ## for other than openfootball (default)
10
- ## use @
11
- ## e.g. myorg@austria
12
- ## austria@myorg ??
13
- ##
14
- ## myorg@europe/france
15
- ## europe/france@myorg
16
-
17
-
18
- def self.read( path )
19
- recs = read_csv( path )
20
- new( recs )
21
- end
22
-
23
- def initialize( recs=nil )
24
- @table = {}
25
- add( recs ) if recs
26
- end
27
-
28
-
29
- def add( recs )
30
- recs.each do |rec|
31
- path = rec['path'] ## use pathspec - why? why not?
32
- ## or repospec or such
33
-
34
- ## auto-expand to openfootball as default org if no @ specified
35
- owner, path = if path.index( '@')
36
- path.split( '@', 2 )
37
- else
38
- ['openfootball', path ]
39
- end
40
- name, path = path.split( '/', 2 )
41
-
42
-
43
- ## openfootball@europe/france
44
- ## =>
45
- ## owner: openfootball
46
- ## name: europe
47
- ## path: france
48
- ##
49
- ## openfootball@austria
50
- ## =>
51
- ## owner: openfootball
52
- ## name: austria
53
- ## path: nil
54
- @table[ rec['key'] ] = { 'owner' => owner, ## (required)
55
- 'name' => name, ## (required)
56
- 'path' => path ## extra/inner/inside/local path (optional)
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
65
- end
66
-
67
-
68
- end
69
-
70
-
71
- ##
72
- ## todo/fix:
73
- ## make key lookup more flexible
74
- ## auto-add more variants!!!
75
- ## e.g. at.1 AT1, AT or such
76
- ##
77
-
78
- ## find (full) record by key
79
- def find( key )
80
- key = key.to_s.downcase
81
-
82
- ## first check for 1:1 match
83
- rec = @table[key]
84
- if rec.nil?
85
- ## try match by (country / first) code
86
- ## split by .
87
- key, _ = key.split( '.' )
88
- rec = @table[key]
89
- end
90
-
91
- rec
92
- end
93
- alias_method :[], :find ## keep alias - why? why not?
94
-
95
-
96
- def find_repo( key )
97
- rec = _find( key )
98
-
99
- rec ? "#{rec['owner']}/#{rec['name']}" : nil
100
- end
101
-
102
- end # class GitHubConfig
103
- end # module Fbup
104
-
105
-
106
-
@@ -1,99 +0,0 @@
1
- module Fbup
2
-
3
- ####
4
- ### check - rename to ExtraLeagueConfig or such - why? why not?
5
-
6
- class LeagueConfig
7
-
8
- def self.find_by( code:, season: )
9
- ## return league code record/item or nil
10
- builtin.find_by( code: code, season: season )
11
- end
12
-
13
-
14
- #####
15
- ## (static) helpers
16
- def self.builtin
17
- ## get builtin league code index (build on demand)
18
- @leagues ||= begin
19
- leagues = LeagueConfig.new
20
- ['leagues',
21
- ].each do |name|
22
- recs = read_csv( "#{SportDb::Module::Fbup.root}/config/#{name}.csv" )
23
- leagues.add( recs )
24
- end
25
- leagues
26
- end
27
- @leagues
28
- end
29
-
30
-
31
- def self.norm( code ) ## use norm_(league)code - why? why not?
32
- ## norm league code
33
- ## downcase
34
- ## and remove all non-letters/digits e.g. at.1 => at1, at 1 => at1 etc.
35
- ## ö.1 => ö1
36
- ## note - allow unicode letters!!!
37
- ## note - assume downcase works for unicode too e.g. Ö=>ö
38
- ## for now no need to use our own downcase - why? why not?
39
-
40
- code.downcase.gsub( /[^\p{Ll}0-9]/, '' )
41
- end
42
-
43
-
44
-
45
-
46
- def initialize
47
- @leagues = {}
48
- end
49
-
50
-
51
- def add( recs )
52
- recs.each do |rec|
53
- key = LeagueConfig.norm( rec['code'] )
54
- @leagues[ key ] ||= []
55
-
56
- ## note: auto-change seasons to season object or nil
57
- @leagues[ key ] << { 'code' => rec['code'],
58
- 'basename' => rec['basename'],
59
- 'start_season' => rec['start_season'].empty? ? nil : Season.parse( rec['start_season'] ),
60
- 'end_season' => rec['end_season'].empty? ? nil : Season.parse( rec['end_season'] ),
61
- }
62
- end
63
- end
64
-
65
-
66
- def find_by( code:, season: )
67
- raise ArgumentError, "league code as string|symbol expected" unless code.is_a?(String) || code.is_a?(Symbol)
68
-
69
- ## return league code record/item or nil
70
- ## check for alt code first
71
- season = Season( season )
72
- key = LeagueCodes.norm( code )
73
- rec = nil
74
-
75
- recs = @leagues[ key ]
76
-
77
- if recs
78
- rec = _find_by_season( recs, season )
79
- end
80
-
81
- rec ## return nil if no code record/item found
82
- end
83
-
84
-
85
- def _find_by_season( recs, season )
86
- recs.each do |rec|
87
- start_season = rec['start_season']
88
- end_season = rec['end_season']
89
- return rec if (start_season.nil? || start_season <= season) &&
90
- (end_season.nil? || end_season >= season)
91
- end
92
- nil
93
- end
94
-
95
-
96
- end # class LeagueConfig
97
-
98
-
99
- end # module Fbup