mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
1033d12040
--enable-testing.
29 lines
731 B
Ruby
29 lines
731 B
Ruby
# Policy for the location of report templates
|
|
require 'string-store'
|
|
|
|
class TemplateStringStore < StringStore
|
|
def initialize()
|
|
super(['report-generators/templates'])
|
|
end
|
|
end
|
|
|
|
module ReportTemplates
|
|
def generate_report(report, bs, dest_path = nil)
|
|
include Reports
|
|
reports = ReportRegister.new
|
|
template_store = TemplateStringStore.new
|
|
report = reports.get_report(report)
|
|
erb = ERB.new(template_store.lookup(report.template))
|
|
body = erb.result(bs)
|
|
title = report.short_desc
|
|
|
|
erb = ERB.new(template_store.lookup("boiler_plate.rhtml"))
|
|
txt = erb.result(binding)
|
|
|
|
dest_path = dest_path.nil? ? report.path : dest_path
|
|
dest_path.open("w") do |out|
|
|
out.puts txt
|
|
end
|
|
end
|
|
end
|