Class: Rsssf::Repo
Instance Method Summary
collapse
Methods included from Utils
#archive_dir_for_year, #year_from_file, #year_from_name, #year_to_season
Methods included from Filters
#html_to_txt, #sanitize
Constructor Details
#initialize(path, opts) ⇒ Repo
29
30
31
32
|
# File 'lib/rsssf/repo.rb', line 29
def initialize( path, opts ) @repo_path = path
@opts = opts
end
|
Instance Method Details
#fetch_pages ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/rsssf/repo.rb', line 35
def fetch_pages
puts "fetch_pages:"
cfg = YAML.load_file( "#{@repo_path}/tables/config.yml")
pp cfg
dl_base = 'http://rsssf.com'
cfg.each do |k,v|
path = v
basename = File.basename( path, '.html' )
src_url = "#{dl_base}/#{path}"
dest_path = "#{@repo_path}/tables/#{basename}.txt"
page = Page.from_url( src_url )
page.save( dest_path )
end end
|
#make_pages_summary ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/rsssf/repo.rb', line 59
def make_pages_summary
stats = []
files = Dir[ "#{@repo_path}/tables/*.txt" ]
files.each do |file|
page = Page.from_file( file )
stats << page.build_stat
end
report = PageReport.new( stats, @opts ) report.save( "#{@repo_path}/tables/README.md" )
end
|
#make_schedules(cfg) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/rsssf/repo.rb', line 97
def make_schedules( cfg )
stats = []
files = Dir[ "#{@repo_path}/tables/*.txt" ]
files.each do |file|
extname = File.extname( file )
basename = File.basename( file, extname )
year = year_from_name( basename )
season = year_to_season( year )
if cfg.includes && cfg.includes.include?( year ) == false
puts " skipping #{basename}; not listed in includes"
next
end
puts " reading >#{basename}<"
page = Page.from_file( file )
if cfg.opts_for_year.is_a?( Hash )
opts = cfg.opts_for_year else
opts = cfg.opts_for_year.call( year )
end
pp opts
schedule = page.find_schedule( opts )
if cfg.dir_for_year.nil?
dir_for_year = archive_dir_for_year( year )
else
dir_for_year = cfg.dir_for_year.call( year )
end
dest_path = "#{@repo_path}/#{dir_for_year}/#{cfg.name}.txt"
puts " save to >#{dest_path}<"
FileUtils.mkdir_p( File.dirname( dest_path ))
schedule.save( dest_path )
rec = ScheduleStat.new
rec.path = dir_for_year
rec.filename = "#{cfg.name}.txt" rec.year = year
rec.season = season
rec.rounds = schedule.rounds
stats << rec
end
stats end
|
#make_schedules_summary(stats) ⇒ Object
note: requires stats to be passed in for now
74
75
76
77
|
# File 'lib/rsssf/repo.rb', line 74
def make_schedules_summary( stats ) report = ScheduleReport.new( stats, @opts ) report.save( "#{@repo_path}/README.md" )
end
|
#patch_pages(patcher) ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/rsssf/repo.rb', line 81
def patch_pages( patcher )
patch_dir( "#{@repo_path}/tables" ) do |txt, name, year|
puts "patching #{year} (#{name}) (#{@repo_path})..."
patcher.patch( txt, name, year ) end
end
|
#sanitize_pages ⇒ Object
90
91
92
93
|
# File 'lib/rsssf/repo.rb', line 90
def sanitize_pages
sanitize_dir( "#{@repo_path}/tables" )
end
|