gimli 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gimli +6 -1
- data/lib/gimli.rb +3 -7
- data/lib/gimli/converter.rb +9 -6
- data/lib/gimli/version.rb +1 -1
- data/spec/gimli/converter_spec.rb +6 -15
- metadata +48 -33
data/bin/gimli
CHANGED
@@ -4,5 +4,10 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + '/../lib/')
|
|
4
4
|
|
5
5
|
require 'gimli'
|
6
6
|
|
7
|
-
|
7
|
+
if ARGV.flags.version?
|
8
|
+
puts "Version: #{Gimli::Version}"
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
Gimli.process! ARGV.flags.file, ARGV.flags.recursive?, ARGV.flags.merge?, ARGV.flags.outputfilename, ARGV.flags.outputdir, ARGV.flags.stylesheet
|
8
13
|
|
data/lib/gimli.rb
CHANGED
@@ -10,14 +10,10 @@ require 'gimli/path'
|
|
10
10
|
module Gimli
|
11
11
|
|
12
12
|
# Starts the processing of selected files
|
13
|
-
def self.process!
|
13
|
+
def self.process!(file, recursive = false, merge = false, output_filename = nil, output_dir = nil, stylesheet = nil)
|
14
14
|
|
15
|
-
if ARGV.flags.version?
|
16
|
-
puts "Version: #{Gimli::Version}"
|
17
|
-
return
|
18
|
-
end
|
19
15
|
|
20
|
-
@files = Path.list_valid(
|
21
|
-
Converter.new(@files).convert!(
|
16
|
+
@files = Path.list_valid(file, recursive).map { |file| MarkupFile.new(file) }
|
17
|
+
Converter.new(@files, output_filename, output_dir, stylesheet).convert!(merge)
|
22
18
|
end
|
23
19
|
end
|
data/lib/gimli/converter.rb
CHANGED
@@ -13,8 +13,11 @@ module Gimli
|
|
13
13
|
|
14
14
|
# Initialize the converter with a File
|
15
15
|
# @param [Array] files The list of Gimli::MarkupFile to convert (passing a single file will still work)
|
16
|
-
def initialize(files)
|
16
|
+
def initialize(files, output_filename = nil, output_dir = nil, stylesheet = nil)
|
17
17
|
@files = files
|
18
|
+
@output_filename = output_filename
|
19
|
+
@output_dir = output_dir
|
20
|
+
@stylesheet = stylesheet
|
18
21
|
end
|
19
22
|
|
20
23
|
# Convert the file and save it as a PDF file
|
@@ -81,13 +84,13 @@ module Gimli
|
|
81
84
|
# Returns the selected stylesheet. Defaults to ./gimli.css
|
82
85
|
# @return [String]
|
83
86
|
def stylesheet
|
84
|
-
|
87
|
+
@stylesheet.nil? ? 'gimli.css' : @stylesheet
|
85
88
|
end
|
86
89
|
|
87
90
|
# Returns the directory where to save the output. Defaults to ./
|
88
91
|
# @return [String]
|
89
92
|
def output_dir
|
90
|
-
output_dir =
|
93
|
+
output_dir = @output_dir.nil? ? Dir.getwd : @output_dir
|
91
94
|
FileUtils.mkdir_p(output_dir) unless ::File.directory?(output_dir)
|
92
95
|
output_dir
|
93
96
|
end
|
@@ -98,13 +101,13 @@ module Gimli
|
|
98
101
|
def output_file(file = nil)
|
99
102
|
if file
|
100
103
|
output_filename = file.name
|
101
|
-
if
|
102
|
-
output_filename =
|
104
|
+
if !@output_filename.nil? && @files.length == 1
|
105
|
+
output_filename = @output_filename
|
103
106
|
end
|
104
107
|
else
|
105
108
|
output_filename = Time.now.to_s.split(' ').join('_')
|
106
109
|
output_filename = @files.last.name if @files.length == 1 || ARGV.flags.merge?
|
107
|
-
output_filename =
|
110
|
+
output_filename = @output_filename unless @output_filename.nil?
|
108
111
|
end
|
109
112
|
|
110
113
|
::File.join(output_dir, "#{output_filename}.pdf")
|
data/lib/gimli/version.rb
CHANGED
@@ -31,10 +31,8 @@ describe Gimli::Converter do
|
|
31
31
|
file = Gimli::MarkupFile.new 'fake'
|
32
32
|
output_filename = 'my_file'
|
33
33
|
|
34
|
-
converter = Gimli::Converter.new [file]
|
34
|
+
converter = Gimli::Converter.new [file], output_filename
|
35
35
|
mock(converter).output_dir { Dir.getwd }
|
36
|
-
mock(ARGV).flags.mock!.outputfilename? { true }
|
37
|
-
mock(ARGV).flags.mock!.outputfilename { output_filename }
|
38
36
|
|
39
37
|
converter.output_file.should == File.join(Dir.getwd, "#{output_filename}.pdf")
|
40
38
|
end
|
@@ -52,34 +50,27 @@ describe Gimli::Converter do
|
|
52
50
|
dir = '/tmp/out'
|
53
51
|
|
54
52
|
file = Gimli::MarkupFile.new 'fake'
|
55
|
-
converter = Gimli::Converter.new file
|
53
|
+
converter = Gimli::Converter.new file, nil, dir
|
56
54
|
|
57
|
-
mock(ARGV).flags.mock!.outputdir? { true }
|
58
|
-
mock(ARGV).flags.mock!.outputdir { dir }
|
59
55
|
mock(File).directory?(dir) { true }
|
60
56
|
|
61
57
|
converter.output_dir.should == dir
|
62
58
|
end
|
63
59
|
|
64
|
-
it 'should use stylesheet if
|
60
|
+
it 'should use default stylesheet if none given' do
|
65
61
|
file = Gimli::MarkupFile.new 'fake'
|
66
62
|
converter = Gimli::Converter.new file
|
67
63
|
|
68
|
-
mock(ARGV).flags.mock!.stylesheet? { false }
|
69
|
-
|
70
64
|
converter.stylesheet.should == 'gimli.css'
|
71
65
|
end
|
72
66
|
|
73
67
|
it 'should use stylesheet if given' do
|
74
68
|
file = Gimli::MarkupFile.new 'fake'
|
75
|
-
|
76
|
-
|
77
|
-
style = '/home/me/gimli/my-style.css'
|
69
|
+
stylesheet = '/home/me/gimli/my-style.css'
|
78
70
|
|
79
|
-
|
80
|
-
mock(ARGV).flags.mock!.stylesheet { style }
|
71
|
+
converter = Gimli::Converter.new file, nil, nil, stylesheet
|
81
72
|
|
82
|
-
converter.stylesheet.should ==
|
73
|
+
converter.stylesheet.should == stylesheet
|
83
74
|
end
|
84
75
|
|
85
76
|
it 'should convert relative image urls to absolute' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gimli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-08-25 00:00:00.000000000Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: github-markup
|
17
|
-
requirement: &
|
16
|
+
requirement: &22561440 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ~>
|
@@ -22,10 +21,10 @@ dependencies:
|
|
22
21
|
version: 0.5.3
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *22561440
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: redcarpet
|
28
|
-
requirement: &
|
27
|
+
requirement: &22557940 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ~>
|
@@ -33,10 +32,10 @@ dependencies:
|
|
33
32
|
version: 1.17.2
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *22557940
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: RedCloth
|
39
|
-
requirement: &
|
38
|
+
requirement: &22556960 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ~>
|
@@ -44,10 +43,10 @@ dependencies:
|
|
44
43
|
version: 4.2.7
|
45
44
|
type: :runtime
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
46
|
+
version_requirements: *22556960
|
48
47
|
- !ruby/object:Gem::Dependency
|
49
48
|
name: org-ruby
|
50
|
-
requirement: &
|
49
|
+
requirement: &22555840 !ruby/object:Gem::Requirement
|
51
50
|
none: false
|
52
51
|
requirements:
|
53
52
|
- - ~>
|
@@ -55,10 +54,10 @@ dependencies:
|
|
55
54
|
version: 0.5.3
|
56
55
|
type: :runtime
|
57
56
|
prerelease: false
|
58
|
-
version_requirements: *
|
57
|
+
version_requirements: *22555840
|
59
58
|
- !ruby/object:Gem::Dependency
|
60
59
|
name: creole
|
61
|
-
requirement: &
|
60
|
+
requirement: &22555200 !ruby/object:Gem::Requirement
|
62
61
|
none: false
|
63
62
|
requirements:
|
64
63
|
- - ~>
|
@@ -66,10 +65,10 @@ dependencies:
|
|
66
65
|
version: 0.4.2
|
67
66
|
type: :runtime
|
68
67
|
prerelease: false
|
69
|
-
version_requirements: *
|
68
|
+
version_requirements: *22555200
|
70
69
|
- !ruby/object:Gem::Dependency
|
71
70
|
name: wikicloth
|
72
|
-
requirement: &
|
71
|
+
requirement: &22554420 !ruby/object:Gem::Requirement
|
73
72
|
none: false
|
74
73
|
requirements:
|
75
74
|
- - ~>
|
@@ -77,10 +76,10 @@ dependencies:
|
|
77
76
|
version: 0.6.3
|
78
77
|
type: :runtime
|
79
78
|
prerelease: false
|
80
|
-
version_requirements: *
|
79
|
+
version_requirements: *22554420
|
81
80
|
- !ruby/object:Gem::Dependency
|
82
81
|
name: albino
|
83
|
-
requirement: &
|
82
|
+
requirement: &22553060 !ruby/object:Gem::Requirement
|
84
83
|
none: false
|
85
84
|
requirements:
|
86
85
|
- - ~>
|
@@ -88,10 +87,10 @@ dependencies:
|
|
88
87
|
version: 1.3.3
|
89
88
|
type: :runtime
|
90
89
|
prerelease: false
|
91
|
-
version_requirements: *
|
90
|
+
version_requirements: *22553060
|
92
91
|
- !ruby/object:Gem::Dependency
|
93
92
|
name: nokogiri
|
94
|
-
requirement: &
|
93
|
+
requirement: &22551860 !ruby/object:Gem::Requirement
|
95
94
|
none: false
|
96
95
|
requirements:
|
97
96
|
- - ~>
|
@@ -99,10 +98,10 @@ dependencies:
|
|
99
98
|
version: 1.4.4
|
100
99
|
type: :runtime
|
101
100
|
prerelease: false
|
102
|
-
version_requirements: *
|
101
|
+
version_requirements: *22551860
|
103
102
|
- !ruby/object:Gem::Dependency
|
104
103
|
name: wkhtmltopdf-binary
|
105
|
-
requirement: &
|
104
|
+
requirement: &22550100 !ruby/object:Gem::Requirement
|
106
105
|
none: false
|
107
106
|
requirements:
|
108
107
|
- - ~>
|
@@ -110,10 +109,10 @@ dependencies:
|
|
110
109
|
version: 0.9.5.3
|
111
110
|
type: :runtime
|
112
111
|
prerelease: false
|
113
|
-
version_requirements: *
|
112
|
+
version_requirements: *22550100
|
114
113
|
- !ruby/object:Gem::Dependency
|
115
114
|
name: pdfkit
|
116
|
-
requirement: &
|
115
|
+
requirement: &22546560 !ruby/object:Gem::Requirement
|
117
116
|
none: false
|
118
117
|
requirements:
|
119
118
|
- - ~>
|
@@ -121,10 +120,10 @@ dependencies:
|
|
121
120
|
version: 0.5.2
|
122
121
|
type: :runtime
|
123
122
|
prerelease: false
|
124
|
-
version_requirements: *
|
123
|
+
version_requirements: *22546560
|
125
124
|
- !ruby/object:Gem::Dependency
|
126
125
|
name: optiflag
|
127
|
-
requirement: &
|
126
|
+
requirement: &22545840 !ruby/object:Gem::Requirement
|
128
127
|
none: false
|
129
128
|
requirements:
|
130
129
|
- - ~>
|
@@ -132,10 +131,21 @@ dependencies:
|
|
132
131
|
version: '0.7'
|
133
132
|
type: :runtime
|
134
133
|
prerelease: false
|
135
|
-
version_requirements: *
|
134
|
+
version_requirements: *22545840
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: rake
|
137
|
+
requirement: &22545180 !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
type: :development
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: *22545180
|
136
146
|
- !ruby/object:Gem::Dependency
|
137
147
|
name: rspec
|
138
|
-
requirement: &
|
148
|
+
requirement: &22544200 !ruby/object:Gem::Requirement
|
139
149
|
none: false
|
140
150
|
requirements:
|
141
151
|
- - ! '>='
|
@@ -143,10 +153,10 @@ dependencies:
|
|
143
153
|
version: '0'
|
144
154
|
type: :development
|
145
155
|
prerelease: false
|
146
|
-
version_requirements: *
|
156
|
+
version_requirements: *22544200
|
147
157
|
- !ruby/object:Gem::Dependency
|
148
158
|
name: rr
|
149
|
-
requirement: &
|
159
|
+
requirement: &22543320 !ruby/object:Gem::Requirement
|
150
160
|
none: false
|
151
161
|
requirements:
|
152
162
|
- - ! '>='
|
@@ -154,10 +164,10 @@ dependencies:
|
|
154
164
|
version: '0'
|
155
165
|
type: :development
|
156
166
|
prerelease: false
|
157
|
-
version_requirements: *
|
167
|
+
version_requirements: *22543320
|
158
168
|
- !ruby/object:Gem::Dependency
|
159
169
|
name: bundler
|
160
|
-
requirement: &
|
170
|
+
requirement: &22542540 !ruby/object:Gem::Requirement
|
161
171
|
none: false
|
162
172
|
requirements:
|
163
173
|
- - ! '>='
|
@@ -165,7 +175,7 @@ dependencies:
|
|
165
175
|
version: '0'
|
166
176
|
type: :development
|
167
177
|
prerelease: false
|
168
|
-
version_requirements: *
|
178
|
+
version_requirements: *22542540
|
169
179
|
description: Utility for converting markup files to pdf files. Useful for reports
|
170
180
|
etc.
|
171
181
|
email: fredrik.wallgren@gmail.com
|
@@ -198,7 +208,6 @@ files:
|
|
198
208
|
- config/style.css
|
199
209
|
- LICENSE
|
200
210
|
- README.textile
|
201
|
-
has_rdoc: true
|
202
211
|
homepage: https://github.com/walle/gimli
|
203
212
|
licenses: []
|
204
213
|
post_install_message:
|
@@ -212,15 +221,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
221
|
- - ! '>='
|
213
222
|
- !ruby/object:Gem::Version
|
214
223
|
version: '0'
|
224
|
+
segments:
|
225
|
+
- 0
|
226
|
+
hash: 1493974172056676610
|
215
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
228
|
none: false
|
217
229
|
requirements:
|
218
230
|
- - ! '>='
|
219
231
|
- !ruby/object:Gem::Version
|
220
232
|
version: '0'
|
233
|
+
segments:
|
234
|
+
- 0
|
235
|
+
hash: 1493974172056676610
|
221
236
|
requirements: []
|
222
237
|
rubyforge_project: gimli
|
223
|
-
rubygems_version: 1.6
|
238
|
+
rubygems_version: 1.8.6
|
224
239
|
signing_key:
|
225
240
|
specification_version: 3
|
226
241
|
summary: Utility for converting markup files to pdf files.
|