pdfkit 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pdfkit might be problematic. Click here for more details.
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/lib/pdfkit.rb +0 -2
- data/lib/pdfkit/pdfkit.rb +19 -5
- data/pdfkit.gemspec +1 -4
- data/spec/PDFKit_spec.rb +14 -1
- data/spec/pdfkit_spec.rb +14 -1
- metadata +9 -23
data/Rakefile
CHANGED
@@ -10,7 +10,6 @@ begin
|
|
10
10
|
gem.email = "jared@codewordstudios.com"
|
11
11
|
gem.homepage = "http://github.com/jdpace/PDFKit"
|
12
12
|
gem.authors = ["jdpace"]
|
13
|
-
gem.add_dependency "activesupport"
|
14
13
|
gem.add_development_dependency "rspec", "~> 2.0.0.beta.8"
|
15
14
|
gem.add_development_dependency "rspec-core", "~> 2.0.0.beta.8"
|
16
15
|
gem.add_development_dependency 'mocha'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/lib/pdfkit.rb
CHANGED
data/lib/pdfkit/pdfkit.rb
CHANGED
@@ -28,9 +28,9 @@ class PDFKit
|
|
28
28
|
:margin_bottom => '0.75in',
|
29
29
|
:margin_left => '0.75in'
|
30
30
|
}
|
31
|
-
@options = normalize_options(
|
31
|
+
@options = normalize_options(default_options.merge(options))
|
32
32
|
|
33
|
-
raise NoExecutableError.new if wkhtmltopdf.
|
33
|
+
raise NoExecutableError.new if wkhtmltopdf.nil? || wkhtmltopdf == ''
|
34
34
|
end
|
35
35
|
|
36
36
|
def command
|
@@ -89,11 +89,25 @@ class PDFKit
|
|
89
89
|
normalized_options = {}
|
90
90
|
options.each do |key, value|
|
91
91
|
next if !value
|
92
|
-
normalized_key = "--#{key
|
93
|
-
|
94
|
-
normalized_options[normalized_key] = normalized_value
|
92
|
+
normalized_key = "--#{normalize_arg key}"
|
93
|
+
normalized_options[normalized_key] = normalize_value(value)
|
95
94
|
end
|
96
95
|
normalized_options
|
97
96
|
end
|
97
|
+
|
98
|
+
def normalize_arg(arg)
|
99
|
+
arg.to_s.downcase.gsub(/[^a-z0-9]/,'-')
|
100
|
+
end
|
101
|
+
|
102
|
+
def normalize_value(value)
|
103
|
+
case value
|
104
|
+
when TrueClass
|
105
|
+
nil
|
106
|
+
when String
|
107
|
+
value.match(/\s/) ? "\"#{value}\"" : value
|
108
|
+
else
|
109
|
+
value
|
110
|
+
end
|
111
|
+
end
|
98
112
|
|
99
113
|
end
|
data/pdfkit.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pdfkit}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["jdpace"]
|
@@ -55,18 +55,15 @@ Gem::Specification.new do |s|
|
|
55
55
|
s.specification_version = 3
|
56
56
|
|
57
57
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
59
58
|
s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
|
60
59
|
s.add_development_dependency(%q<rspec-core>, ["~> 2.0.0.beta.8"])
|
61
60
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
62
61
|
else
|
63
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
64
62
|
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
|
65
63
|
s.add_dependency(%q<rspec-core>, ["~> 2.0.0.beta.8"])
|
66
64
|
s.add_dependency(%q<mocha>, [">= 0"])
|
67
65
|
end
|
68
66
|
else
|
69
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
70
67
|
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
|
71
68
|
s.add_dependency(%q<rspec-core>, ["~> 2.0.0.beta.8"])
|
72
69
|
s.add_dependency(%q<mocha>, [">= 0"])
|
data/spec/PDFKit_spec.rb
CHANGED
@@ -42,9 +42,22 @@ describe PDFKit do
|
|
42
42
|
|
43
43
|
context "command" do
|
44
44
|
it "should contstruct the correct command" do
|
45
|
-
pdfkit = PDFKit.new('html', :page_size => 'Letter')
|
45
|
+
pdfkit = PDFKit.new('html', :page_size => 'Letter', :toc_l1_font_size => 12)
|
46
46
|
pdfkit.command.should include('wkhtmltopdf')
|
47
47
|
pdfkit.command.should include('--page-size Letter')
|
48
|
+
pdfkit.command.should include('--toc-l1-font-size 12')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "will not include default options it is told to omit" do
|
52
|
+
pdfkit = PDFKit.new('html')
|
53
|
+
pdfkit.command.should include('--disable-smart-shrinking')
|
54
|
+
pdfkit = PDFKit.new('html', :disable_smart_shrinking => false)
|
55
|
+
pdfkit.command.should_not include('--disable-smart-shrinking')
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should encapsulate string arguments in quotes" do
|
59
|
+
pdfkit = PDFKit.new('html', :header_center => "foo [page]")
|
60
|
+
pdfkit.command.should include('--header-center "foo [page]"')
|
48
61
|
end
|
49
62
|
|
50
63
|
it "read the source from stdin if it is html" do
|
data/spec/pdfkit_spec.rb
CHANGED
@@ -42,9 +42,22 @@ describe PDFKit do
|
|
42
42
|
|
43
43
|
context "command" do
|
44
44
|
it "should contstruct the correct command" do
|
45
|
-
pdfkit = PDFKit.new('html', :page_size => 'Letter')
|
45
|
+
pdfkit = PDFKit.new('html', :page_size => 'Letter', :toc_l1_font_size => 12)
|
46
46
|
pdfkit.command.should include('wkhtmltopdf')
|
47
47
|
pdfkit.command.should include('--page-size Letter')
|
48
|
+
pdfkit.command.should include('--toc-l1-font-size 12')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "will not include default options it is told to omit" do
|
52
|
+
pdfkit = PDFKit.new('html')
|
53
|
+
pdfkit.command.should include('--disable-smart-shrinking')
|
54
|
+
pdfkit = PDFKit.new('html', :disable_smart_shrinking => false)
|
55
|
+
pdfkit.command.should_not include('--disable-smart-shrinking')
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should encapsulate string arguments in quotes" do
|
59
|
+
pdfkit = PDFKit.new('html', :header_center => "foo [page]")
|
60
|
+
pdfkit.command.should include('--header-center "foo [page]"')
|
48
61
|
end
|
49
62
|
|
50
63
|
it "read the source from stdin if it is html" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdfkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- jdpace
|
@@ -18,24 +18,10 @@ cert_chain: []
|
|
18
18
|
date: 2010-06-18 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
name: activesupport
|
23
|
-
prerelease: false
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
33
|
-
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
21
|
- !ruby/object:Gem::Dependency
|
36
22
|
name: rspec
|
37
23
|
prerelease: false
|
38
|
-
requirement: &
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
26
|
requirements:
|
41
27
|
- - ~>
|
@@ -49,11 +35,11 @@ dependencies:
|
|
49
35
|
- 8
|
50
36
|
version: 2.0.0.beta.8
|
51
37
|
type: :development
|
52
|
-
version_requirements: *
|
38
|
+
version_requirements: *id001
|
53
39
|
- !ruby/object:Gem::Dependency
|
54
40
|
name: rspec-core
|
55
41
|
prerelease: false
|
56
|
-
requirement: &
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
57
43
|
none: false
|
58
44
|
requirements:
|
59
45
|
- - ~>
|
@@ -67,11 +53,11 @@ dependencies:
|
|
67
53
|
- 8
|
68
54
|
version: 2.0.0.beta.8
|
69
55
|
type: :development
|
70
|
-
version_requirements: *
|
56
|
+
version_requirements: *id002
|
71
57
|
- !ruby/object:Gem::Dependency
|
72
58
|
name: mocha
|
73
59
|
prerelease: false
|
74
|
-
requirement: &
|
60
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
75
61
|
none: false
|
76
62
|
requirements:
|
77
63
|
- - ">="
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- 0
|
82
68
|
version: "0"
|
83
69
|
type: :development
|
84
|
-
version_requirements: *
|
70
|
+
version_requirements: *id003
|
85
71
|
description: Uses wkhtmltopdf to create PDFs using HTML
|
86
72
|
email: jared@codewordstudios.com
|
87
73
|
executables:
|