propaganda 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -6,6 +6,8 @@ def usage
6
6
  puts " --title=='A Friendly Title' (will detect from filename if omitted)"
7
7
  puts " --template=={default|clean} (will use default if omitted)"
8
8
  puts " --engine=={markdown|textile|none} (will detect from filename if omitted)"
9
+ puts " --html Output html"
10
+ puts " --pdf Output pdf (default)"
9
11
  puts " --verbose Show errors and warnings"
10
12
  puts " --help"
11
13
  exit
@@ -20,12 +22,14 @@ require 'propaganda'
20
22
 
21
23
  def opt(name)
22
24
  p = ARGV.select{|arg| arg =~ /^--#{name}/}.first
23
- p.gsub(/^--#{name}=/, '') if p
25
+ p = p.gsub(/^--/, '') if p
26
+ p = p.gsub(/^#{name}=/, '') if p
24
27
  end
25
28
 
26
29
  template = opt "template"
27
30
  title = opt "title"
28
31
  engine = opt "engine"
32
+ html = opt "html"
29
33
  verbose = !opt("verbose").nil?
30
34
 
31
35
  # Grab the params
@@ -35,4 +39,4 @@ output = params[1] rescue nil
35
39
  usage if input.nil? || output.nil?
36
40
 
37
41
  # Run it
38
- Propaganda.convert(input, output, title, template, engine, verbose)
42
+ Propaganda.convert(input, output, title, template, engine, html, verbose)
@@ -2,12 +2,14 @@ require 'propaganda/renderer'
2
2
  require 'propaganda/formatter'
3
3
 
4
4
  module Propaganda
5
- def self.convert(input, output, title=nil, template=nil, engine=nil, verbose=false)
5
+ def self.convert(input, output, title=nil, template=nil, engine=nil, format=nil, verbose=false)
6
6
  title ||= File.basename(input, File.extname(input))
7
7
  engine ||= detect(input)
8
+ format ||= 'pdf'
8
9
  text = IO.read(input)
9
10
  formatter = Formatter.new
10
11
  text = formatter.format(text, title, engine)
12
+ return !File.open(output, 'w') {|f| f.write(text) }.nil? if format == 'html'
11
13
  fop = Renderer.new(verbose)
12
14
  fop.render(text, output, template)
13
15
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propaganda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Rafter
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-25 00:00:00 -08:00
12
+ date: 2010-02-26 00:00:00 -08:00
13
13
  default_executable: propaganda
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency