Module: Propaganda

Defined in:
lib/propaganda.rb,
lib/propaganda/renderer.rb,
lib/propaganda/fop/shell.rb,
lib/propaganda/formatter.rb,
lib/propaganda/fop/bridge.rb

Defined Under Namespace

Modules: Fop Classes: Formatter, Renderer

Constant Summary collapse

MODE =
check_dependencies ? 'rjb' : 'shell'

Class Method Summary collapse

Class Method Details

.check_dependenciesObject



5
6
7
8
# File 'lib/propaganda/renderer.rb', line 5

def self.check_dependencies
  require 'propaganda/fop/shell' 
  require 'propaganda/fop/bridge'
end

.convert(input, output, title = nil, template = nil, engine = nil, verbose = false) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/propaganda.rb', line 5

def self.convert(input, output, title=nil, template=nil, engine=nil, verbose=false)
  title ||= File.basename(input, File.extname(input))
  engine ||= detect(input)
  text = IO.read(input)
  formatter = Formatter.new
  text = formatter.format(text, title, engine)
  fop = Renderer.new(verbose)
  fop.render(text, output, template)
end

.detect(input) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/propaganda.rb', line 15

def self.detect(input)
  case File.extname(input)
    when '.textile'
      'textile'
    when '.markdown', '.md'
      'markdown'
    when '.html', '.xhtml'
      'none'
    else
      raise "Unknown format for #{input}, use .html, .textile or .markdown extension"
  end
end