spiffy 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f006d8837df5b0b128e01bd099a55d1a64ebf3e3
4
- data.tar.gz: ffafaf1e1ecf09ed0f255441f793a16c43f07f81
3
+ metadata.gz: 7a0ce5b8b5aa02953467ec003f7d6ccbe3907a46
4
+ data.tar.gz: 1c87fe773585fa77df23d6683cf9631641a52191
5
5
  SHA512:
6
- metadata.gz: d47bea9057a29d9adbf9e16a98868ddbc73d6e7298e0d0324957f32926f12ff21eba083fe2b5ef72fff618aa7ab188b511ce3521be9f6cc963bcc963a20ca527
7
- data.tar.gz: 5b1ccb31851f2ed7cbc5ef6a0f75a64e38e2f8cb63378a5bd6457adad9b19458d8e666500e15a0db051ebcdbfcad3ee5ce0e4601d857de0b414b9239de80357b
6
+ metadata.gz: c28b9583be65d050e9f6db0172e633c484f155bc7766a0c709d24269f7b5f212152a8ac4ce51e2e19d23883107eee9b93bd4b570cbef89ced49d26626d0403cc
7
+ data.tar.gz: 52a373bcbe83593616861bce0788074f97b796b39c69c43548b421c217490c2168b1d894b9d531e2c825a879182cba16420f61ab5dbb2b80fc7c7dcadd4cd1bc
@@ -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[0...-markup_file_ext.length]
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)
@@ -33,10 +33,14 @@ module SpiffyCli
33
33
  options[:pdf] = on_or_off != "off"
34
34
  end
35
35
 
36
- opt.on("-h", "--html [on|off]", "Output HTML files (default: on)") do |on_or_off|
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
@@ -1,3 +1,3 @@
1
1
  module SpiffyVersion
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leigh McCulloch