football-sources 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +6 -4
  3. data/Manifest.txt +0 -29
  4. data/README.md +30 -28
  5. data/Rakefile +32 -31
  6. data/lib/football/sources.rb +6 -6
  7. data/lib/football-sources/version.rb +19 -19
  8. data/lib/football-sources.rb +16 -46
  9. metadata +15 -58
  10. data/lib/football-sources/apis/config.rb +0 -17
  11. data/lib/football-sources/apis/convert.rb +0 -239
  12. data/lib/football-sources/apis/convert_cl.rb +0 -267
  13. data/lib/football-sources/apis/download.rb +0 -11
  14. data/lib/football-sources/apis/stat.rb +0 -59
  15. data/lib/football-sources/apis.rb +0 -86
  16. data/lib/football-sources/worldfootball/build.rb +0 -245
  17. data/lib/football-sources/worldfootball/config.rb +0 -16
  18. data/lib/football-sources/worldfootball/convert.rb +0 -100
  19. data/lib/football-sources/worldfootball/convert_reports.rb +0 -107
  20. data/lib/football-sources/worldfootball/download.rb +0 -61
  21. data/lib/football-sources/worldfootball/leagues/asia.rb +0 -53
  22. data/lib/football-sources/worldfootball/leagues/europe--british_isles.rb +0 -59
  23. data/lib/football-sources/worldfootball/leagues/europe--central.rb +0 -127
  24. data/lib/football-sources/worldfootball/leagues/europe--eastern.rb +0 -82
  25. data/lib/football-sources/worldfootball/leagues/europe--northern.rb +0 -57
  26. data/lib/football-sources/worldfootball/leagues/europe--southern.rb +0 -86
  27. data/lib/football-sources/worldfootball/leagues/europe--western.rb +0 -38
  28. data/lib/football-sources/worldfootball/leagues/europe.rb +0 -13
  29. data/lib/football-sources/worldfootball/leagues/north_america.rb +0 -44
  30. data/lib/football-sources/worldfootball/leagues/pacific.rb +0 -21
  31. data/lib/football-sources/worldfootball/leagues/south_america.rb +0 -11
  32. data/lib/football-sources/worldfootball/leagues.rb +0 -200
  33. data/lib/football-sources/worldfootball/mods.rb +0 -72
  34. data/lib/football-sources/worldfootball/tool.rb +0 -100
  35. data/lib/football-sources/worldfootball/vacuum.rb +0 -66
  36. data/lib/football-sources/worldfootball.rb +0 -24
  37. data/test/helper.rb +0 -8
  38. data/test/test_version.rb +0 -16
@@ -1,72 +0,0 @@
1
- #### todo/check: move MODS and SCORE_ERRORS out-of-lib
2
- ## and into config or such - why? why not?
3
-
4
-
5
- module Worldfootball
6
-
7
-
8
- ######
9
- # "global" helpers
10
- def self.norm_team( team )
11
- ## clean team name and asciify (e.g. ’->' )
12
- team = team.sub( '(old)', '' ).strip
13
- team = team.gsub( '’', "'" ) ## e.g. Hawke’s Bay United FC
14
- team
15
- end
16
-
17
-
18
-
19
- MODS = {
20
- 'at' => {
21
- ## AT 1
22
- 'SC Magna Wiener Neustadt' => 'SC Wiener Neustadt', # in 2010/11
23
- 'KSV Superfund' => 'Kapfenberger SV', # in 2010/11
24
- 'Kapfenberger SV 1919' => 'Kapfenberger SV', # in 2011/12
25
- 'FC Trenkwalder Admira' => 'FC Admira Wacker', # in 2011/12
26
- ## AT 2
27
- 'Austria Wien (A)' => 'Young Violets', # in 2019/20
28
- 'FC Wacker Innsbruck (A)' => 'FC Wacker Innsbruck II', # in 2018/19
29
- ## AT CUP
30
- 'Rapid Wien (A)' => 'Rapid Wien II', # in 2011/12
31
- 'Sturm Graz (A)' => 'Sturm Graz II',
32
- 'Kapfenberger SV 1919 (A)' => 'Kapfenberger SV II',
33
- 'SV Grödig (A)' => 'SV Grödig II',
34
- 'RB Salzburg (A)' => 'RB Salzburg II',
35
- 'SR WGFM Donaufeld' => 'SR Donaufeld Wien',
36
- 'FC Trenkwalder Admira (A)' => 'FC Admira Wacker II',
37
- ## AT 3.O (Regionalliga Ost)
38
- 'FC Admira Wacker (A)' => 'FC Admira Wacker II', # in 2020/21
39
- },
40
- 'nz' => {
41
- ## NZ 1
42
- 'Wellington Phoenix (R)' => 'Wellington Phoenix Reserves',
43
- },
44
- }
45
-
46
-
47
-
48
- ## fix/patch known score format errors in at/de cups
49
- ## new convention
50
- ## for a fix require league, date, and team1 & team2 for now!!!!
51
- ## - do NOT use some "generic" fix / patch!!!!
52
- ##
53
- ## old de/at patches/fixes:
54
- ## '0-1 (0-0, 0-0, 0-0) n.V.' => '0-1 (0-0, 0-0) n.V.', # too long
55
- ## '2-1 (1-1, 1-1, 1-0) n.V.' => '2-1 (1-1, 1-1) n.V.',
56
- ## '4-2 (0-0, 0-0) i.E.' => '4-2 (0-0, 0-0, 0-0) i.E.', # too short
57
-
58
-
59
- SCORE_ERRORS = {
60
- 'ro.1' => {
61
- ## 2013/14
62
- '2013-07-29' => [ 'FC Brașov', 'Săgeata Năvodari', ['1-1 (0-0, 0-1)', '1-1 (0-0)']],
63
- },
64
- 'gr.1' => {
65
- ## 2010/11
66
- '2010-11-24' => [ 'Ergotelis', 'Olympiakos Piräus', ['0-2 (0-0, 0-0, 0-0)', '0-2 (0-0)']],
67
- '2010-11-28' => [ 'Panserraikos', 'Aris Saloniki', ['1-0 (1-0, 0-0, 0-0)', '1-0 (1-0)']],
68
- }
69
- }
70
-
71
-
72
- end # module Worldfootball
@@ -1,100 +0,0 @@
1
-
2
-
3
- module Worldfootball
4
- ################################
5
- # add more helpers
6
- # move upstream for (re)use - why? why not?
7
-
8
- ## todo/check: what to do: if league is both included and excluded?
9
- ## include forces include? or exclude has the last word? - why? why not?
10
- ## Excludes match before includes,
11
- ## meaning that something that has been excluded cannot be included again
12
-
13
- ## todo - find "proper/classic" timezone ("winter time")
14
-
15
- ## Brasilia - Distrito Federal, Brasil (GMT-3) -- summer time?
16
- ## Ciudad de México, CDMX, México (GMT-5) -- summer time?
17
- ## Londres, Reino Unido (GMT+1)
18
- ## Madrid -- ?
19
- ## Lisboa -- ?
20
- ## Moskow -- ?
21
- ##
22
- ## todo/check - quick fix timezone offsets for leagues for now
23
- ## - find something better - why? why not?
24
- ## note: assume time is in GMT+1
25
- OFFSETS = {
26
- 'eng.1' => -1,
27
- 'eng.2' => -1,
28
- 'eng.3' => -1,
29
- 'eng.4' => -1,
30
- 'eng.5' => -1,
31
-
32
- 'es.1' => -1,
33
- 'es.2' => -1,
34
-
35
- 'pt.1' => -1,
36
- 'pt.2' => -1,
37
-
38
- 'br.1' => -5,
39
- 'mx.1' => -7,
40
- }
41
-
42
-
43
-
44
-
45
- class Tool
46
- def initialize( includes: nil,
47
- excludes: nil )
48
- ## quick fix: move/handle empty array upstream!!!!
49
- includes = nil if includes.is_a?(Array) && includes.empty?
50
-
51
- @includes = includes
52
- @excludes = excludes
53
- end
54
-
55
-
56
-
57
- def download( datasets )
58
- datasets.each do |dataset|
59
- league = dataset[0]
60
- seasons = dataset[1]
61
-
62
- with_filter( league ) do
63
- seasons.each do |season|
64
- puts "downloading #{league} #{season}..."
65
-
66
- Worldfootball.schedule( league: league,
67
- season: season )
68
- end
69
- end
70
- end
71
- end
72
-
73
- def convert( datasets )
74
- datasets.each do |dataset|
75
- league = dataset[0]
76
- seasons = dataset[1]
77
-
78
- with_filter( league ) do
79
- seasons.each do |season|
80
- Worldfootball.convert( league: league,
81
- season: season,
82
- offset: OFFSETS[ league ] )
83
- end
84
- end
85
- end
86
- end
87
-
88
-
89
- #########################################
90
- # more helpers
91
- def with_filter( league, &blk )
92
- return if @excludes && @excludes.find { |q| league.start_with?( q.downcase ) }
93
- return if @includes && @includes.find { |q| league.start_with?( q.downcase ) }.nil?
94
- blk.call()
95
- end
96
-
97
- end # class Tool
98
- end # module Worldfootball
99
-
100
-
@@ -1,66 +0,0 @@
1
- module Worldfootball
2
-
3
-
4
- MAX_HEADERS = [
5
- 'Stage',
6
- 'Round',
7
- 'Date',
8
- 'Time',
9
- 'Team 1',
10
- 'FT',
11
- 'HT',
12
- 'Team 2',
13
- 'ET',
14
- 'P',
15
- 'Comments'] ## e.g. awarded, cancelled/canceled, etc.
16
-
17
- MIN_HEADERS = [ ## always keep even if all empty
18
- 'Date',
19
- 'Team 1',
20
- 'FT',
21
- 'Team 2'
22
- ]
23
-
24
- def self.vacuum( rows, headers: MAX_HEADERS, fixed_headers: MIN_HEADERS )
25
- ## check for unused columns and strip/remove
26
- counter = Array.new( MAX_HEADERS.size, 0 )
27
- rows.each do |row|
28
- row.each_with_index do |col, idx|
29
- counter[idx] += 1 unless col.nil? || col.empty?
30
- end
31
- end
32
-
33
- pp counter
34
-
35
- ## check empty columns
36
- headers = []
37
- indices = []
38
- empty_headers = []
39
- empty_indices = []
40
-
41
- counter.each_with_index do |num, idx|
42
- header = MAX_HEADERS[ idx ]
43
- if num > 0 || (num == 0 && fixed_headers.include?( header ))
44
- headers << header
45
- indices << idx
46
- else
47
- empty_headers << header
48
- empty_indices << idx
49
- end
50
- end
51
-
52
- if empty_indices.size > 0
53
- rows = rows.map do |row|
54
- row_vacuumed = []
55
- row.each_with_index do |col, idx|
56
- ## todo/fix: use values or such??
57
- row_vacuumed << col unless empty_indices.include?( idx )
58
- end
59
- row_vacuumed
60
- end
61
- end
62
-
63
- [rows, headers]
64
- end
65
-
66
- end # module Worldfootball
@@ -1,24 +0,0 @@
1
- ###########################
2
- # note: split code in two parts
3
- # metal - "bare" basics - no ref to sportdb
4
- # and rest / convert with sportdb references / goodies
5
-
6
-
7
- ## our own code
8
- require_relative 'worldfootball/leagues'
9
-
10
- require_relative 'worldfootball/config'
11
-
12
- require_relative 'worldfootball/download'
13
-
14
- require_relative 'worldfootball/mods'
15
- require_relative 'worldfootball/vacuum'
16
- require_relative 'worldfootball/build'
17
- require_relative 'worldfootball/convert'
18
- require_relative 'worldfootball/convert_reports'
19
-
20
-
21
- require_relative 'worldfootball/tool'
22
-
23
-
24
-
data/test/helper.rb DELETED
@@ -1,8 +0,0 @@
1
- $LOAD_PATH.unshift( '../webget/lib')
2
-
3
- require 'minitest/autorun'
4
-
5
-
6
- ## our own code
7
- require 'football/sources' ## or require 'football-sources'
8
-
data/test/test_version.rb DELETED
@@ -1,16 +0,0 @@
1
- ###
2
- # to run use
3
- # ruby -I ./lib -I ./test test/test_version.rb
4
-
5
-
6
- require 'helper'
7
-
8
- class TestVersion < MiniTest::Test
9
-
10
- def test_version
11
- pp FootballSources::VERSION
12
- pp FootballSources.banner
13
- pp FootballSources.root
14
- end
15
-
16
- end # class TestVersion