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.



15
16
17
# File 'lib/propaganda/renderer.rb', line 15

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

Instance Method Details

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



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

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



19
20
21
# File 'lib/propaganda/renderer.rb', line 19

def version
  invoke('-v')
end