Module: Rsssf
- Defined in:
- lib/rsssf/page.rb,
lib/rsssf/repo.rb,
lib/rsssf/utils.rb,
lib/rsssf/convert.rb,
lib/rsssf/version.rb,
lib/rsssf/download.rb,
lib/rsssf/schedule.rb,
lib/rsssf/reports/page.rb,
lib/rsssf/reports/schedule.rb
Defined Under Namespace
Modules: Utils
Classes: Page, PageConverter, PageReport, PageStat, Repo, Schedule, ScheduleReport, ScheduleStat
Constant Summary
collapse
- MAJOR =
0
- MINOR =
2
- PATCH =
0
- VERSION =
[MAJOR,MINOR,PATCH].join('.')
- TABLE =
map country codes to table pages
add options about (char) encoding ??? - why? why not?
{
'eng' => ['tablese/eng{year}', { encoding: 'Windows-1252' } ],
'es' => ['tabless/span{year}', { encoding: 'Windows-1252' } ],
'de' => ['tablesd/duit{year}', { encoding: 'Windows-1252' } ],
'at' => ['tableso/oost{year}', { encoding: 'Windows-1252' } ],
'br' => [
->(season) {
if season == Season('2000')
'tablesb/braz-joao{year}' else
'tablesb/braz{year}'
end
}, { encoding: 'Windows-1252' } ],
}
- BASE_URL =
"https://rsssf.org"
Class Method Summary
collapse
Class Method Details
.banner ⇒ Object
13
14
15
|
# File 'lib/rsssf/version.rb', line 13
def self.banner
"rsssf/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
end
|
.download_page(url, encoding:) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/rsssf/download.rb', line 73
def self.download_page( url, encoding: )
response = Webget.page( url, encoding: encoding )
exit 1 if response.status.nok?
puts "html:"
html = response.text( encoding: encoding )
pp html[0..400]
html
end
|
.download_table(code, season:) ⇒ Object
66
67
68
69
70
|
# File 'lib/rsssf/download.rb', line 66
def self.download_table( code, season: )
url, encoding = table_url_and_encoding( code, season: season )
download_page( url, encoding: encoding )
end
|
.root ⇒ Object
17
18
19
|
# File 'lib/rsssf/version.rb', line 17
def self.root
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
end
|
.table_url(code, season:) ⇒ Object
36
37
38
39
|
# File 'lib/rsssf/download.rb', line 36
def self.table_url( code, season: )
url, _ = table_url_and_encoding( code, season: season )
url
end
|
.table_url_and_encoding(code, season:) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/rsssf/download.rb', line 41
def self.table_url_and_encoding( code, season: )
season = Season( season )
table = TABLE[ code.downcase ]
tmpl = table[0]
tmpl = tmpl.call( season ) if tmpl.is_a?(Proc)
opts = table[1] || {}
encoding = opts[:encoding] || 'UTF-8'
slug = if season.end_year < 2010 '%02d' % (season.end_year % 100) else
'%4d' % season.end_year
end
tmpl = tmpl.sub( '{year}', slug )
url = "#{BASE_URL}/#{tmpl}.html"
[url, encoding]
end
|
.version ⇒ Object
9
10
11
|
# File 'lib/rsssf/version.rb', line 9
def self.version
VERSION
end
|