spiffy 0.0.16 → 0.0.17
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 +4 -4
- data/bin/spiffy +4 -91
- data/lib/spiffy.rb +0 -2
- data/lib/spiffy_cli.rb +104 -0
- data/lib/spiffy_version.rb +3 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 949d4e18b7e4b71182e90482f7638e965aed7e63
|
4
|
+
data.tar.gz: 0424f08b70eaa537dc306f4b8ab697be3f91dc08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8adcff89802c8c90e9fe6fdac2d94b5b80f3e00a51bb47aeb4f1acf78d9faffb4872c3a75f5626b7fd3ad47e96b3731dbdc595b5cad68dbd1d1be0b9c2c8d23e
|
7
|
+
data.tar.gz: 5aaf9f715aa7f3427d0e7d22575d88faaff12054baab6af5e6a5ae7734b2d5e2d5757d84cdad002d74220b161b8cb9abb85dd88a077d4c94089cf695c9162be7
|
data/bin/spiffy
CHANGED
@@ -1,98 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "yaml"
|
6
|
-
require_relative "../lib/spiffy"
|
7
|
-
|
8
|
-
DEFAULT_DIR = File.join(File.dirname(__FILE__), "../templates")
|
9
|
-
DEFAULT_TEMPLATE_FILE = File.join(DEFAULT_DIR, "default.haml")
|
10
|
-
DEFAULT_CSS_FILE = File.join(DEFAULT_DIR, "default.css")
|
11
|
-
DEFAULT_HTML = true
|
12
|
-
DEFAULT_PDF = false
|
13
|
-
|
14
|
-
DOT_FILE = ".spiffy.yml"
|
15
|
-
|
16
|
-
options = {
|
17
|
-
:template_file => nil,
|
18
|
-
:css_file => nil,
|
19
|
-
:html => nil,
|
20
|
-
:pdf => nil
|
21
|
-
}
|
22
|
-
|
23
|
-
opt_parser = OptionParser.new do |opt|
|
24
|
-
opt.banner = "Usage: spiffy [options] [file] [file] ..."
|
25
|
-
opt.separator("Version: #{Spiffy::VERSION}")
|
26
|
-
opt.separator("")
|
27
|
-
opt.separator("Options")
|
28
|
-
|
29
|
-
opt.on("-c", "--css [css]", "CSS to include inline in the HTML file output") do |css|
|
30
|
-
options[:css_file] = css
|
31
|
-
end
|
32
|
-
|
33
|
-
opt.on("-t", "--template [template]", "Template to wrap the resulting HTML") do |template|
|
34
|
-
options[:template_file] = template
|
35
|
-
end
|
36
|
-
|
37
|
-
opt.on("-p", "--pdf [on|off]", "Output PDF files (default: off)") do |on_or_off|
|
38
|
-
options[:pdf] = on_or_off != "off"
|
39
|
-
end
|
40
|
-
|
41
|
-
opt.on("-h", "--html [on|off]", "Output HTML files (default: on)") do |on_or_off|
|
42
|
-
options[:html] = on_or_off != "off"
|
43
|
-
end
|
44
|
-
|
45
|
-
opt.on("-h", "--help", "This usage outline.") do
|
46
|
-
puts opt_parser
|
47
|
-
end
|
48
|
-
|
49
|
-
opt.separator("")
|
50
|
-
|
51
|
-
opt.separator("Alternatively:")
|
52
|
-
opt.separator("Create a .spiffy.yml in this directory with options within.")
|
53
|
-
opt.separator("See https://github.com/leighmcculloch/spiffy.")
|
54
|
-
|
55
|
-
opt.separator("")
|
56
|
-
end
|
57
|
-
|
58
|
-
opt_parser.parse!
|
59
|
-
|
60
|
-
has_dot_file = File.exists?(DOT_FILE)
|
61
|
-
|
62
|
-
if File.exists?(DOT_FILE)
|
63
|
-
sets = YAML.load_file(DOT_FILE)
|
64
|
-
end
|
65
|
-
|
66
|
-
if ARGV.any?
|
67
|
-
sets = ARGV.map do |arg|
|
68
|
-
set = sets.find({}) do |set|
|
69
|
-
set["markdown_files"].any? do |markdown_file|
|
70
|
-
File.fnmatch(markdown_file, arg)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
set.merge({ "markdown_files" => [arg] })
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
if !sets
|
78
|
-
puts opt_parser
|
79
|
-
abort
|
80
|
-
end
|
3
|
+
require_relative "../lib/spiffy_cli"
|
81
4
|
|
82
5
|
begin
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
print "Converting #{file}..."
|
87
|
-
Spiffy.markup_to_html(file,
|
88
|
-
css_file: options[:css_file] || set["css_file"] || DEFAULT_CSS_FILE,
|
89
|
-
template_file: options[:template_file] || set["template_file"] || DEFAULT_TEMPLATE_FILE,
|
90
|
-
output_html: options[:html].nil? ? set["html"] || DEFAULT_HTML : options[:html],
|
91
|
-
output_pdf: options[:pdf].nil? ? set["pdf"] || DEFAULT_PDF : options[:pdf])
|
92
|
-
puts "done"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
6
|
+
SpiffyCli.main
|
7
|
+
rescue SystemExit, Interrupt
|
8
|
+
warn "\nExiting.."
|
96
9
|
rescue RuntimeError => e
|
97
10
|
warn e.message
|
98
11
|
end
|
data/lib/spiffy.rb
CHANGED
@@ -3,8 +3,6 @@ require "haml"
|
|
3
3
|
require "pdfkit"
|
4
4
|
|
5
5
|
module Spiffy
|
6
|
-
VERSION = "0.0.16"
|
7
|
-
|
8
6
|
def self.markup_to_html(markup_file, css_file: nil, template_file: nil, output_html: true, output_pdf: false)
|
9
7
|
markup_file_ext = File.extname(markup_file)
|
10
8
|
markup_file_name = markup_file[0...-markup_file_ext.length]
|
data/lib/spiffy_cli.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require "optparse"
|
2
|
+
require "rubygems"
|
3
|
+
require "yaml"
|
4
|
+
require_relative "spiffy"
|
5
|
+
require_relative "spiffy_version"
|
6
|
+
|
7
|
+
module SpiffyCli
|
8
|
+
DEFAULT_DIR = File.join(File.dirname(__FILE__), "../templates")
|
9
|
+
DEFAULT_TEMPLATE_FILE = File.join(DEFAULT_DIR, "default.haml")
|
10
|
+
DEFAULT_CSS_FILE = File.join(DEFAULT_DIR, "default.css")
|
11
|
+
DEFAULT_HTML = true
|
12
|
+
DEFAULT_PDF = false
|
13
|
+
DOT_FILE = ".spiffy.yml"
|
14
|
+
|
15
|
+
def self.main
|
16
|
+
options = {}
|
17
|
+
|
18
|
+
opt_parser = OptionParser.new do |opt|
|
19
|
+
opt.banner = "Usage: spiffy [options] [file] [file] ..."
|
20
|
+
opt.separator("Version: #{SpiffyVersion::VERSION}")
|
21
|
+
opt.separator("")
|
22
|
+
opt.separator("Options")
|
23
|
+
|
24
|
+
opt.on("-c", "--css [css]", "CSS to include inline in the HTML file output") do |css|
|
25
|
+
options[:css_file] = css
|
26
|
+
end
|
27
|
+
|
28
|
+
opt.on("-t", "--template [template]", "Template to wrap the resulting HTML") do |template|
|
29
|
+
options[:template_file] = template
|
30
|
+
end
|
31
|
+
|
32
|
+
opt.on("-p", "--pdf [on|off]", "Output PDF files (default: off)") do |on_or_off|
|
33
|
+
options[:pdf] = on_or_off != "off"
|
34
|
+
end
|
35
|
+
|
36
|
+
opt.on("-h", "--html [on|off]", "Output HTML files (default: on)") do |on_or_off|
|
37
|
+
options[:html] = on_or_off != "off"
|
38
|
+
end
|
39
|
+
|
40
|
+
opt.on("-h", "--help", "This usage outline.") do
|
41
|
+
puts opt_parser
|
42
|
+
end
|
43
|
+
|
44
|
+
opt.separator("")
|
45
|
+
|
46
|
+
opt.separator("Alternatively:")
|
47
|
+
opt.separator("Create a .spiffy.yml in this directory with options within.")
|
48
|
+
opt.separator("See https://github.com/leighmcculloch/spiffy.")
|
49
|
+
|
50
|
+
opt.separator("")
|
51
|
+
end
|
52
|
+
|
53
|
+
opt_parser.parse!
|
54
|
+
|
55
|
+
self.handle(options)
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.handle(options)
|
59
|
+
has_dot_file = File.exists?(DOT_FILE)
|
60
|
+
|
61
|
+
if File.exists?(DOT_FILE)
|
62
|
+
sets = YAML.load_file(DOT_FILE)
|
63
|
+
end
|
64
|
+
|
65
|
+
if ARGV.any?
|
66
|
+
sets = ARGV.map do |arg|
|
67
|
+
set = sets.find({}) do |set|
|
68
|
+
set["markdown_files"].any? do |markdown_file|
|
69
|
+
File.fnmatch(markdown_file, arg)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
set.merge({ "markdown_files" => [arg] })
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if !sets
|
77
|
+
puts opt_parser
|
78
|
+
abort
|
79
|
+
end
|
80
|
+
|
81
|
+
sets.each do |set|
|
82
|
+
set["markdown_files"].each do |input|
|
83
|
+
Dir[input].each do |file|
|
84
|
+
print "Converting #{file}..."
|
85
|
+
|
86
|
+
output_html = options[:html]
|
87
|
+
output_html = set["html"] if output_html.nil?
|
88
|
+
output_html = DEFAULT_HTML if output_html.nil?
|
89
|
+
|
90
|
+
output_pdf = options[:pdf]
|
91
|
+
output_pdf = set["pdf"] if output_pdf.nil?
|
92
|
+
output_pdf = DEFAULT_PDF if output_pdf.nil?
|
93
|
+
|
94
|
+
Spiffy.markup_to_html(file,
|
95
|
+
css_file: options[:css_file] || set["css_file"] || DEFAULT_CSS_FILE,
|
96
|
+
template_file: options[:template_file] || set["template_file"] || DEFAULT_TEMPLATE_FILE,
|
97
|
+
output_html: output_html,
|
98
|
+
output_pdf: output_pdf)
|
99
|
+
puts "done"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
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.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leigh McCulloch
|
@@ -120,6 +120,8 @@ extra_rdoc_files: []
|
|
120
120
|
files:
|
121
121
|
- bin/spiffy
|
122
122
|
- lib/spiffy.rb
|
123
|
+
- lib/spiffy_cli.rb
|
124
|
+
- lib/spiffy_version.rb
|
123
125
|
- templates/default.css
|
124
126
|
- templates/default.haml
|
125
127
|
homepage: http://rubygems.org/gems/hola
|