spiffy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/bin/spiffy +50 -0
  3. data/defaults/template.haml +7 -0
  4. data/lib/spiffy.rb +38 -0
  5. metadata +222 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 27591d49e69f45079512a504e59138a6752a2706
4
+ data.tar.gz: 18add8c07f6da748c9c7334ac509c9bf51d6640b
5
+ SHA512:
6
+ metadata.gz: 0ad8fadc56e3c1b59e611265592813b26c75a2288ef24ff0663cbd7adc51cf87f87597d616c986831fd8445138ccba33750e1f2cbbeb68e59b9c45febf0f9c05
7
+ data.tar.gz: 4176bf64275a0f02975da452bf8687d3dc9aa6353e68bfed0622d0e5e4a328b46477416382708ed0e7c2b2ced0cab0e543259f24b74382cfb0ffc1f6da82a08e
data/bin/spiffy ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "rubygems"
5
+ require_relative "../lib/spiffy"
6
+
7
+ spec = Gem::Specification::load("spiffy.gemspec")
8
+
9
+ DEFAULT_DIR = File.join(File.dirname(__FILE__), "../defaults")
10
+ DEFAULT_TEMPLATE_FILE = File.join(DEFAULT_DIR, "template.haml")
11
+ DEFAULT_CSS_FILE = File.join(DEFAULT_DIR, "style.css")
12
+
13
+ options = {
14
+ :template => DEFAULT_TEMPLATE_FILE,
15
+ :css => DEFAULT_CSS_FILE
16
+ }
17
+
18
+ opt_parser = OptionParser.new do |opt|
19
+ opt.banner = "Usage: spiffy [options] [file] [file] ..."
20
+ opt.separator("Version: #{spec.version}")
21
+ opt.separator("")
22
+ opt.separator("Options")
23
+
24
+ opt.on("-C", "--css", String, "CSS to include inline in the HTML file output") do |css|
25
+ options[:css] = css
26
+ end
27
+
28
+ opt.on("-T", "--template", String, "Template to wrap the resulting HTML") do |template|
29
+ options[:template] = template
30
+ end
31
+
32
+ opt.on("-h", "--help", "help") do
33
+ puts opt_parser
34
+ end
35
+
36
+ opt.separator("")
37
+ end
38
+
39
+ opt_parser.parse!
40
+
41
+ if ARGV.empty?
42
+ puts opt_parser
43
+ else
44
+ inputs = ARGV
45
+ inputs.each do |inputs|
46
+ Dir[inputs].each do |file|
47
+ Spiffy.markup_to_html(file, css_file: options[:css], template_file: options[:template])
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,7 @@
1
+ %html
2
+ %head
3
+ %meta{ :charset => "utf-8" }
4
+ %style
5
+ = yield :css
6
+ %body
7
+ = yield :body
data/lib/spiffy.rb ADDED
@@ -0,0 +1,38 @@
1
+ require "github/markup"
2
+ require "redcarpet"
3
+ require "RedCloth"
4
+ require "rdoc"
5
+ require "org-ruby"
6
+ require "creole"
7
+ require "wikicloth"
8
+ require "asciidoctor"
9
+ require "haml"
10
+
11
+ module Spiffy
12
+ def self.markup_to_html(markup_file, css_file: nil, template_file: nil)
13
+ markup_file_name = File.basename(markup_file, ".*")
14
+ markup = File.open(markup_file, "r:UTF-8", &:read)
15
+
16
+ html = GitHub::Markup.render(markup_file, markup)
17
+
18
+ if css_file
19
+ css = File.open(css_file, "r:UTF-8", &:read)
20
+ end
21
+
22
+ if template_file
23
+ template_ext = File.extname(template_file)
24
+ template = File.open(template_file, "r:UTF-8", &:read)
25
+ html = case template_ext
26
+ when ".erb"
27
+ ERB.new(template).result { |section| case section; when :css; css; when :body; html; end }
28
+ when ".haml"
29
+ Haml::Engine.new(template).render { |section| case section; when :css; css; when :body; html; end }
30
+ else
31
+ raise "Template file #{template_file} unsupported. Only .erb or .haml are supported."
32
+ end
33
+ end
34
+
35
+ out_file = "#{markup_file_name}.html"
36
+ File.open(out_file, "w:UTF-8") { |f| f.write(html) }
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,222 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spiffy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Leigh McCulloch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: github-markup
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.3.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: redcarpet
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.2'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.2.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.2'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.2.2
53
+ - !ruby/object:Gem::Dependency
54
+ name: RedCloth
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '4.2'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 4.2.9
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '4.2'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 4.2.9
73
+ - !ruby/object:Gem::Dependency
74
+ name: rdoc
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '='
78
+ - !ruby/object:Gem::Version
79
+ version: 3.6.1
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '='
85
+ - !ruby/object:Gem::Version
86
+ version: 3.6.1
87
+ - !ruby/object:Gem::Dependency
88
+ name: org-ruby
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '0.9'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.12
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 0.9.12
107
+ - !ruby/object:Gem::Dependency
108
+ name: creole
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '0.5'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 0.5.0
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '0.5'
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 0.5.0
127
+ - !ruby/object:Gem::Dependency
128
+ name: wikicloth
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '0.8'
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 0.8.2
137
+ type: :runtime
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: '0.8'
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: 0.8.2
147
+ - !ruby/object:Gem::Dependency
148
+ name: asciidoctor
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '1.5'
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: 1.5.2
157
+ type: :runtime
158
+ prerelease: false
159
+ version_requirements: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: '1.5'
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 1.5.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: haml
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '4.0'
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: 4.0.6
177
+ type: :runtime
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '4.0'
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: 4.0.6
187
+ description: A markup to HTML & PDF converter. Supports all markups supported by Github,
188
+ including markdown, rdoc, etc.
189
+ email: leigh@mcchouse.com
190
+ executables:
191
+ - spiffy
192
+ extensions: []
193
+ extra_rdoc_files: []
194
+ files:
195
+ - bin/spiffy
196
+ - defaults/template.haml
197
+ - lib/spiffy.rb
198
+ homepage: http://rubygems.org/gems/hola
199
+ licenses:
200
+ - BSD-3-Clause
201
+ metadata: {}
202
+ post_install_message:
203
+ rdoc_options: []
204
+ require_paths:
205
+ - lib
206
+ required_ruby_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
211
+ required_rubygems_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ requirements: []
217
+ rubyforge_project:
218
+ rubygems_version: 2.2.2
219
+ signing_key:
220
+ specification_version: 4
221
+ summary: A markup to HTML & PDF converter.
222
+ test_files: []