Class: Propaganda::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/propaganda/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(verbose = false) ⇒ Renderer

Returns a new instance of Renderer.



13
14
15
# File 'lib/propaganda/renderer.rb', line 13

def initialize(verbose=false)
  @verbose = verbose
end

Instance Method Details

#render(html, output, template = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/propaganda/renderer.rb', line 21

def render(html, output, template=nil)
  template ||= 'default'
  stylesheet = File.join(File.dirname(__FILE__), '..', '..', 'templates', "#{template}.xsl")
  stylesheet = File.expand_path(stylesheet)
  tmp = Tempfile.new('fop')
  tmp << html
  tmp.flush
  tmp.close
  output = File.expand_path(output)
  invoke('-xml', tmp.path, '-xsl', stylesheet, '-pdf', output)
ensure
  tmp.close rescue nil
  tmp = nil  
end

#versionObject



17
18
19
# File 'lib/propaganda/renderer.rb', line 17

def version
  invoke('-v')
end