sportdb-writers 0.3.1 → 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: b8f8ed0e95799a14767c7ee6a1d66e5f13160b6845c5a0c7cf9f7b200ddbf48a
4
- data.tar.gz: 298302af01c42832b4f46a87f5f189fbd3fcd86a63162410d732f8310171f2cf
3
+ metadata.gz: f5b6e14ffd7c59f250270651861e017f01fdc1fd28ed191f2267d6bed3a2a21d
4
+ data.tar.gz: 45011876b106ff65f3ef3dc7d2d243c10c40c3cc986bbbbef512d32f729555d4
5
5
  SHA512:
6
- metadata.gz: 271d38df12f342e760889a50e4302f5b981326daee680779da0f855213ca2c82c6489f7a8ee5072083f8f47f5877a620ae6957b2388614bd50af6f11860c23f8
7
- data.tar.gz: d7da046a9f7c9378f2a77464a4f833b7ad4c7a4afc3f28a68385ecc288da70dc5d619282d985aea913dc4e9f1de578efc1073aac8c65b61ef7c70df2aee19826
6
+ metadata.gz: efb7a560598e3257d40a87a9c8eeb8f8bd8fc5eb8fb7070ad6dd8c45b8468e429c7bf36ec8a9318f461281ed63da2ec7439d1083f93aa62578c7187a15547193
7
+ data.tar.gz: 870215a2d271b92a86b08f7904db21e77e6e1dbae25d7db981c8fb78b781332f2b2dae808e341cac0431268c466422b33b4887c66f03d5466246f87387c48c78
data/CHANGELOG.md CHANGED
@@ -1,5 +1,4 @@
1
- ### 0.3.1
2
-
1
+ ### 0.4.1
3
2
  ### 0.0.1 / 2020-11-15
4
3
 
5
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -2,13 +2,7 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- bin/fbgen
6
- bin/fbtxt
7
- config/leagues.csv
8
- lib/sportdb/fbgen/main.rb
9
- lib/sportdb/fbtxt/main.rb
10
5
  lib/sportdb/writers.rb
11
6
  lib/sportdb/writers/goals.rb
12
- lib/sportdb/writers/league_config.rb
13
7
  lib/sportdb/writers/txt_writer.rb
14
8
  lib/sportdb/writers/version.rb
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
 
@@ -3,7 +3,7 @@ module SportDb
3
3
  module Module
4
4
  module Writers
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 3
6
+ MINOR = 4
7
7
  PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
@@ -1,11 +1,10 @@
1
1
 
2
- require 'sportdb/quick'
3
-
4
-
5
- require 'optparse' ## command-line processing; check if included updstream?
6
-
2
+ require 'sportdb/structs'
7
3
 
8
4
 
5
+ ##
6
+ ### todo/fix - add SportDb namespace for config? why? why not?
7
+ ## check where used?
9
8
  module Writer
10
9
  class Configuration
11
10
  def out_dir() @out_dir || './tmp'; end
@@ -23,34 +22,32 @@ end # module Writer
23
22
 
24
23
 
25
24
 
25
+
26
26
  ###
27
27
  # our own code
28
28
  require_relative 'writers/version'
29
-
30
- ## setup leagues (info) table
31
- require_relative 'writers/league_config'
32
-
33
- module Writer
34
- LEAGUES = SportDb::LeagueConfig.new
35
-
36
- ['leagues',
37
- ].each do |name|
38
- recs = read_csv( "#{SportDb::Module::Writers.root}/config/#{name}.csv" )
39
- LEAGUES.add( recs )
40
- end
41
- end # module Writer
42
-
43
-
44
29
  require_relative 'writers/goals'
45
30
  require_relative 'writers/txt_writer'
46
31
 
47
32
 
48
- ###
49
- # fbtxt tool
50
- require 'football/timezones' ## pulls in read_datasets, etc.
51
33
 
52
- require_relative 'fbtxt/main'
53
- require_relative 'fbgen/main'
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
54
51
 
55
52
 
56
53
 
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.3.1
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-10-15 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
@@ -64,20 +50,18 @@ dependencies:
64
50
  requirements:
65
51
  - - "~>"
66
52
  - !ruby/object:Gem::Version
67
- version: '4.1'
53
+ version: '4.2'
68
54
  type: :development
69
55
  prerelease: false
70
56
  version_requirements: !ruby/object:Gem::Requirement
71
57
  requirements:
72
58
  - - "~>"
73
59
  - !ruby/object:Gem::Version
74
- version: '4.1'
60
+ version: '4.2'
75
61
  description: sportdb-writers - sport.db writers for match schedules and results, and
76
62
  more
77
63
  email: gerald.bauer@gmail.com
78
- executables:
79
- - fbgen
80
- - fbtxt
64
+ executables: []
81
65
  extensions: []
82
66
  extra_rdoc_files:
83
67
  - CHANGELOG.md
@@ -88,14 +72,8 @@ files:
88
72
  - Manifest.txt
89
73
  - README.md
90
74
  - Rakefile
91
- - bin/fbgen
92
- - bin/fbtxt
93
- - config/leagues.csv
94
- - lib/sportdb/fbgen/main.rb
95
- - lib/sportdb/fbtxt/main.rb
96
75
  - lib/sportdb/writers.rb
97
76
  - lib/sportdb/writers/goals.rb
98
- - lib/sportdb/writers/league_config.rb
99
77
  - lib/sportdb/writers/txt_writer.rb
100
78
  - lib/sportdb/writers/version.rb
101
79
  homepage: https://github.com/sportdb/sport.db
@@ -119,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
97
  - !ruby/object:Gem::Version
120
98
  version: '0'
121
99
  requirements: []
122
- rubygems_version: 3.4.10
100
+ rubygems_version: 3.5.22
123
101
  signing_key:
124
102
  specification_version: 4
125
103
  summary: sportdb-writers - sport.db writers for match schedules and results, and more
data/bin/fbgen DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ## tip: to test run:
4
- ## ruby -I ./lib bin/fbgen
5
-
6
-
7
- require 'sportdb/writers'
8
-
9
-
10
- Fbgen.main( ARGV )
11
-
12
-
13
- puts "bye"
data/bin/fbtxt DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ## tip: to test run:
4
- ## ruby -I ./lib bin/fbtxt
5
-
6
- # $LOAD_PATH.unshift( '../../../sportdb/sport.db/parser/lib' )
7
- # $LOAD_PATH.unshift( '../../../sportdb/sport.db/sportdb-structs/lib' )
8
- # $LOAD_PATH.unshift( '../../../sportdb/sport.db/quick/lib' )
9
-
10
- require 'sportdb/writers'
11
-
12
-
13
- Fbtxt.main( ARGV )
14
-
15
-
16
- puts "bye"
17
-
data/config/leagues.csv DELETED
@@ -1,423 +0,0 @@
1
- key,name,basename,start_season,end_season
2
- caf.cl,CAF Champions League,cl,,
3
- caf.conf,CAF Confederations Cup,cafconfederationscup,,
4
- afl,African Football League,afl,,
5
- eg.1,Egypt Premiership,1-premiership,,
6
- eg.cup,Egypt Cup,cup,,
7
- eg.super,Egypt Supercup,supercup,,
8
- tn.1,Tunisia Ligue 1,ligue1,,
9
- ma.1,Morocco Botola,1-botola,,
10
- dz.1,Algeria Ligue 1,1-ligue1,,
11
- za.1,South Africa Premier League,premierleague,,
12
- za.2,South Africa National First Division,nationalfirstdivision,,
13
- za.cup,South Africa Cup,cup,,
14
- za.cup.l,South Africa Knockout,knockout,,
15
- ng.1,Nigeria Professional League,professionalleague,,
16
- ke.1,Kenya Premier League,premierleague,,
17
- zm.1,Zambia Super League,superleague,,
18
- gh.1,Ghana Premier League,premierleague,,
19
- ug.1,Uganda Super League,superleague,,
20
- zw.1,Zimbabwe Premier Soccer League,premiersoccerleague,,
21
- bi.1,Burundi 1. Liga,1liga,,
22
- ao.1,Angola Girabola,girabola,,
23
- tz.1,Tanzania Premier League,premierleague,,
24
- mu.1,Mauritius Premier League,premierleague,,
25
- mu.cup,Mauritius Cup,cup,,
26
- mu.cup.rep,Mauritius Republic Cup,republiccup,,
27
- asia.cl,AFC Champions League,afcchampionsleague,,
28
- asia.cup,AFC Cup,afccup,,
29
- jp.1,Japan J. League,1-jleague,,
30
- jp.2,Japan J. League 2,jleague2,,
31
- jp.cup,Japan Emperor's Cup,emperorscup,,
32
- jp.cup.l,Japan J. League Cup,jleaguecup,,
33
- kr.1,South Korea K-League,kleague,,
34
- kr.2,South Korea K-League 2,kleague2,,
35
- kr.cup,South Korea Cup,cup,,
36
- sg.1,Singapore Premier League,premierleague,,
37
- th.1,Thailand Premier League,premierleague,,
38
- my.1,Malaysia Super League,superleague,,
39
- mm.1,Myanmar National League,nationalleague,,
40
- id.1,Indonesia Super League,superleague,,
41
- in.1.i,India I-League,ileague,,
42
- in.1.ii,India Super League,superleague,,
43
- tw.1,Taiwan Premier League,premierleague,,
44
- cn.1,China Super League,1-superleague,,
45
- kz.1,Kazakhstan Premier League A,1-premierleague,,
46
- tm.1,Turkmenistan 1. Liga,1liga,,
47
- uz.1,Uzbekistan Super League,superleague,,
48
- tj.1,Tajikistan Higher League,higherleague,,
49
- tj.super,Tajikistan Super Cup,supercup,,
50
- vn.1,Vietnam V. League 1,vleague1,,
51
- vn.cup,Vietnam Cup,cup,,
52
- jm.1,Jamaica Premier League,premierleague,,
53
- cr.1,Costa Rica Primera División,primeradivision,,
54
- cr.2,Costa Rica Segunda División,segundadivision,,
55
- hn.1,Honduras Primera División,primeradivision,,
56
- sv.1,El Salvador Primera División,primeradivision,,
57
- gt.1,Guatemala Liga Nacional,liganacional,,
58
- ni.1,Nicaragua Primera División,primeradivision,,
59
- at.1,Österr. Bundesliga,1-bundesliga,,
60
- at.2,Österr. 2. Liga,2-liga2,2018/19,
61
- at.2,Österr. Erste Liga,2-liga1,,2017/18
62
- at.3.o,Österr. Regionalliga Ost,3-regionalliga-ost,,
63
- at.3.m,Österr. Regionalliga Mitte,3-regionalliga-mitte,,
64
- at.3.sbg,Österr. Regionalliga Salzburg,regionalligasalzburg,,
65
- at.3.t,Österr. Regionalliga Tirol,regionalligatirol,,
66
- at.3.v,Österr. Regionalliga Vorarlberg,regionalligavorarlberg,,
67
- at.3.w,Österr. Regionalliga West,regionalligawest,,
68
- at.cup,ÖFB Cup,cup,,
69
- at.4.ost.w,Österr. Wiener Stadtliga,wienerstadtliga,,
70
- at.4.ost.n,Österr. Landesliga Niederösterreich,landesliganiederosterreich,,
71
- at.4.ost.b,Österr. Landesliga Burgenland,landesligaburgenland,,
72
- at.4.mitte.st,Österr. Steirische Landesliga,steirischelandesliga,,
73
- at.4.mitte.o,Österr. Landesliga Oberösterreich,landesligaoberosterreich,,
74
- at.4.mitte.k,Österr. Kärtner Liga,kartnerliga,,
75
- at.4.west.s,Österr. Salzburger Liga,salzburgerliga,,
76
- at.4.west.t,Österr. Tiroler Liga,tirolerliga,,
77
- at.4.west.v,Österr. Vorarlberg Liga,vorarlbergliga,,
78
- at.5.n.ost,Österr. 2. Landesliga Ost (NÖ),2landesligaostno,,
79
- at.5.n.west,Österr. 2. Landesliga West (NÖ),2landesligawestno,,
80
- at.6.n.ost.sso,Österr. Gebietsliga Süd/Südost (NÖ),gebietsligasudsudostno,,
81
- at.6.n.ost.nnw,Österr. Gebietsliga Nord/Nordwest (NÖ),gebietsliganordnordwestno,,
82
- at.6.n.west.w,Österr. Gebietsliga West (NÖ),gebietsligawestno,,
83
- at.6.n.west.nww,Österr. Gebietsliga Nordwest/Waldviertel (NÖ),gebietsliganordwestwaldviertelno,,
84
- at.7.n.ost.sso.s,Österr. 1. Klasse Süd (NÖ),1klassesudno,,
85
- at.7.n.ost.sso.o,Österr. 1. Klasse Ost (NÖ),1klasseostno,,
86
- at.7.n.ost.nnw.n,Österr. 1. Klasse Nord (NÖ),1klassenordno,,
87
- at.7.n.ost.nnw.nw,Österr. 1. Klasse Nordwest (NÖ),1klassenordwestno,,
88
- at.7.n.west.w.w,Österr. 1. Klasse West (NÖ),1klassewestno,,
89
- at.7.n.west.w.wm,Österr. 1. Klasse West-Mitte (NÖ),1klassewestmitteno,,
90
- at.7.n.west.nww.nwm,Österr. 1. Klasse Nordwest-Mitte (NÖ),1klassenordwestmitteno,,
91
- at.7.n.west.nww.w,Österr. 1. Klasse Waldviertel (NÖ),1klassewaldviertelno,,
92
- at.8.n.steinfeld,Österr. 2. Klasse Steinfeld (NÖ),2klassesteinfeldno,,
93
- at.8.n.wechsel,Österr. 2. Klasse Wechsel (NÖ),2klassewechselno,,
94
- at.8.n.triestingtal,Österr. 2. Klasse Triestingtal (NÖ),2klassetriestingtalno,,
95
- at.8.n.ostmitte,Österr. 2. Klasse Ost/Mitte (NÖ),2klasseostmitteno,,
96
- at.8.n.ost,Österr. 2. Klasse Ost (NÖ),2klasseostno,,
97
- at.8.n.weinviertel.n,Österr. 2. Klasse Weinviertel Nord (NÖ),2klasseweinviertelnordno,,
98
- at.8.n.weinviertel.s,Österr. 2. Klasse Weinviertel Süd (NÖ),2klasseweinviertelsudno,,
99
- at.8.n.marchfeld,Österr. 2. Klasse Marchfeld (NÖ),2klassemarchfeldno,,
100
- at.8.n.donau,Österr. 2. Klasse Donau (NÖ),2klassedonauno,,
101
- at.8.n.pulkautal,Österr. 2. Klasse Pulkautal (NÖ),2klassepulkautalno,,
102
- at.8.n.ybbstal,Österr. 2. Klasse Ybbstal (NÖ),2klasseybbstalno,,
103
- at.8.n.yspertal,Österr. 2. Klasse Yspertal (NÖ),2klasseyspertalno,,
104
- at.8.n.alpenvorland,Österr. 2. Klasse Alpenvorland (NÖ),2klassealpenvorlandno,,
105
- at.8.n.traisental,Österr. 2. Klasse Traisental (NÖ),2klassetraisentalno,,
106
- at.8.n.wachau,Österr. 2. Klasse Wachau (NÖ),2klassewachauno,,
107
- at.8.n.schmidatal,Österr. 2. Klasse Schmidatal (NÖ),2klasseschmidatalno,,
108
- at.8.n.waldviertelthayatal,Österr. 2. Klasse Waldviertel Thayatal (NÖ),2klassewaldviertelthayatalno,,
109
- at.8.n.waldviertel.s,Österr. 2. Klasse Waldviertel/Süd (NÖ),2klassewaldviertelsudno,,
110
- at.9.n.hornerwald,Österr. 3. Klasse Hornerwald (NÖ),3klassehornerwaldno,,
111
- at.9.n.mistelbach,Österr. 3. Klasse Mistelbach (NÖ),3klassemistelbachno,,
112
- eng.2,English Championship,2-championship,2004/05,
113
- eng.2,English Division One,2-division1,1992/93,2003/04
114
- eng.1,English Division One,1-division1,1892/93,1991/92
115
- eng.1,English Football League,1-footballleague,1888/89,1891/92
116
- eng.3,English League One,3-league1,2004/05,
117
- eng.3,English Division Two,3-division2,1992/93,2003/04
118
- eng.2,English Division Two,2-division2,1892/93,1991/92
119
- eng.4,English League Two,4-league2,2004/05,
120
- eng.4,English Division Three,4-division3,1992/93,2003/04
121
- eng.3,English Division Three,3-division3,,1991/92
122
- eng.1,English Premier League,1-premierleague,1992/93,
123
- eng.5,English National League,5-nationalleague,1992/93,
124
- eng.3.a,English Division Three (North),3a-division3_north,,
125
- eng.3.b,English Division Three (South),3b-division3_south,,
126
- eng.cup,English FA Cup,facup,,
127
- eng.super,English FA Community Shield,facommunityshield,,
128
- eng.cup.l,English EFL Cup,eflcup,,
129
- eng.cup.t,English EFL Trophy,efltrophy,,
130
- eng.cup.t.ii,English FA Trophy,fatrophy,,
131
- de.1,Deutsche Bundesliga,1-bundesliga,,
132
- de.2,Deutsche 2. Bundesliga,2-bundesliga2,,
133
- de.3,Deutsche 3. Liga,3-liga3,,
134
- de.cup,DFB Pokal,cup,,
135
- de.super,Deutsche Supercup,super,,
136
- de.4.nord,Deutsche Regionalliga Nord,4-regionalliga-nord,,
137
- de.4.nordost,Deutsche Regionalliga Nordost,4-regionalliga-nordost,,
138
- de.4.west,Deutsche Regionalliga West,4-regionalliga-west,,
139
- de.4.suedwest,Deutsche Regionalliga Südwest,4-regionalliga-suedwest,,
140
- de.4.bayern,Deutsche Regionalliga Bayern,4-regionalliga-bayern,,
141
- de.5.nord.sh,Deutsche Schleswig-Holstein-Liga,schleswigholsteinliga,,
142
- de.5.nord.hh,Deutsche Oberliga Hamburg,oberligahamburg,,
143
- de.5.nord.hb,Deutsche Bremen-Liga,bremenliga,,
144
- de.5.nord.ni,Deutsche Oberliga Niedersachsen,oberliganiedersachsen,,
145
- de.5.nordost.n,Deutsche Oberliga Nordost (Nord),oberliganordostnord,,
146
- de.5.nordost.s,Deutsche Oberliga Nordost (Süd),oberliganordostsud,,
147
- de.5.west.niederrhein,Deutsche Oberliga Niederrhein,oberliganiederrhein,,
148
- de.5.west.mittelrhein,Deutsche Mittelrheinliga,mittelrheinliga,,
149
- de.5.west.westfalen,Deutsche Oberliga Westfalen,oberligawestfalen,,
150
- de.5.suedwest.rp.sl,Deutsche Oberliga Rheinland-Pfalz/Saar,oberligarheinlandpfalzsaar,,
151
- de.5.suedwest.he,Deutsche Hessenliga,hessenliga,,
152
- de.5.suedwest.bw,Deutsche Oberliga Baden-Württemberg,oberligabadenwurttemberg,,
153
- de.5.by.n,Deutsche Bayernliga (Nord),bayernliganord,,
154
- de.5.by.s,Deutsche Bayernliga (Süd),bayernligasud,,
155
- uefa.cl,UEFA Champions League,cl,1992/93,
156
- uefa.cl.quali,UEFA Champions League - Quali,uefachampionsleaguequali,1992/93,
157
- euro.champs,European Champion Clubs' Cup,champs,1955/56,1991/92
158
- euro.cup,European Cup Winners' Cup,cupwinners,1960/61,1998/99
159
- uefa.el,UEFA Europa League,el,2009/10,
160
- uefa.el.quali,UEFA Europa League - Quali,uefaeuropaleaguequali,2009/10,
161
- uefa.cup,UEFA Cup,cup,1971/72,2008/09
162
- uefa.conf,UEFA Conference League,conf,2021/22,
163
- uefa.conf.quali,UEFA Conference League - Quali,uefaconferenceleaguequali,2021/22,
164
- uefa.super,UEFA Super Cup,super,1972,
165
- atl.cup,Atlantic Cup,atlanticcup,,
166
- czsk.super,Czechoslovak Supercup,czechoslovaksupercup,,
167
- sco.1,Scottish Premiership,1-premiership,,
168
- sco.2,Scottish Championship,championship,,
169
- sco.3,Scottish League One,leagueone,,
170
- sco.4,Scottish League Two,leaguetwo,,
171
- sco.cup.l,Scottish League Cup,leaguecup,,
172
- sco.cup.fa,Scottish FA Cup,facup,,
173
- sco.cup.cc,Scottish Challenge Cup,challengecup,,
174
- wal.1,Welsh Premier League,1-premierleague,,
175
- nir.1,Northern Irish Premiership,1-premiership,,
176
- nir.2,Northern Irish Championship,championship,,
177
- nir.cup.l,Northern Irish League Cup,leaguecup,,
178
- nir.cup,Northern Irish Irish Cup,irishcup,,
179
- nir.super,Northern Irish NIFL Charity Shield,niflcharityshield,,
180
- ie.1,Irish Premier Division,1-premierdivision,,
181
- ie.2,Irish First Division,firstdivision,,
182
- ie.cup.l,Irish League Cup,leaguecup,,
183
- ie.super,Irish Supercup,supercup,,
184
- ie.cup,Irish FAI Cup,faicup,,
185
- is.1,Iceland Urvalsdeild,1-urvalsdeild,,
186
- is.2,Iceland 1. Deild,1deild,,
187
- is.3,Iceland 2. Delid,2delid,,
188
- is.cup,Iceland Cup,cup,,
189
- is.cup.l,Iceland League Cup,leaguecup,,
190
- is.super,Iceland Super Cup,supercup,,
191
- fo.1,Faroe Islands Premier Division,1-premierdivision,,
192
- es.1,Primera División de España,1-liga,,
193
- es.2,Segunda División de España,2-liga2,,
194
- es.3,Spain Segunda División B,segundadivisionb,,
195
- es.cup,Copa del Rey de España,cup,,
196
- es.super,Spain Supercopa,supercopa,,
197
- pt.1,Portuguese Primeira Liga,1-primeiraliga,,
198
- pt.2,Portuguese Segunda Liga,2-segundaliga,,
199
- pt.cup,Portuguese Taça de Portugal,tacadeportugal,,
200
- pt.cup.l,Portuguese Taça da Liga,tacadaliga,,
201
- pt.super,Portuguese Supercup,supercup,,
202
- gi.1,Gibraltar Premier League A,1-premierleague,,
203
- ad.1,Andorra Premier Division,1-premierdisvision,,
204
- fr.1,French Ligue 1,1-ligue1,,
205
- fr.2,French Ligue 2,2-ligue2,,
206
- fr.3,French National,national,,
207
- fr.cup,French Coupe de France,cup,,
208
- fr.cup.l,French Coupe de la Ligue,coupedelaligue,,
209
- fr.super,French Trophée des Champions,tropheedeschampions,,
210
- it.1,Italian Serie A,1-seriea,,
211
- it.2,Italian Serie B,2-serieb,,
212
- it.3.a,Italian Serie C (North & Central West),seriecnorthcentralwest,,
213
- it.3.b,Italian Serie C (North & Central East),seriecnorthcentraleast,,
214
- it.3.c,Italian Serie C (South),seriecsouth,,
215
- it.cup,Coppa Italia,cup,,
216
- it.cup.c,Italian Coppa Italia Serie C,coppaitaliaseriec,,
217
- it.super,Italian Supercoppa Italiana,supercoppaitaliana,,
218
- sm.1,San Marinese Championship,1-championship,,
219
- tr.1,Turkish Süper Lig,1-superlig,,
220
- tr.2,Turkish 1. Lig,2-lig1,,
221
- tr.3.b,Turkish 2. Lig - Beya,2ligbeya,,
222
- tr.3.ki,Turkish 2. Lig - Kirmizi,2ligkirmizi,,
223
- tr.3.playoffs,Turkish 2. Lig - Play Offs,2ligplayoffs,,
224
- tr.cup,Türkiye Kupasi,turkiyekupasi,,
225
- tr.super,Turkish Süper Kupa,superkupa,,
226
- gr.1,Greek Super League,1-superleague,,
227
- gr.2,Greek Super League 2,superleague2,,
228
- gr.cup,Greek Greek Cup,greekcup,,
229
- cy.1,Cyprus First Division,1-firstdivision,,
230
- cy.cup,Cyprus Cypriot Cup,cypriotcup,,
231
- mt.1,Malta Premier League,1-premierleague,,
232
- mt.cup,Malta Cup,cup,,
233
- dk.1,Denmark Superligaen,1-superligaen,,
234
- dk.2,Denmark 1. Division,1division,,
235
- dk.cup,Denmark Landspokalturneringen,landspokalturneringen,,
236
- no.1,Norway Eliteserien,1-eliteserien,,
237
- no.2,Norway 1. Division,1division,,
238
- no.3,Norway 2. Division,2division,,
239
- no.cup,Norway Norwegian Football Cup,norwegianfootballcup,,
240
- se.1,Sweden Allsvenskan,1-allsvenskan,,
241
- se.2,Sweden Superettan,2-superettan,,
242
- se.3.s,Sweden Div 1 Södra,div1sodra,,
243
- se.3.n,Sweden Div 1 Norra,div1norra,,
244
- se.cup,Sweden Cup,cup,,
245
- fi.1,Finland Veikkausliiga,1-veikkausliiga,,
246
- fi.2,Finland Ykkonen,ykkonen,,
247
- fi.3,Finland Kakkonen,kakkonen,,
248
- fi.4.a,Finland Kakkonen Group A,kakkonengroupa,,
249
- fi.cup,Finland Cup,cup,,
250
- nl.1,Netherlands Eredivisie,1-eredivisie,,
251
- nl.1.comeback,Netherlands Eredivisie Comeback Tournament,eredivisiecomebacktournament,,
252
- nl.2,Netherlands Eerste Divisie,eerstedivisie,,
253
- nl.cup,Netherlands Cup,cup,,
254
- nl.super,Netherlands Johan Cruijff Schaal,johancruijffschaal,,
255
- nl.po,Netherlands Promotion/Relegation Playoffs,promotionrelegationplayoffs,,
256
- be.1,Belgium First Division A,1-firstdivisiona,,
257
- be.2,Belgium First Division B,firstdivisionb,,
258
- be.cup,Beker van Belgie,bekervanbelgie,,
259
- be.super,Belgium Supercup,supercup,,
260
- lu.1,Luxembourg National Division,1-nationaldivision,,
261
- pl.1,Poland Ekstraklasa,1-ekstraklasa,,
262
- pl.2,Poland I Liga,iliga,,
263
- pl.3,Poland II Liga,iiliga,,
264
- pl.cup,Poland Cup,cup,,
265
- pl.super,Poland Supercup,supercup,,
266
- hu.1,Hungarian Nemzeti Bajnokság I,1-nbi,,
267
- hu.2,Hungarian Nemzeti Bajnokság II,2-nbii,,
268
- hu.cup,Hungarian Cup,cup,,
269
- cz.1,Czech Republic First League,1-firstleague,,
270
- cz.2,Czech Republic 1. Division,1division,,
271
- cz.cup,Czech Republic Cup,cup,,
272
- ch.1,Swiss Super League,1-superleague,,
273
- ch.2,Swiss Challenge League,2-challengeleague,,
274
- ch.3,Swiss Promotion League,promotionleague,,
275
- ch.cup,Swiss Cup,cup,,
276
- li.cup,Liechtensteiner Pokal,cup,,
277
- sk.1,Slovakia First League,1-liga1,,
278
- sk.2,Slovakia Second League,secondleague,,
279
- sk.cup,Slovakia Cup,cup,,
280
- si.1,Slovenia First League,1-firstleague,,
281
- si.2,Slovenia Second League,secondleague,,
282
- si.cup,Slovenia Cup,cup,,
283
- hr.1,Croatia HNL,1-hnl,,
284
- hr.2,Croatia Prva NL,prvanl,,
285
- hr.3,Croatia Druga NL,druganl,,
286
- hr.cup,Croatia Cup,cup,,
287
- hr.super,Croatia Supercup,supercup,,
288
- ba.1,Bosnia and Herzegovina Premier Liga,1-premierliga,,
289
- ba.cup,Bosnia and Herzegovina Cup,cup,,
290
- rs.1,Serbia Super League,1-superleague,,
291
- rs.cup,Serbia Cup,cup,,
292
- kos.1,Kosovo Superliga A,1-superliga,,
293
- al.1,Albania Super League,1-superleague,,
294
- md.1,Moldova First Division,1-firstdivision,,
295
- me.1,Montenegro First League,1-firstleague,,
296
- me.cup,Montenegro Cup,cup,,
297
- mk.1,North Macedonia First League,1-firstleague,,
298
- ro.1,Romania Liga 1,1-liga1,,
299
- ro.2,Romania Liga 2,liga2,,
300
- ro.3.a,Romania Liga 3 - Seria 1,liga3seria1,,
301
- ro.cup,Romania Cup,cup,,
302
- ro.super,Romania Supercup,supercup,,
303
- bg.1,Bulgaria Premier League,1-premierleague,,
304
- bg.cup,Bulgaria Cup,cup,,
305
- bg.super,Bulgaria Supercup,supercup,,
306
- lv.1,Latvia Higher League,1-higherleague,,
307
- lt.1,Lithuania First Division,1-firstdivision,,
308
- ee.1,Estonia Meistriliiga,1-meistriliiga,,
309
- ee.cup,Estonia Cup,cup,,
310
- ru.1,Russia Premier League,1-premierliga,,
311
- ru.2,Russia 1. Division,2-division1,,
312
- ru.cup,Russia Cup,cup,,
313
- ru.super,Russia Supercup,supercup,,
314
- ua.1,Ukraine Premier League,1-premierleague,,
315
- ua.cup,Ukraine Cup,cup,,
316
- ua.super,Ukraine Supercup,supercup,,
317
- by.1,Belarus Premier League,1-premierleague,,
318
- by.2,Belarus Pervaya Liga,pervayaliga,,
319
- by.3,Belarus Vtoraya Liga,vtorayaliga,,
320
- by.cup,Belarus Cup,cup,,
321
- by.res,Belarus Reserve Liga,reserveliga,,
322
- am.1,Armenia Premier League,1-premierleague,,
323
- az.1,Azerbaijan Premier League A,1-premierleague,,
324
- ge.1,Georgia Premier League A,1-premierleague,,
325
- world,World Cup,cup,,
326
- world.quali.europe,World Cup Quali Europe,worldcupqualieurope,,
327
- world.quali.northamerica,World Cup Quali North/Central America and Caribbean,worldcupqualinorthcentralamericaandcaribbean,,
328
- world.quali.southamerica,World Cup Quali South America,worldcupqualisouthamerica,,
329
- world.quali.africa,World Cup Quali Africa,worldcupqualiafrica,,
330
- world.quali.asia,World Cup Quali Asia (w/ Australia),worldcupqualiasiawaustralia,,
331
- world.quali.pacific,World Cup Quali South Pacific,worldcupqualisouthpacific,,
332
- world.quali.playoffs,World Cup Quali Intercontinental Playoffs,worldcupqualiintercontinentalplayoffs,,
333
- world.confed,Confederations Cup,confederationscup,,
334
- euro,Euro,euro,1960,
335
- euro.quali,Euro Quali,euroquali,,
336
- uefa.nl,UEFA Nations League,nl,2018/19,
337
- uefa.nl.a,UEFA Nations League A,nla,2018/19,
338
- uefa.nl.b,UEFA Nations League B,nlb,2018/19,
339
- uefa.nl.c,UEFA Nations League C,nlc,2018/19,
340
- southamerica,Copa América,copaamerica,,
341
- northamerica,Gold Cup,goldcup,,
342
- asia,Asian Cup,asiancup,,
343
- africa,Africa Cup of Nations,africacupofnations,,
344
- paficic,South Pacific Nations Cup,southpacificnationscup,,
345
- world.club,Club World Cup,clubworldcup,,
346
- il.1,Israel Premier League,1-premierleague,,
347
- il.2,Israel National League,nationalleague,,
348
- il.cup,Israel League Cup National,leaguecupnational,,
349
- il.cup.lp,Israel League Cup Premier,leaguecuppremier,,
350
- il.super,Israel Supercup,supercup,,
351
- ps.1.i,Palestine West Bank Premier League,westbankpremierleague,,
352
- ps.1.ii,Palestine Gaza Strip Premier League,gazastrippremierleague,,
353
- ps.cup.gaza,Palestine Gaza Strip Cup,gazastripcup,,
354
- sa.1,Saudi Arabia Saudi Professional League,saudiprofessionalleague,,
355
- sa.cup,Saudi Arabia King Cup,kingcup,,
356
- sa.super,Saudi Arabia Super Cup,supercup,,
357
- qa.1,Qatar Stars League,starsleague,,
358
- ir.1,Iran Pro League,proleague,,
359
- bh.1,Bahrain Premier League,premierleague,,
360
- om.cup,Oman Sultan Cup,sultancup,,
361
- concacaf.cl,CONCACAF Champions League,concacafchampionsleague,,
362
- concacaf.l,CONCACAF League,concacafleague,,
363
- usmx.cup,US & Mexican Leagues Cup,usmexicanleaguescup,,
364
- ca.1,Canada Premier League,premierleague,,
365
- us.1,Major League Soccer,majorleaguesoccer,,
366
- us.mls.back,MLS is Back Tournament,mlsisbacktournament,,
367
- us.2,United Soccer League Championship,unitedsoccerleaguechampionship,,
368
- us.3,United Soccer League One,unitedsoccerleagueone,,
369
- us.4,United Soccer League Two,unitedsoccerleaguetwo,,
370
- us.cup,US Open Cup,usopencup,,
371
- us.ncaa,United States NCAA Men's Soccer,ncaamenssoccer,,
372
- mx.1,Liga MX,1-ligamx,,
373
- mx.2,Liga de Expansión MX,2-ligaexpansionmx,2020/21,
374
- mx.2,Ascenso MX,2-ascensomx,,2019/20
375
- mx.copa,Mexico Copa MX,copamx,,
376
- au.1,Australia A-League,aleague,,
377
- au.2.qpr,Australia Queensland Premier,queenslandpremier,,
378
- au.cup,Australia FFA Cup,ffacup,,
379
- ar.1,Argentina Primera Division,1-primeradivision,,
380
- ar.2,Argentina Primera B Nacional,primerabnacional,,
381
- ar.3.metro,Argentina Primera B Metropolitana,primerabmetropolitana,,
382
- ar.3.fed,Argentina Torneo Federal A,torneofederala,,
383
- ar.4.metro,Argentina Primera C Metropolitana,primeracmetropolitana,,
384
- ar.4.fed,Argentina Torneo Federal B,torneofederalb,,
385
- ar.5.metro,Argentina Primera D Metropolitana,primeradmetropolitana,,
386
- ar.5.fed,Argentina Torneo Federal C,torneofederalc,,
387
- ar.copa,Argentina Copa Argentina,copaargentina,,
388
- ar.copa.l,Argentina Copa Superliga,copasuperliga,,
389
- ar.super,Argentina Supercopa Argentina,supercopaargentina,,
390
- br.1,Brasileiro Série A,1-seriea,,
391
- br.2,Brasileiro Série B,2-serieb,,
392
- br.3,Brasileiro Série C,3-seriec,,
393
- br.4,Brasileiro Série D,4-seried,,
394
- br.copa,Copa do Brasil,cup,,
395
- br.league,Brazil Primeira Liga,primeiraliga,,
396
- br.rs,Campeonato Gaúcho,gauchao,,
397
- br.rs.2,Brazil Divisão de Acesso Gaúcha,divisaodeacessogaucha,,
398
- br.rs.3,Brazil Terceirona,terceirona,,
399
- br.sp,Campeonato Paulista,paulistao,,
400
- br.rj,Campeonato Carioca,carioca,,
401
- br.mg,Campeonato Mineiro,mineiro,,
402
- br.paranaense,Campeonato Paranaense,paranaense,,
403
- copa.l,Copa Libertadores,libertadores,,
404
- copa.s,Copa Sudamericana,sudamericana,,
405
- recopa,Recopa Sudamericana,recopasudamericana,,
406
- py.1,Paraguay Primera Division,primeradivision,,
407
- pe.1,Peru Primera Division,primeradivision,,
408
- pe.2,Peru Segunda Division,segundadivision,,
409
- pe.copa.bic,Peru Copa Bicentenario 2019,copabicentenario2019,,
410
- bo.1,Bolivia Bolivian Primera División,bolivianprimeradivision,,
411
- cl.1,Chile Primera Divison,primeradivison,,
412
- cl.2,Chile Primera B,primerab,,
413
- cl.copa,Copa Chile,copachile,,
414
- co.1,Colombia Primera A,1-primeraa,,
415
- co.2,Colombia Primera B,primerab,,
416
- co.copa,Copa Colombia,copacolombia,,
417
- co.super,Colombia Super Cup,supercup,,
418
- uy.1,Uruguay Primera División,primeradivision,,
419
- uy.copa,Uruguay Cup,cup,,
420
- ec.1,Ecuador Serie A,seriea,,
421
- ec.2,Ecuador Serie B,serieb,,
422
- ve.1,Venezuela Primera División,primeradivision,,
423
- ve.copa,Copa Venezuela,copavenezuela,,
@@ -1,172 +0,0 @@
1
-
2
- module Fbgen
3
- def self.main( args=ARGV )
4
-
5
- opts = {
6
- source_path: [],
7
- dry: false,
8
- debug: true,
9
- file: nil,
10
- }
11
-
12
- parser = OptionParser.new do |parser|
13
- parser.banner = "Usage: #{$PROGRAM_NAME} [options] [args]"
14
-
15
- parser.on( "--dry",
16
- "dry run; do NOT write - default is (#{opts[:dry]})" ) do |dry|
17
- opts[:dry] = true
18
- end
19
- parser.on( "-q", "--quiet",
20
- "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
21
- opts[:debug] = false
22
- end
23
-
24
- parser.on( "-I DIR", "--include DIR",
25
- "add directory to (source) search path - default is (#{opts[:source_path].join(',')})") do |dir|
26
- opts[:source_path] += path
27
- end
28
-
29
- parser.on( "-f FILE", "--file FILE",
30
- "read leagues (and seasons) via .csv file") do |file|
31
- opts[:file] = file
32
- end
33
- end
34
- parser.parse!( args )
35
-
36
-
37
-
38
- if opts[:source_path].empty? &&
39
- File.exist?( '/sports/cache.api.fbdat') &&
40
- File.exist?( '/sports/cache.wfb' )
41
- opts[:source_path] << '/sports/cache.api.fbdat'
42
- opts[:source_path] << '/sports/cache.wfb'
43
- end
44
-
45
-
46
- if opts[:source_path].empty?
47
- opts[:source_path] = ['.'] ## use ./ as default
48
- end
49
-
50
- source_path = opts[:source_path]
51
-
52
-
53
- puts "OPTS:"
54
- p opts
55
- puts "ARGV:"
56
- p args
57
-
58
-
59
- datasets = if opts[:file]
60
- read_datasets( opts[:file] )
61
- else
62
- parse_datasets_args( args )
63
- end
64
-
65
- puts "datasets:"
66
- pp datasets
67
-
68
-
69
-
70
- root_dir = './o'
71
- puts " (output) root_dir: >#{root_dir}<"
72
-
73
-
74
- ### step 0 - validate and fill-in seasons etc.
75
- validate_datasets!( datasets, source_path: source_path )
76
-
77
- ## step 1 - generate
78
- datasets.each do |league_key, seasons|
79
- puts "==> gen #{league_key} - #{seasons.size} seasons(s)..."
80
-
81
- league_info = Writer::LEAGUES[ league_key ]
82
- pp league_info
83
-
84
- seasons.each do |season|
85
- filename = "#{season.to_path}/#{league_key}.csv"
86
- path = find_file( filename, path: source_path )
87
-
88
- ## get matches
89
- puts " ---> reading matches in #{path} ..."
90
- matches = SportDb::CsvMatchParser.read( path )
91
- puts " #{matches.size} matches"
92
-
93
- ## build
94
- txt = SportDb::TxtMatchWriter.build( matches )
95
- puts txt if opts[:debug]
96
-
97
- league_name = league_info[ :name ] # e.g. Brasileiro Série A
98
- league_name = league_name.call( season ) if league_name.is_a?( Proc ) ## is proc/func - name depends on season
99
-
100
- buf = String.new
101
- buf << "= #{league_name} #{season}\n\n"
102
- buf << txt
103
-
104
- outpath = "#{root_dir}/foot/#{season.to_path}/#{league_key}.txt"
105
-
106
- if opts[:dry]
107
- puts " (dry) writing to >#{outpath}<..."
108
- else
109
- write_text( outpath, buf )
110
- end
111
- end
112
- end
113
- end # method self.main
114
-
115
-
116
-
117
- def self.find_file( filename, path: )
118
- path.each do |src_dir|
119
- path = "#{src_dir}/#{filename}"
120
- return path if File.exist?( path )
121
- end
122
-
123
- ## fix - raise file not found error!!!
124
- nil ## not found - raise filenot found error - why? why not?
125
- end
126
-
127
-
128
- ### use a function for (re)use
129
- ### note - may add seasons in place!! (if seasons is empty)
130
- def self.validate_datasets!( datasets, source_path: )
131
- datasets.each do |dataset|
132
- league_key, seasons = dataset
133
-
134
- league_info = Writer::LEAGUES[ league_key ]
135
- if league_info.nil?
136
- puts "!! ERROR - no league (config) found for >#{league_key}<; sorry"
137
- exit 1
138
- end
139
-
140
-
141
- if seasons.empty?
142
- ## simple heuristic to find current season
143
- [ Season( '2024/25'), Season( '2024') ].each do |season|
144
- filename = "#{season.to_path}/#{league_key}.csv"
145
- path = find_file( filename, path: source_path )
146
- if path
147
- seasons = [season]
148
- dataset[1] = seasons
149
- break
150
- end
151
- end
152
-
153
- if seasons.empty?
154
- puts "!! ERROR - no latest auto-season via source found for #{league_key}; sorry"
155
- exit 1
156
- end
157
- end
158
-
159
- ## check source path too upfronat - why? why not?
160
- seasons.each do |season|
161
- filename = "#{season.to_path}/#{league_key}.csv"
162
- path = find_file( filename, path: source_path )
163
-
164
- if path.nil?
165
- puts "!! ERROR - no source found for #{filename}; sorry"
166
- exit 1
167
- end
168
- end
169
- end
170
- datasets
171
- end
172
- end # module Fbgen
@@ -1,37 +0,0 @@
1
-
2
- module Fbtxt
3
- def self.main( args=ARGV )
4
-
5
-
6
- opts = {
7
- }
8
-
9
- parser = OptionParser.new do |parser|
10
- parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
11
- end
12
- parser.parse!( args )
13
-
14
- puts "OPTS:"
15
- p opts
16
- puts "ARGV:"
17
- p args
18
-
19
-
20
- matches = []
21
-
22
- ## step 1 - get all matches via csv
23
- args.each do |arg|
24
- path = arg
25
- puts "==> reading matches in #{path} ..."
26
- more_matches = SportDb::CsvMatchParser.read( path )
27
- matches += more_matches
28
- end
29
-
30
- puts "#{matches.size} matches"
31
- puts
32
-
33
- txt = SportDb::TxtMatchWriter.build( matches )
34
- puts txt
35
- puts
36
- end
37
- end # module Fbtxt
@@ -1,83 +0,0 @@
1
-
2
- module SportDb
3
- class LeagueConfig
4
-
5
- def self.read( path )
6
- recs = read_csv( path )
7
- new( recs )
8
- end
9
-
10
- def initialize( recs=nil )
11
- @table = {}
12
- add( recs ) if recs
13
- end
14
-
15
-
16
- class LeagueItem
17
- def initialize
18
- @recs = []
19
- end
20
- def add( rec ) @recs << rec; end
21
- alias_method :<<, :add
22
-
23
- def find_by_season( season )
24
- @recs.each do |rec|
25
- start_season = rec['start_season']
26
- end_season = rec['end_season']
27
- return rec if (start_season.nil? || start_season <= season) &&
28
- (end_season.nil? || end_season >= season)
29
- end
30
- nil
31
- end
32
-
33
-
34
- def name_by_season( season )
35
- rec = find_by_season( season )
36
- rec ? rec['name'] : nil
37
- end
38
-
39
- def basename_by_season( season )
40
- rec = find_by_season( season )
41
- rec ? rec['basename'] : nil
42
- end
43
-
44
-
45
- def [](key)
46
- ## short cut - if only one or zero rec
47
- ## return directly
48
- if @recs.empty?
49
- nil
50
- elsif @recs.size == 1 &&
51
- @recs[0]['start_season'].nil? &&
52
- @recs[0]['end_season'].nil?
53
- @recs[0][key.to_s]
54
- else ### return proc that requires season arg
55
- case key.to_sym
56
- when :name then method(:name_by_season).to_proc
57
- when :basename then method(:basename_by_season).to_proc
58
- else
59
- nil ## return nil - why? why not?
60
- ## raise ArgumentError, "invalid key #{key}; use :name or :basename"
61
- end
62
- end
63
- end
64
- end
65
-
66
- def add( recs )
67
- recs.each do |rec|
68
- @table[ rec['key'] ] ||= LeagueItem.new
69
-
70
- ## note: auto-change seasons to season object or nil
71
- @table[ rec['key'] ] << { 'name' => rec['name'],
72
- 'basename' => rec['basename'],
73
- 'start_season' => rec['start_season'].empty? ? nil : Season.parse( rec['start_season'] ),
74
- 'end_season' => rec['end_season'].empty? ? nil : Season.parse( rec['end_season'] ),
75
- }
76
- end
77
- end
78
-
79
-
80
- def [](key) @table[ key.to_s.downcase ]; end
81
-
82
- end # class LeagueConfig
83
- end # module SportDb