spiffy 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spiffy.rb +9 -4
- data/lib/spiffy_cli.rb +7 -2
- data/lib/spiffy_version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a0ce5b8b5aa02953467ec003f7d6ccbe3907a46
|
4
|
+
data.tar.gz: 1c87fe773585fa77df23d6683cf9631641a52191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c28b9583be65d050e9f6db0172e633c484f155bc7766a0c709d24269f7b5f212152a8ac4ce51e2e19d23883107eee9b93bd4b570cbef89ced49d26626d0403cc
|
7
|
+
data.tar.gz: 52a373bcbe83593616861bce0788074f97b796b39c69c43548b421c217490c2168b1d894b9d531e2c825a879182cba16420f61ab5dbb2b80fc7c7dcadd4cd1bc
|
data/lib/spiffy.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
require "fileutils"
|
1
2
|
require "github/markup"
|
2
3
|
require "haml"
|
3
4
|
require "pdfkit"
|
4
5
|
|
5
6
|
module Spiffy
|
6
|
-
def self.markup_to_html(markup_file, css_file: nil, template_file: nil, output_html: true, output_pdf: false)
|
7
|
+
def self.markup_to_html(markup_file, css_file: nil, template_file: nil, output_html: true, output_pdf: false, output_dir: nil)
|
7
8
|
markup_file_ext = File.extname(markup_file)
|
8
|
-
markup_file_name = markup_file
|
9
|
+
markup_file_name = File.basename(markup_file, ".*")
|
9
10
|
markup_file_directory = File.dirname(markup_file)
|
10
11
|
markup = File.open(markup_file, "r:UTF-8", &:read)
|
11
12
|
|
@@ -37,13 +38,17 @@ module Spiffy
|
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
41
|
+
output_dir = File.join(output_dir, "") if output_dir
|
42
|
+
output_dir = "#{output_dir}#{markup_file_directory}"
|
43
|
+
FileUtils.mkdir_p(output_dir) unless File.directory?(output_dir)
|
44
|
+
|
40
45
|
if output_html
|
41
|
-
html_file = "#{markup_file_name}.html"
|
46
|
+
html_file = File.join(output_dir, "#{markup_file_name}.html")
|
42
47
|
File.open(html_file, "w:UTF-8") { |f| f.write(html) }
|
43
48
|
end
|
44
49
|
|
45
50
|
if output_pdf
|
46
|
-
pdf_file = "#{markup_file_name}.pdf"
|
51
|
+
pdf_file = File.join(output_dir, "#{markup_file_name}.pdf")
|
47
52
|
pdf = PDFKit.new(html)
|
48
53
|
pdf.stylesheets << css_file if css_file
|
49
54
|
pdf.to_file(pdf_file)
|
data/lib/spiffy_cli.rb
CHANGED
@@ -33,10 +33,14 @@ module SpiffyCli
|
|
33
33
|
options[:pdf] = on_or_off != "off"
|
34
34
|
end
|
35
35
|
|
36
|
-
opt.on("-
|
36
|
+
opt.on("-m", "--html [on|off]", "Output HTML files (default: on)") do |on_or_off|
|
37
37
|
options[:html] = on_or_off != "off"
|
38
38
|
end
|
39
39
|
|
40
|
+
opt.on("-o", "--out [output directory]", "Output files to this directory") do |output_dir|
|
41
|
+
options[:output_dir] = output_dir
|
42
|
+
end
|
43
|
+
|
40
44
|
opt.on("-h", "--help", "This usage outline.") do
|
41
45
|
puts opt_parser
|
42
46
|
options[:help] = true
|
@@ -98,7 +102,8 @@ module SpiffyCli
|
|
98
102
|
css_file: options[:css_file] || set["css_file"] || DEFAULT_CSS_FILE,
|
99
103
|
template_file: options[:template_file] || set["template_file"] || DEFAULT_TEMPLATE_FILE,
|
100
104
|
output_html: output_html,
|
101
|
-
output_pdf: output_pdf
|
105
|
+
output_pdf: output_pdf,
|
106
|
+
output_dir: options[:output_dir] || set["output_dir"])
|
102
107
|
puts "done"
|
103
108
|
end
|
104
109
|
end
|
data/lib/spiffy_version.rb
CHANGED