class Serenity::Template
Attributes
template[RW]
Public Class Methods
new(template, output)
click to toggle source
# File lib/serenity/serenity/template.rb, line 8 def initialize(template, output) FileUtils.cp(template, output) @template = output end
Public Instance Methods
process(context)
click to toggle source
# File lib/serenity/serenity/template.rb, line 13 def process context tmpfiles = [] Zip::ZipFile.open(@template) do |zipfile| %w(content.xml styles.xml).each do |xml_file| content = zipfile.read(xml_file) odteruby = OdtEruby.new(XmlReader.new(content)) out = odteruby.evaluate(context) out.force_encoding Encoding.default_external.to_s tmpfiles << (file = Tempfile.new("serenity")) file << out file.close zipfile.replace(xml_file, file.path) end end end