12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/aquatone/report.rb', line 12
def generate(destination)
sorted_visits = @visits.sort { |x,y| x[:domain] <=> y[:domain] }
slices = sorted_visits.each_slice(@options[:per_page].to_i)
report = load_template
slices.each_with_index do |h, i|
b = binding
@visit_slice = h
@page_number = i
if i + 1 == slices.count
@link_to_next_page = false
else
@link_to_next_page = true
@next_page_path = File.basename(report_file_name(destination, i + 1))
end
if i.zero?
@link_to_previous_page = false
else
@link_to_previous_page = true
@previous_page_path = File.basename(report_file_name(destination, i - 1))
end
File.open(report_file_name(destination, i), "w") do |f|
f.write(report.result(b))
end
end
end
|