sportdb-writers 0.0.1 → 0.1.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
- SHA1:
3
- metadata.gz: 0bf61e140b088804628afc2351b7b9a32975cd75
4
- data.tar.gz: cefaf1da69870273c3eeb7130e96c943ddf29d05
2
+ SHA256:
3
+ metadata.gz: f4c4a35292a78b32475f88dc7d43246c1782dcd82c15afed36aec0b6e1143e94
4
+ data.tar.gz: 6ec7868264b09d86494f86b2a30c7577212e7e262901df415b36d2bd3c4d4d06
5
5
  SHA512:
6
- metadata.gz: 6102adb9c492d1cfe1d4d112bd4385524d78a9feaaed47cb058ca45f1db25d94d2c97e2806f75e4531a845cb6b1aba963e3f491b7465f13d2a2efc06bba8b63f
7
- data.tar.gz: de627bc67581498ccb674e23f9c68977cfd20363d8118788ab9554531cc77f158c3e949ede70c2f6f25e3f60a387710ea4572c70382d7c67c985cfdb40aefd1c
6
+ metadata.gz: 6ca5e6e0ec314d83328900e159d6f561869ba4f93d160628b012c1f16b571df3b2d7c92fb418b74fcf474bf3fd8451c03590e629318309b4cb93ee2eaee7c491
7
+ data.tar.gz: 4ed5b4c8538c9438532fb80432a7c7087f3b84c991a38d4026a4e74981759093fed3d475d9191b2f28d6c3ae776de87c3826e1f80f7531e00da28f6d4a009a3d
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ### 0.0.1 / 2020-11-15
2
-
3
- * Everything is new. First release.
4
-
1
+ ### 0.1.1
2
+
3
+ ### 0.0.1 / 2020-11-15
4
+
5
+ * Everything is new. First release.
6
+
data/Manifest.txt CHANGED
@@ -2,6 +2,8 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/fbgen
6
+ bin/fbtxt
5
7
  lib/sportdb/leagues/leagues_at.rb
6
8
  lib/sportdb/leagues/leagues_de.rb
7
9
  lib/sportdb/leagues/leagues_eng.rb
@@ -12,10 +14,8 @@ lib/sportdb/leagues/leagues_mx.rb
12
14
  lib/sportdb/leagues/leagues_south_america.rb
13
15
  lib/sportdb/leagues/leagues_world.rb
14
16
  lib/sportdb/writers.rb
15
- lib/sportdb/writers/config.rb
17
+ lib/sportdb/writers/github.rb
18
+ lib/sportdb/writers/goals.rb
16
19
  lib/sportdb/writers/txt_writer.rb
17
20
  lib/sportdb/writers/version.rb
18
21
  lib/sportdb/writers/write.rb
19
- test/helper.rb
20
- test/test_txt_writer.rb
21
- test/test_version.rb
data/README.md CHANGED
@@ -1,28 +1,26 @@
1
- # sportdb-writers - sport.db writers for match schedules and results, and more
2
-
3
- * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
4
- * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
5
- * gem :: [rubygems.org/gems/sportdb-writers](https://rubygems.org/gems/sportdb-writers)
6
- * rdoc :: [rubydoc.info/gems/sportdb-writers](http://rubydoc.info/gems/sportdb-writers)
7
- * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
8
-
9
-
10
-
11
- ## Usage
12
-
13
- To be done
14
-
15
-
16
- ## License
17
-
18
- ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
19
-
20
- The `sportdb-writers` scripts are dedicated to the public domain.
21
- Use it as you please with no restrictions whatsoever.
22
-
23
-
24
- ## Questions? Comments?
25
-
26
- Send them along to the
27
- [Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
28
- Thanks!
1
+ # sportdb-writers - sport.db writers for match schedules and results, and more
2
+
3
+ * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
4
+ * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
5
+ * gem :: [rubygems.org/gems/sportdb-writers](https://rubygems.org/gems/sportdb-writers)
6
+ * rdoc :: [rubydoc.info/gems/sportdb-writers](http://rubydoc.info/gems/sportdb-writers)
7
+ * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
8
+
9
+
10
+
11
+ ## Usage
12
+
13
+ To be done
14
+
15
+
16
+ ## License
17
+
18
+ The `sportdb-writers` scripts are dedicated to the public domain.
19
+ Use it as you please with no restrictions whatsoever.
20
+
21
+
22
+ ## Questions? Comments?
23
+
24
+ Yes, you can. More than welcome.
25
+ See [Help & Support »](https://github.com/openfootball/help)
26
+
data/Rakefile CHANGED
@@ -1,30 +1,30 @@
1
- require 'hoe'
2
- require './lib/sportdb/writers/version.rb'
3
-
4
- Hoe.spec 'sportdb-writers' do
5
-
6
- self.version = SportDb::Module::Writers::VERSION
7
-
8
- self.summary = 'sportdb-writers - sport.db writers for match schedules and results, and more'
9
- self.description = summary
10
-
11
- self.urls = { home: 'https://github.com/sportdb/sport.db' }
12
-
13
- self.author = 'Gerald Bauer'
14
- self.email = 'opensport@googlegroups.com'
15
-
16
- # switch extension to .markdown for gihub formatting
17
- self.readme_file = 'README.md'
18
- self.history_file = 'CHANGELOG.md'
19
-
20
- self.extra_deps = [
21
- ['sportdb-catalogs', '>= 1.0.0'],
22
- ]
23
-
24
- self.licenses = ['Public Domain']
25
-
26
- self.spec_extras = {
27
- required_ruby_version: '>= 2.2.2'
28
- }
29
-
30
- end
1
+ require 'hoe'
2
+ require './lib/sportdb/writers/version.rb'
3
+
4
+ Hoe.spec 'sportdb-writers' do
5
+
6
+ self.version = SportDb::Module::Writers::VERSION
7
+
8
+ self.summary = 'sportdb-writers - sport.db writers for match schedules and results, and more'
9
+ self.description = summary
10
+
11
+ self.urls = { home: 'https://github.com/sportdb/sport.db' }
12
+
13
+ self.author = 'Gerald Bauer'
14
+ self.email = 'gerald.bauer@gmail.com'
15
+
16
+ # switch extension to .markdown for gihub formatting
17
+ self.readme_file = 'README.md'
18
+ self.history_file = 'CHANGELOG.md'
19
+
20
+ self.extra_deps = [
21
+ ['sportdb-quick'],
22
+ ['gitti'],
23
+ ]
24
+
25
+ self.licenses = ['Public Domain']
26
+
27
+ self.spec_extras = {
28
+ required_ruby_version: '>= 3.1.0'
29
+ }
30
+ end
data/bin/fbgen ADDED
@@ -0,0 +1,99 @@
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
+ require 'optparse'
10
+
11
+
12
+
13
+ args=ARGV
14
+
15
+
16
+ opts = {
17
+ }
18
+
19
+ parser = OptionParser.new do |parser|
20
+ parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
21
+ end
22
+ parser.parse!( args )
23
+
24
+ puts "OPTS:"
25
+ p opts
26
+ puts "ARGV:"
27
+ p args
28
+
29
+
30
+ ### split args in datasets with leagues and seasons
31
+ datasets = []
32
+
33
+
34
+ args.each do |arg|
35
+ if arg =~ %r{^[0-9/-]+$} ## season
36
+ if datasets.empty?
37
+ puts "!! ERROR - league required before season arg; sorry"
38
+ exit 1
39
+ end
40
+
41
+ season = Season.parse( arg ) ## check season
42
+ datasets[-1][1] << season
43
+ else ## assume league key
44
+ key = arg.downcase
45
+ league_info = Writer::LEAGUES[ key ]
46
+
47
+ if league_info.nil?
48
+ puts "!! ERROR - no league found for >#{key}<; sorry"
49
+ exit 1
50
+ end
51
+
52
+ datasets << [key, []]
53
+ end
54
+ end
55
+
56
+ pp datasets
57
+
58
+
59
+ datasets.each do |league_key, seasons|
60
+ seasons = [ Season('2024/25') ] if seasons.empty?
61
+
62
+ puts "==> gen #{league_key} - #{seasons.size} seasons(s)..."
63
+
64
+ league_info = Writer::LEAGUES[ league_key ]
65
+ pp league_info
66
+
67
+ seasons.each do |season|
68
+ ### get matches
69
+ src_dir = "/sports/cache.wfb"
70
+ path = "#{src_dir}/#{season.to_path}/#{league_key}.csv"
71
+ puts " ---> reading matches in #{path} ..."
72
+ matches = SportDb::CsvMatchParser.read( path )
73
+ puts " #{matches.size} matches"
74
+
75
+ ## build
76
+ txt = SportDb::TxtMatchWriter.build( matches )
77
+ puts txt
78
+
79
+ league_name = league_info[ :name ] # e.g. Brasileiro Série A
80
+ basename = league_info[ :basename] #.e.g 1-seriea
81
+
82
+ league_name = league_name.call( season ) if league_name.is_a?( Proc ) ## is proc/func - name depends on season
83
+ basename = basename.call( season ) if basename.is_a?( Proc ) ## is proc/func - name depends on season
84
+
85
+ buf = String.new
86
+ buf << "= #{league_name} #{season}\n\n"
87
+ buf << txt
88
+
89
+ ## note - repo_path moved!!!
90
+ ## repo_path = league_info[ :path ] # e.g. brazil or world/europe/portugal etc.
91
+ repo_path = SportDb::GitHubSync::REPOS[ league_key ]
92
+
93
+ outpath = "./o/#{repo_path}/#{season.to_path}/#{basename}.txt"
94
+ write_text( outpath, buf )
95
+ end
96
+ end
97
+
98
+
99
+ puts "bye"
data/bin/fbtxt ADDED
@@ -0,0 +1,52 @@
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
+ require 'optparse'
13
+
14
+
15
+
16
+ args=ARGV
17
+
18
+
19
+ opts = {
20
+ }
21
+
22
+ parser = OptionParser.new do |parser|
23
+ parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
24
+ end
25
+ parser.parse!( args )
26
+
27
+ puts "OPTS:"
28
+ p opts
29
+ puts "ARGV:"
30
+ p args
31
+
32
+
33
+ matches = []
34
+
35
+ ## step 1 - get all matches via csv
36
+ args.each do |arg|
37
+ path = arg
38
+ puts "==> reading matches in #{path} ..."
39
+ more_matches = SportDb::CsvMatchParser.read( path )
40
+ matches += more_matches
41
+ end
42
+
43
+ puts "#{matches.size} matches"
44
+ puts
45
+
46
+
47
+ txt = SportDb::TxtMatchWriter.build( matches )
48
+ puts txt
49
+ puts
50
+
51
+ puts "bye"
52
+
@@ -1,39 +1,35 @@
1
- module Writer
2
-
3
- ########################
4
- # Austria
5
-
6
- LEAGUES.merge!(
7
- 'at.1' => { name: 'Österr. Bundesliga',
8
- basename: '1-bundesliga',
9
- path: 'austria',
10
- lang: 'de_AT',
11
- stages: ->(season) {
12
- if season.start_year >= 2018
13
- [['Grunddurchgang'],
14
- ['Finaldurchgang - Meister',
15
- 'Finaldurchgang - Qualifikation',
16
- 'Europa League Play-off']]
17
- else
18
- nil
19
- end
20
- },
21
- },
22
- 'at.2' => { name: ->(season) { season.start_year >= 2018 ? 'Österr. 2. Liga' : 'Österr. Erste Liga' },
23
- basename: ->(season) { season.start_year >= 2018 ? '2-liga2' : '2-liga1' },
24
- path: 'austria',
25
- lang: 'de_AT',
26
- },
27
- 'at.3.o' => { name: 'Österr. Regionalliga Ost',
28
- basename: '3-regionalliga-ost',
29
- path: 'austria',
30
- lang: 'de_AT',
31
- },
32
- 'at.cup' => { name: 'ÖFB Cup',
33
- basename: 'cup',
34
- path: 'austria',
35
- lang: 'de_AT',
36
- }
37
- )
38
-
39
- end # module Writer
1
+ module Writer
2
+
3
+ ########################
4
+ # Austria
5
+
6
+ LEAGUES.merge!(
7
+ 'at.1' => { name: 'Österr. Bundesliga',
8
+ basename: '1-bundesliga',
9
+ stages: ->(season) {
10
+ if season.start_year >= 2018
11
+ [['Grunddurchgang'],
12
+ ['Finaldurchgang - Meister',
13
+ 'Finaldurchgang - Qualifikation',
14
+ 'Europa League Play-off']]
15
+ else
16
+ nil
17
+ end
18
+ },
19
+ },
20
+ 'at.2' => { name: ->(season) { season.start_year >= 2018 ?
21
+ 'Österr. 2. Liga' :
22
+ 'Österr. Erste Liga' },
23
+ basename: ->(season) { season.start_year >= 2018 ?
24
+ '2-liga2' :
25
+ '2-liga1' },
26
+ },
27
+ 'at.3.o' => { name: 'Österr. Regionalliga Ost',
28
+ basename: '3-regionalliga-ost',
29
+ },
30
+ 'at.cup' => { name: 'ÖFB Cup',
31
+ basename: 'cup',
32
+ }
33
+ )
34
+
35
+ end # module Writer
@@ -1,29 +1,21 @@
1
- module Writer
2
-
3
- ############################
4
- # Germany / Deutschland
5
-
6
- LEAGUES.merge!(
7
- 'de.1' => { name: 'Deutsche Bundesliga',
8
- basename: '1-bundesliga',
9
- path: 'deutschland',
10
- lang: 'de_DE',
11
- },
12
- 'de.2' => { name: 'Deutsche 2. Bundesliga',
13
- basename: '2-bundesliga2',
14
- path: 'deutschland',
15
- lang: 'de_DE',
16
- },
17
- 'de.3' => { name: 'Deutsche 3. Liga',
18
- basename: '3-liga3',
19
- path: 'deutschland',
20
- lang: 'de_DE',
21
- },
22
- 'de.cup' => { name: 'DFB Pokal',
23
- basename: 'cup',
24
- path: 'deutschland',
25
- lang: 'de_DE',
26
- }
27
- )
28
-
29
- end # module Writer
1
+ module Writer
2
+
3
+ ############################
4
+ # Germany / Deutschland
5
+
6
+ LEAGUES.merge!(
7
+ 'de.1' => { name: 'Deutsche Bundesliga',
8
+ basename: '1-bundesliga',
9
+ },
10
+ 'de.2' => { name: 'Deutsche 2. Bundesliga',
11
+ basename: '2-bundesliga2',
12
+ },
13
+ 'de.3' => { name: 'Deutsche 3. Liga',
14
+ basename: '3-liga3',
15
+ },
16
+ 'de.cup' => { name: 'DFB Pokal',
17
+ basename: 'cup',
18
+ }
19
+ )
20
+
21
+ end # module Writer
@@ -1,70 +1,58 @@
1
- module Writer
2
-
3
- ####################
4
- # England
5
-
6
-
7
- def self.eng1( season )
8
- case season ## todo/fix: - use cast e.g. Season(season) - make sure it's a season obj
9
- when Season('1888/89')..Season('1891/92') ## single league (no divisions)
10
- {name: 'English Football League',
11
- basename: '1-footballleague'}
12
- when Season('1892/93')..Season('1991/92') ## start of division 1 & 2
13
- {name: 'English Division One',
14
- basename: '1-division1'}
15
- else ## starts in season 1992/93
16
- {name: 'English Premier League',
17
- basename: '1-premierleague'}
18
- end
19
- end
20
-
21
- def self.eng2( season )
22
- case season
23
- when Season('1892/93')..Season('1991/92')
24
- {name: 'English Division Two', ## or use English Football League Second Division ???
25
- basename: '2-division2'}
26
- when Season('1992/93')..Season('2003/04') ## start of premier league
27
- {name: 'English Division One',
28
- basename: '2-division1'}
29
- else # starts in 2004/05
30
- {name: 'English Championship', ## rebranding divsion 1 => championship
31
- basename: '2-championship'}
32
- end
33
- end
34
-
35
-
36
- LEAGUES.merge!(
37
- 'eng.1' => { name: ->(season) { eng1( season )[ :name ] },
38
- basename: ->(season) { eng1( season )[ :basename ] },
39
- path: 'england',
40
- lang: 'en',
41
- },
42
- 'eng.2' => { name: ->(season) { eng2( season )[ :name ] },
43
- basename: ->(season) { eng2( season )[ :basename ] },
44
- path: 'england',
45
- lang: 'en',
46
- },
47
- 'eng.3' => { name: 'English League One',
48
- basename: '3-league1',
49
- path: 'england',
50
- lang: 'en',
51
- },
52
- 'eng.4' => { name: 'English League Two',
53
- basename: '4-league2',
54
- path: 'england',
55
- lang: 'en',
56
- },
57
- 'eng.5' => { name: 'English National League',
58
- basename: '5-nationalleague',
59
- path: 'england',
60
- lang: 'en',
61
- },
62
- 'eng.cup' => { name: 'English FA Cup',
63
- basename: 'facup',
64
- path: 'england',
65
- lang: 'en',
66
- }
67
- )
68
-
69
- end # module Writer
70
-
1
+ module Writer
2
+
3
+ ####################
4
+ # England
5
+
6
+
7
+ def self.eng1( season )
8
+ case season ## todo/fix: - use cast e.g. Season(season) - make sure it's a season obj
9
+ when Season('1888/89')..Season('1891/92') ## single league (no divisions)
10
+ {name: 'English Football League',
11
+ basename: '1-footballleague'}
12
+ when Season('1892/93')..Season('1991/92') ## start of division 1 & 2
13
+ {name: 'English Division One',
14
+ basename: '1-division1'}
15
+ else ## starts in season 1992/93
16
+ {name: 'English Premier League',
17
+ basename: '1-premierleague'}
18
+ end
19
+ end
20
+
21
+ def self.eng2( season )
22
+ case season
23
+ when Season('1892/93')..Season('1991/92')
24
+ {name: 'English Division Two', ## or use English Football League Second Division ???
25
+ basename: '2-division2'}
26
+ when Season('1992/93')..Season('2003/04') ## start of premier league
27
+ {name: 'English Division One',
28
+ basename: '2-division1'}
29
+ else # starts in 2004/05
30
+ {name: 'English Championship', ## rebranding divsion 1 => championship
31
+ basename: '2-championship'}
32
+ end
33
+ end
34
+
35
+
36
+ LEAGUES.merge!(
37
+ 'eng.1' => { name: ->(season) { eng1( season )[ :name ] },
38
+ basename: ->(season) { eng1( season )[ :basename ] },
39
+ },
40
+ 'eng.2' => { name: ->(season) { eng2( season )[ :name ] },
41
+ basename: ->(season) { eng2( season )[ :basename ] },
42
+ },
43
+ 'eng.3' => { name: 'English League One',
44
+ basename: '3-league1',
45
+ },
46
+ 'eng.4' => { name: 'English League Two',
47
+ basename: '4-league2',
48
+ },
49
+ 'eng.5' => { name: 'English National League',
50
+ basename: '5-nationalleague',
51
+ },
52
+ 'eng.cup' => { name: 'English FA Cup',
53
+ basename: 'facup',
54
+ }
55
+ )
56
+
57
+ end # module Writer
58
+
@@ -1,19 +1,15 @@
1
- module Writer
2
-
3
- LEAGUES.merge!(
4
- ###################
5
- # Spain / Espana
6
- 'es.1' => { name: 'Primera División de España',
7
- basename: '1-liga',
8
- path: 'espana',
9
- lang: 'es',
10
- },
11
- 'es.2' => { name: 'Segunda División de España',
12
- basename: '2-liga2',
13
- path: 'espana',
14
- lang: 'es',
15
- },
16
- )
17
-
18
- end # module Writer
19
-
1
+ module Writer
2
+
3
+ LEAGUES.merge!(
4
+ ###################
5
+ # Spain / Espana
6
+ 'es.1' => { name: 'Primera División de España',
7
+ basename: '1-liga',
8
+ },
9
+ 'es.2' => { name: 'Segunda División de España',
10
+ basename: '2-liga2',
11
+ },
12
+ )
13
+
14
+ end # module Writer
15
+