wicked_pdf 0.11.0 → 1.0.0
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/.gitignore +1 -1
- data/.travis.yml +13 -3
- data/Gemfile +1 -1
- data/README.md +152 -142
- data/Rakefile +24 -12
- data/gemfiles/2.3.gemfile +2 -0
- data/gemfiles/3.1.gemfile +3 -2
- data/gemfiles/3.2.gemfile +3 -2
- data/gemfiles/4.0.gemfile +2 -2
- data/gemfiles/4.1.gemfile +6 -0
- data/gemfiles/4.2.gemfile +6 -0
- data/gemfiles/rails_edge.gemfile +3 -3
- data/generators/wicked_pdf/templates/wicked_pdf.rb +19 -3
- data/generators/wicked_pdf/wicked_pdf_generator.rb +1 -1
- data/lib/generators/wicked_pdf_generator.rb +2 -2
- data/lib/wicked_pdf.rb +241 -212
- data/lib/wicked_pdf/middleware.rb +6 -7
- data/lib/wicked_pdf/pdf_helper.rb +53 -53
- data/lib/wicked_pdf/railtie.rb +14 -14
- data/lib/wicked_pdf/tempfile.rb +2 -2
- data/lib/wicked_pdf/version.rb +2 -2
- data/lib/wicked_pdf/wicked_pdf_helper.rb +30 -15
- data/test/functional/pdf_helper_test.rb +5 -5
- data/test/functional/wicked_pdf_helper_assets_test.rb +35 -8
- data/test/functional/wicked_pdf_helper_test.rb +2 -2
- data/test/test_helper.rb +10 -5
- data/test/unit/wicked_pdf_test.rb +90 -57
- data/wicked_pdf.gemspec +5 -4
- metadata +20 -72
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -59
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -67
- data/test/dummy/config/environments/test.rb +0 -37
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
WickedPdf.config = { :exe_path => ENV['WKHTMLTOPDF_BIN'] || '/usr/local/bin/wkhtmltopdf' }
|
4
|
-
HTML_DOCUMENT =
|
4
|
+
HTML_DOCUMENT = '<html><body>Hello World</body></html>'
|
5
5
|
|
6
6
|
# Provide a public accessor to the normally-private parse_options function.
|
7
7
|
# Also, smash the returned array of options into a single string for
|
@@ -10,6 +10,14 @@ class WickedPdf
|
|
10
10
|
def get_parsed_options(opts)
|
11
11
|
parse_options(opts).join(' ')
|
12
12
|
end
|
13
|
+
|
14
|
+
def get_valid_option(name)
|
15
|
+
valid_option(name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_binary_version_to(version)
|
19
|
+
@binary_version = version
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
23
|
class WickedPdfTest < ActiveSupport::TestCase
|
@@ -17,45 +25,45 @@ class WickedPdfTest < ActiveSupport::TestCase
|
|
17
25
|
@wp = WickedPdf.new
|
18
26
|
end
|
19
27
|
|
20
|
-
test
|
28
|
+
test 'should generate PDF from html document' do
|
21
29
|
wp = WickedPdf.new
|
22
30
|
pdf = wp.pdf_from_string HTML_DOCUMENT
|
23
|
-
assert pdf.start_with?(
|
24
|
-
assert pdf.rstrip.end_with?(
|
31
|
+
assert pdf.start_with?('%PDF-1.4')
|
32
|
+
assert pdf.rstrip.end_with?('%%EOF')
|
25
33
|
assert pdf.length > 100
|
26
34
|
end
|
27
35
|
|
28
|
-
test
|
36
|
+
test 'should generate PDF from html document with long lines' do
|
29
37
|
wp = WickedPdf.new
|
30
|
-
document_with_long_line_file = File.new(
|
38
|
+
document_with_long_line_file = File.new('test/fixtures/document_with_long_line.html', 'r')
|
31
39
|
pdf = wp.pdf_from_string(document_with_long_line_file.read)
|
32
|
-
assert pdf.start_with?(
|
33
|
-
assert pdf.rstrip.end_with?(
|
40
|
+
assert pdf.start_with?('%PDF-1.4')
|
41
|
+
assert pdf.rstrip.end_with?('%%EOF')
|
34
42
|
assert pdf.length > 100
|
35
43
|
end
|
36
44
|
|
37
|
-
test
|
45
|
+
test 'should generate PDF from html existing HTML file without converting it to string' do
|
38
46
|
wp = WickedPdf.new
|
39
|
-
filepath = File.join(Dir.pwd,
|
47
|
+
filepath = File.join(Dir.pwd, 'test/fixtures/document_with_long_line.html')
|
40
48
|
pdf = wp.pdf_from_html_file(filepath)
|
41
|
-
assert pdf.start_with?(
|
42
|
-
assert pdf.rstrip.end_with?(
|
49
|
+
assert pdf.start_with?('%PDF-1.4')
|
50
|
+
assert pdf.rstrip.end_with?('%%EOF')
|
43
51
|
assert pdf.length > 100
|
44
52
|
end
|
45
53
|
|
46
|
-
test
|
54
|
+
test 'should raise exception when no path to wkhtmltopdf' do
|
47
55
|
assert_raise RuntimeError do
|
48
|
-
WickedPdf.new
|
56
|
+
WickedPdf.new ' '
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
|
-
test
|
60
|
+
test 'should raise exception when wkhtmltopdf path is wrong' do
|
53
61
|
assert_raise RuntimeError do
|
54
|
-
WickedPdf.new
|
62
|
+
WickedPdf.new '/i/do/not/exist/notwkhtmltopdf'
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|
58
|
-
test
|
66
|
+
test 'should raise exception when wkhtmltopdf is not executable' do
|
59
67
|
begin
|
60
68
|
tmp = Tempfile.new('wkhtmltopdf')
|
61
69
|
fp = tmp.path
|
@@ -68,7 +76,7 @@ class WickedPdfTest < ActiveSupport::TestCase
|
|
68
76
|
end
|
69
77
|
end
|
70
78
|
|
71
|
-
test
|
79
|
+
test 'should raise exception when pdf generation fails' do
|
72
80
|
begin
|
73
81
|
tmp = Tempfile.new('wkhtmltopdf')
|
74
82
|
fp = tmp.path
|
@@ -82,85 +90,88 @@ class WickedPdfTest < ActiveSupport::TestCase
|
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
85
|
-
test
|
93
|
+
test 'should parse header and footer options' do
|
86
94
|
wp = WickedPdf.new
|
87
95
|
|
88
96
|
[:header, :footer].each do |hf|
|
89
97
|
[:center, :font_name, :left, :right].each do |o|
|
90
|
-
assert_equal
|
91
|
-
|
98
|
+
assert_equal "--#{hf.to_s}-#{o.to_s.gsub('_', '-')} header_footer",
|
99
|
+
wp.get_parsed_options(hf => { o => 'header_footer' }).strip
|
92
100
|
end
|
93
101
|
|
94
102
|
[:font_size, :spacing].each do |o|
|
95
|
-
assert_equal
|
96
|
-
|
103
|
+
assert_equal "--#{hf.to_s}-#{o.to_s.gsub('_', '-')} 12",
|
104
|
+
wp.get_parsed_options(hf => { o => '12' }).strip
|
97
105
|
end
|
98
106
|
|
99
|
-
assert_equal
|
100
|
-
|
101
|
-
assert_equal
|
102
|
-
|
107
|
+
assert_equal "--#{hf.to_s}-line",
|
108
|
+
wp.get_parsed_options(hf => { :line => true }).strip
|
109
|
+
assert_equal "--#{hf.to_s}-html http://www.abc.com",
|
110
|
+
wp.get_parsed_options(hf => { :html => { :url => 'http://www.abc.com' } }).strip
|
103
111
|
end
|
104
112
|
end
|
105
113
|
|
106
|
-
test
|
114
|
+
test 'should parse toc options' do
|
107
115
|
wp = WickedPdf.new
|
116
|
+
toc_option = wp.get_valid_option('toc')
|
108
117
|
|
109
118
|
[:font_name, :header_text].each do |o|
|
110
|
-
assert_equal
|
111
|
-
|
119
|
+
assert_equal "#{toc_option} --toc-#{o.to_s.gsub('_', '-')} toc",
|
120
|
+
wp.get_parsed_options(:toc => { o => 'toc' }).strip
|
112
121
|
end
|
113
122
|
|
114
|
-
[
|
123
|
+
[:depth, :header_fs, :l1_font_size, :l2_font_size, :l3_font_size, :l4_font_size,
|
115
124
|
:l5_font_size, :l6_font_size, :l7_font_size, :l1_indentation, :l2_indentation,
|
116
125
|
:l3_indentation, :l4_indentation, :l5_indentation, :l6_indentation, :l7_indentation
|
117
126
|
].each do |o|
|
118
|
-
assert_equal
|
119
|
-
|
127
|
+
assert_equal "#{toc_option} --toc-#{o.to_s.gsub('_', '-')} 5",
|
128
|
+
wp.get_parsed_options(:toc => { o => 5 }).strip
|
120
129
|
end
|
121
130
|
|
122
131
|
[:no_dots, :disable_links, :disable_back_links].each do |o|
|
123
|
-
assert_equal
|
124
|
-
|
132
|
+
assert_equal "#{toc_option} --toc-#{o.to_s.gsub('_', '-')}",
|
133
|
+
wp.get_parsed_options(:toc => { o => true }).strip
|
125
134
|
end
|
126
135
|
end
|
127
136
|
|
128
|
-
test
|
137
|
+
test 'should parse outline options' do
|
129
138
|
wp = WickedPdf.new
|
130
139
|
|
131
|
-
assert_equal
|
132
|
-
assert_equal
|
140
|
+
assert_equal '--outline', wp.get_parsed_options(:outline => { :outline => true }).strip
|
141
|
+
assert_equal '--outline-depth 5', wp.get_parsed_options(:outline => { :outline_depth => 5 }).strip
|
133
142
|
end
|
134
143
|
|
135
|
-
test
|
144
|
+
test 'should parse margins options' do
|
136
145
|
wp = WickedPdf.new
|
137
146
|
|
138
147
|
[:top, :bottom, :left, :right].each do |o|
|
139
|
-
assert_equal "--margin-#{o.to_s} 12", wp.get_parsed_options(:margin => {o =>
|
148
|
+
assert_equal "--margin-#{o.to_s} 12", wp.get_parsed_options(:margin => { o => '12' }).strip
|
140
149
|
end
|
141
150
|
end
|
142
151
|
|
143
|
-
test
|
152
|
+
test 'should parse cover' do
|
144
153
|
wp = WickedPdf.new
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
154
|
+
cover_option = wp.get_valid_option('cover')
|
155
|
+
|
156
|
+
pathname = Rails.root.join('app', 'views', 'pdf', 'file.html')
|
157
|
+
assert_equal "#{cover_option} http://example.org", wp.get_parsed_options(:cover => 'http://example.org').strip, 'URL'
|
158
|
+
assert_equal "#{cover_option} #{pathname.to_s}", wp.get_parsed_options(:cover => pathname).strip, 'Pathname'
|
159
|
+
assert_match /#{cover_option} .+wicked_cover_pdf.+\.html/, wp.get_parsed_options(:cover => '<html><body>HELLO</body></html>').strip, 'HTML'
|
149
160
|
end
|
150
161
|
|
151
|
-
test
|
162
|
+
test 'should parse other options' do
|
152
163
|
wp = WickedPdf.new
|
153
164
|
|
154
|
-
[
|
165
|
+
[:orientation, :page_size, :proxy, :username, :password, :dpi,
|
155
166
|
:encoding, :user_style_sheet
|
156
167
|
].each do |o|
|
157
|
-
assert_equal "--#{o.to_s.gsub('_', '-')} opts", wp.get_parsed_options(o =>
|
168
|
+
assert_equal "--#{o.to_s.gsub('_', '-')} opts", wp.get_parsed_options(o => 'opts').strip
|
158
169
|
end
|
159
170
|
|
160
171
|
[:cookie, :post].each do |o|
|
161
|
-
assert_equal "--#{o.to_s.gsub('_', '-')} name value", wp.get_parsed_options(o =>
|
172
|
+
assert_equal "--#{o.to_s.gsub('_', '-')} name value", wp.get_parsed_options(o => 'name value').strip
|
162
173
|
|
163
|
-
nv_formatter =
|
174
|
+
nv_formatter = proc { |number| "--#{o.to_s.gsub('_', '-')} par#{number} val#{number}" }
|
164
175
|
assert_equal "#{nv_formatter.call(1)} #{nv_formatter.call(2)}", wp.get_parsed_options(o => ['par1 val1', 'par2 val2']).strip
|
165
176
|
end
|
166
177
|
|
@@ -168,7 +179,7 @@ class WickedPdfTest < ActiveSupport::TestCase
|
|
168
179
|
assert_equal "--#{o.to_s.gsub('_', '-')} 5", wp.get_parsed_options(o => 5).strip
|
169
180
|
end
|
170
181
|
|
171
|
-
[
|
182
|
+
[:book, :default_header, :disable_javascript, :grayscale, :lowquality,
|
172
183
|
:enable_plugins, :disable_internal_links, :disable_external_links,
|
173
184
|
:print_media_type, :disable_smart_shrinking, :use_xserver, :no_background
|
174
185
|
].each do |o|
|
@@ -176,26 +187,48 @@ class WickedPdfTest < ActiveSupport::TestCase
|
|
176
187
|
end
|
177
188
|
end
|
178
189
|
|
179
|
-
test
|
190
|
+
test 'should extract old wkhtmltopdf version' do
|
180
191
|
version_info_sample = "Name:\n wkhtmltopdf 0.9.9\n\nLicense:\n Copyright (C) 2008,2009 Wkhtmltopdf Authors.\n\n\n\n License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n This is free software: you are free to change and redistribute it. There is NO\n WARRANTY, to the extent permitted by law.\n\nAuthors:\n Written by Jakob Truelsen. Patches by Mrio Silva, Benoit Garret and Emmanuel\n Bouthenot.\n"
|
181
192
|
assert_equal WickedPdf::DEFAULT_BINARY_VERSION, @wp.send(:parse_version, version_info_sample)
|
182
193
|
end
|
183
194
|
|
184
|
-
test
|
195
|
+
test 'should extract new wkhtmltopdf version' do
|
185
196
|
version_info_sample = "Name:\n wkhtmltopdf 0.11.0 rc2\n\nLicense:\n Copyright (C) 2010 wkhtmltopdf/wkhtmltoimage Authors.\n\n\n\n License LGPLv3+: GNU Lesser General Public License version 3 or later\n <http://gnu.org/licenses/lgpl.html>. This is free software: you are free to\n change and redistribute it. There is NO WARRANTY, to the extent permitted by\n law.\n\nAuthors:\n Written by Jan Habermann, Christian Sciberras and Jakob Truelsen. Patches by\n Mehdi Abbad, Lyes Amazouz, Pascal Bach, Emmanuel Bouthenot, Benoit Garret and\n Mario Silva."
|
186
197
|
assert_equal Gem::Version.new('0.11.0'), @wp.send(:parse_version, version_info_sample)
|
187
198
|
end
|
188
199
|
|
189
|
-
test
|
200
|
+
test 'should extract wkhtmltopdf version with nondigit symbols' do
|
190
201
|
version_info_sample = "Name:\n wkhtmltopdf 0.10.4b\n\nLicense:\n Copyright (C) 2008,2009 Wkhtmltopdf Authors.\n\n\n\n License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n This is free software: you are free to change and redistribute it. There is NO\n WARRANTY, to the extent permitted by law.\n\nAuthors:\n Written by Jakob Truelsen. Patches by Mrio Silva, Benoit Garret and Emmanuel\n Bouthenot.\n"
|
191
202
|
assert_equal Gem::Version.new('0.10.4b'), @wp.send(:parse_version, version_info_sample)
|
192
203
|
end
|
193
204
|
|
194
|
-
test
|
205
|
+
test 'should fallback to default version on parse error' do
|
195
206
|
assert_equal WickedPdf::DEFAULT_BINARY_VERSION, @wp.send(:parse_version, '')
|
196
207
|
end
|
197
208
|
|
198
|
-
test
|
199
|
-
|
209
|
+
test 'should set version on initialize' do
|
210
|
+
assert_not_equal @wp.send(:get_binary_version), ''
|
211
|
+
end
|
212
|
+
|
213
|
+
test 'should not use double dash options for version without dashes' do
|
214
|
+
@wp.set_binary_version_to(WickedPdf::BINARY_VERSION_WITHOUT_DASHES)
|
215
|
+
|
216
|
+
%w(toc cover).each do |name|
|
217
|
+
assert_equal @wp.get_valid_option(name), name
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
test 'should use double dash options for version with dashes' do
|
222
|
+
@wp.set_binary_version_to(Gem::Version.new('0.11.0'))
|
223
|
+
|
224
|
+
%w(toc cover).each do |name|
|
225
|
+
assert_equal @wp.get_valid_option(name), "--#{name}"
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
test '-- options should not be given after object' do
|
230
|
+
options = { :header => { :center => 3 }, :cover => 'http://example.org', :disable_javascript => true }
|
231
|
+
cover_option = @wp.get_valid_option('cover')
|
232
|
+
assert_equal @wp.get_parsed_options(options), "--disable-javascript --header-center 3 #{cover_option} http://example.org"
|
200
233
|
end
|
201
234
|
end
|
data/wicked_pdf.gemspec
CHANGED
@@ -4,25 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'wicked_pdf/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'wicked_pdf'
|
8
8
|
spec.version = WickedPdf::VERSION
|
9
|
-
spec.authors = [
|
9
|
+
spec.authors = ['Miles Z. Sterrett']
|
10
10
|
spec.email = 'miles.sterrett@gmail.com'
|
11
11
|
spec.summary = 'PDF generator (from HTML) gem for Ruby on Rails'
|
12
12
|
spec.homepage = 'https://github.com/mileszs/wicked_pdf'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
spec.date = Time.now.strftime('%Y-%m-%d')
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.
|
21
|
+
spec.add_development_dependency 'rails'
|
22
22
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
23
|
spec.add_development_dependency 'rake'
|
24
24
|
spec.add_development_dependency 'sqlite3'
|
25
25
|
spec.add_development_dependency 'mocha'
|
26
|
+
spec.add_development_dependency 'test-unit'
|
26
27
|
|
27
28
|
spec.description = <<desc
|
28
29
|
Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wicked_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Z. Sterrett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test-unit
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: |
|
84
98
|
Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML.
|
85
99
|
In other words, rather than dealing with a PDF generation DSL of some sort,
|
@@ -100,6 +114,8 @@ files:
|
|
100
114
|
- gemfiles/3.1.gemfile
|
101
115
|
- gemfiles/3.2.gemfile
|
102
116
|
- gemfiles/4.0.gemfile
|
117
|
+
- gemfiles/4.1.gemfile
|
118
|
+
- gemfiles/4.2.gemfile
|
103
119
|
- gemfiles/rails_edge.gemfile
|
104
120
|
- generators/wicked_pdf/templates/wicked_pdf.rb
|
105
121
|
- generators/wicked_pdf/wicked_pdf_generator.rb
|
@@ -112,40 +128,6 @@ files:
|
|
112
128
|
- lib/wicked_pdf/tempfile.rb
|
113
129
|
- lib/wicked_pdf/version.rb
|
114
130
|
- lib/wicked_pdf/wicked_pdf_helper.rb
|
115
|
-
- test/dummy/README.rdoc
|
116
|
-
- test/dummy/Rakefile
|
117
|
-
- test/dummy/app/assets/javascripts/application.js
|
118
|
-
- test/dummy/app/assets/stylesheets/application.css
|
119
|
-
- test/dummy/app/controllers/application_controller.rb
|
120
|
-
- test/dummy/app/helpers/application_helper.rb
|
121
|
-
- test/dummy/app/mailers/.gitkeep
|
122
|
-
- test/dummy/app/models/.gitkeep
|
123
|
-
- test/dummy/app/views/layouts/application.html.erb
|
124
|
-
- test/dummy/config.ru
|
125
|
-
- test/dummy/config/application.rb
|
126
|
-
- test/dummy/config/boot.rb
|
127
|
-
- test/dummy/config/database.yml
|
128
|
-
- test/dummy/config/environment.rb
|
129
|
-
- test/dummy/config/environments/development.rb
|
130
|
-
- test/dummy/config/environments/production.rb
|
131
|
-
- test/dummy/config/environments/test.rb
|
132
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
133
|
-
- test/dummy/config/initializers/inflections.rb
|
134
|
-
- test/dummy/config/initializers/mime_types.rb
|
135
|
-
- test/dummy/config/initializers/secret_token.rb
|
136
|
-
- test/dummy/config/initializers/session_store.rb
|
137
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
138
|
-
- test/dummy/config/locales/en.yml
|
139
|
-
- test/dummy/config/routes.rb
|
140
|
-
- test/dummy/db/test.sqlite3
|
141
|
-
- test/dummy/lib/assets/.gitkeep
|
142
|
-
- test/dummy/log/.gitkeep
|
143
|
-
- test/dummy/log/development.log
|
144
|
-
- test/dummy/public/404.html
|
145
|
-
- test/dummy/public/422.html
|
146
|
-
- test/dummy/public/500.html
|
147
|
-
- test/dummy/public/favicon.ico
|
148
|
-
- test/dummy/script/rails
|
149
131
|
- test/fixtures/document_with_long_line.html
|
150
132
|
- test/fixtures/wicked.css
|
151
133
|
- test/functional/pdf_helper_test.rb
|
@@ -174,45 +156,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
156
|
version: '0'
|
175
157
|
requirements: []
|
176
158
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.4.5
|
178
160
|
signing_key:
|
179
161
|
specification_version: 4
|
180
162
|
summary: PDF generator (from HTML) gem for Ruby on Rails
|
181
163
|
test_files:
|
182
|
-
- test/dummy/README.rdoc
|
183
|
-
- test/dummy/Rakefile
|
184
|
-
- test/dummy/app/assets/javascripts/application.js
|
185
|
-
- test/dummy/app/assets/stylesheets/application.css
|
186
|
-
- test/dummy/app/controllers/application_controller.rb
|
187
|
-
- test/dummy/app/helpers/application_helper.rb
|
188
|
-
- test/dummy/app/mailers/.gitkeep
|
189
|
-
- test/dummy/app/models/.gitkeep
|
190
|
-
- test/dummy/app/views/layouts/application.html.erb
|
191
|
-
- test/dummy/config.ru
|
192
|
-
- test/dummy/config/application.rb
|
193
|
-
- test/dummy/config/boot.rb
|
194
|
-
- test/dummy/config/database.yml
|
195
|
-
- test/dummy/config/environment.rb
|
196
|
-
- test/dummy/config/environments/development.rb
|
197
|
-
- test/dummy/config/environments/production.rb
|
198
|
-
- test/dummy/config/environments/test.rb
|
199
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
200
|
-
- test/dummy/config/initializers/inflections.rb
|
201
|
-
- test/dummy/config/initializers/mime_types.rb
|
202
|
-
- test/dummy/config/initializers/secret_token.rb
|
203
|
-
- test/dummy/config/initializers/session_store.rb
|
204
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
205
|
-
- test/dummy/config/locales/en.yml
|
206
|
-
- test/dummy/config/routes.rb
|
207
|
-
- test/dummy/db/test.sqlite3
|
208
|
-
- test/dummy/lib/assets/.gitkeep
|
209
|
-
- test/dummy/log/.gitkeep
|
210
|
-
- test/dummy/log/development.log
|
211
|
-
- test/dummy/public/404.html
|
212
|
-
- test/dummy/public/422.html
|
213
|
-
- test/dummy/public/500.html
|
214
|
-
- test/dummy/public/favicon.ico
|
215
|
-
- test/dummy/script/rails
|
216
164
|
- test/fixtures/document_with_long_line.html
|
217
165
|
- test/fixtures/wicked.css
|
218
166
|
- test/functional/pdf_helper_test.rb
|
data/test/dummy/README.rdoc
DELETED
@@ -1,261 +0,0 @@
|
|
1
|
-
== Welcome to Rails
|
2
|
-
|
3
|
-
Rails is a web-application framework that includes everything needed to create
|
4
|
-
database-backed web applications according to the Model-View-Control pattern.
|
5
|
-
|
6
|
-
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
-
templates that are primarily responsible for inserting pre-built data in between
|
8
|
-
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
-
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
-
persist themselves to a database. The controller handles the incoming requests
|
11
|
-
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
-
and directing data to the view.
|
13
|
-
|
14
|
-
In Rails, the model is handled by what's called an object-relational mapping
|
15
|
-
layer entitled Active Record. This layer allows you to present the data from
|
16
|
-
database rows as objects and embellish these data objects with business logic
|
17
|
-
methods. You can read more about Active Record in
|
18
|
-
link:files/vendor/rails/activerecord/README.html.
|
19
|
-
|
20
|
-
The controller and view are handled by the Action Pack, which handles both
|
21
|
-
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
-
are bundled in a single package due to their heavy interdependence. This is
|
23
|
-
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
-
more separate. Each of these packages can be used independently outside of
|
25
|
-
Rails. You can read more about Action Pack in
|
26
|
-
link:files/vendor/rails/actionpack/README.html.
|
27
|
-
|
28
|
-
|
29
|
-
== Getting Started
|
30
|
-
|
31
|
-
1. At the command prompt, create a new Rails application:
|
32
|
-
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
33
|
-
|
34
|
-
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
-
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
|
-
|
37
|
-
3. Go to http://localhost:3000/ and you'll see:
|
38
|
-
"Welcome aboard: You're riding Ruby on Rails!"
|
39
|
-
|
40
|
-
4. Follow the guidelines to start developing your application. You can find
|
41
|
-
the following resources handy:
|
42
|
-
|
43
|
-
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
-
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
45
|
-
|
46
|
-
|
47
|
-
== Debugging Rails
|
48
|
-
|
49
|
-
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
-
will help you debug it and get it back on the rails.
|
51
|
-
|
52
|
-
First area to check is the application log files. Have "tail -f" commands
|
53
|
-
running on the server.log and development.log. Rails will automatically display
|
54
|
-
debugging and runtime information to these files. Debugging info will also be
|
55
|
-
shown in the browser on requests from 127.0.0.1.
|
56
|
-
|
57
|
-
You can also log your own messages directly into the log file from your code
|
58
|
-
using the Ruby logger class from inside your controllers. Example:
|
59
|
-
|
60
|
-
class WeblogController < ActionController::Base
|
61
|
-
def destroy
|
62
|
-
@weblog = Weblog.find(params[:id])
|
63
|
-
@weblog.destroy
|
64
|
-
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
The result will be a message in your log file along the lines of:
|
69
|
-
|
70
|
-
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
-
|
72
|
-
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
-
|
74
|
-
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
-
several books available online as well:
|
76
|
-
|
77
|
-
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
-
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
-
|
80
|
-
These two books will bring you up to speed on the Ruby language and also on
|
81
|
-
programming in general.
|
82
|
-
|
83
|
-
|
84
|
-
== Debugger
|
85
|
-
|
86
|
-
Debugger support is available through the debugger command when you start your
|
87
|
-
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
-
execution at any point in the code, investigate and change the model, and then,
|
89
|
-
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
-
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
-
|
92
|
-
class WeblogController < ActionController::Base
|
93
|
-
def index
|
94
|
-
@posts = Post.all
|
95
|
-
debugger
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
So the controller will accept the action, run the first line, then present you
|
100
|
-
with a IRB prompt in the server window. Here you can do things like:
|
101
|
-
|
102
|
-
>> @posts.inspect
|
103
|
-
=> "[#<Post:0x14a6be8
|
104
|
-
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
-
#<Post:0x14a6620
|
106
|
-
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
-
>> @posts.first.title = "hello from a debugger"
|
108
|
-
=> "hello from a debugger"
|
109
|
-
|
110
|
-
...and even better, you can examine how your runtime objects actually work:
|
111
|
-
|
112
|
-
>> f = @posts.first
|
113
|
-
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
-
>> f.
|
115
|
-
Display all 152 possibilities? (y or n)
|
116
|
-
|
117
|
-
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
-
|
119
|
-
|
120
|
-
== Console
|
121
|
-
|
122
|
-
The console is a Ruby shell, which allows you to interact with your
|
123
|
-
application's domain model. Here you'll have all parts of the application
|
124
|
-
configured, just like it is when the application is running. You can inspect
|
125
|
-
domain models, change values, and save to the database. Starting the script
|
126
|
-
without arguments will launch it in the development environment.
|
127
|
-
|
128
|
-
To start the console, run <tt>rails console</tt> from the application
|
129
|
-
directory.
|
130
|
-
|
131
|
-
Options:
|
132
|
-
|
133
|
-
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
-
made to the database.
|
135
|
-
* Passing an environment name as an argument will load the corresponding
|
136
|
-
environment. Example: <tt>rails console production</tt>.
|
137
|
-
|
138
|
-
To reload your controllers and models after launching the console run
|
139
|
-
<tt>reload!</tt>
|
140
|
-
|
141
|
-
More information about irb can be found at:
|
142
|
-
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
-
|
144
|
-
|
145
|
-
== dbconsole
|
146
|
-
|
147
|
-
You can go to the command line of your database directly through <tt>rails
|
148
|
-
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
-
defined in database.yml. Starting the script without arguments will connect you
|
150
|
-
to the development database. Passing an argument will connect you to a different
|
151
|
-
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
-
PostgreSQL and SQLite 3.
|
153
|
-
|
154
|
-
== Description of Contents
|
155
|
-
|
156
|
-
The default directory structure of a generated Ruby on Rails application:
|
157
|
-
|
158
|
-
|-- app
|
159
|
-
| |-- assets
|
160
|
-
| |-- images
|
161
|
-
| |-- javascripts
|
162
|
-
| `-- stylesheets
|
163
|
-
| |-- controllers
|
164
|
-
| |-- helpers
|
165
|
-
| |-- mailers
|
166
|
-
| |-- models
|
167
|
-
| `-- views
|
168
|
-
| `-- layouts
|
169
|
-
|-- config
|
170
|
-
| |-- environments
|
171
|
-
| |-- initializers
|
172
|
-
| `-- locales
|
173
|
-
|-- db
|
174
|
-
|-- doc
|
175
|
-
|-- lib
|
176
|
-
| `-- tasks
|
177
|
-
|-- log
|
178
|
-
|-- public
|
179
|
-
|-- script
|
180
|
-
|-- test
|
181
|
-
| |-- fixtures
|
182
|
-
| |-- functional
|
183
|
-
| |-- integration
|
184
|
-
| |-- performance
|
185
|
-
| `-- unit
|
186
|
-
|-- tmp
|
187
|
-
| |-- cache
|
188
|
-
| |-- pids
|
189
|
-
| |-- sessions
|
190
|
-
| `-- sockets
|
191
|
-
`-- vendor
|
192
|
-
|-- assets
|
193
|
-
`-- stylesheets
|
194
|
-
`-- plugins
|
195
|
-
|
196
|
-
app
|
197
|
-
Holds all the code that's specific to this particular application.
|
198
|
-
|
199
|
-
app/assets
|
200
|
-
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
-
|
202
|
-
app/controllers
|
203
|
-
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
-
automated URL mapping. All controllers should descend from
|
205
|
-
ApplicationController which itself descends from ActionController::Base.
|
206
|
-
|
207
|
-
app/models
|
208
|
-
Holds models that should be named like post.rb. Models descend from
|
209
|
-
ActiveRecord::Base by default.
|
210
|
-
|
211
|
-
app/views
|
212
|
-
Holds the template files for the view that should be named like
|
213
|
-
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
-
eRuby syntax by default.
|
215
|
-
|
216
|
-
app/views/layouts
|
217
|
-
Holds the template files for layouts to be used with views. This models the
|
218
|
-
common header/footer method of wrapping views. In your views, define a layout
|
219
|
-
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
-
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
-
layout.
|
222
|
-
|
223
|
-
app/helpers
|
224
|
-
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
-
generated for you automatically when using generators for controllers.
|
226
|
-
Helpers can be used to wrap functionality for your views into methods.
|
227
|
-
|
228
|
-
config
|
229
|
-
Configuration files for the Rails environment, the routing map, the database,
|
230
|
-
and other dependencies.
|
231
|
-
|
232
|
-
db
|
233
|
-
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
-
sequence of Migrations for your schema.
|
235
|
-
|
236
|
-
doc
|
237
|
-
This directory is where your application documentation will be stored when
|
238
|
-
generated using <tt>rake doc:app</tt>
|
239
|
-
|
240
|
-
lib
|
241
|
-
Application specific libraries. Basically, any kind of custom code that
|
242
|
-
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
-
the load path.
|
244
|
-
|
245
|
-
public
|
246
|
-
The directory available for the web server. Also contains the dispatchers and the
|
247
|
-
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
-
server.
|
249
|
-
|
250
|
-
script
|
251
|
-
Helper scripts for automation and generation.
|
252
|
-
|
253
|
-
test
|
254
|
-
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
-
command, template test files will be generated for you and placed in this
|
256
|
-
directory.
|
257
|
-
|
258
|
-
vendor
|
259
|
-
External libraries that the application depends on. Also includes the plugins
|
260
|
-
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
-
vendor/rails/. This directory is in the load path.
|