adzap-wicked_pdf 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.github/issue_template.md +15 -0
  3. data/.gitignore +21 -0
  4. data/.rubocop.yml +22 -0
  5. data/.rubocop_todo.yml +63 -0
  6. data/.travis.yml +30 -0
  7. data/CHANGELOG.md +135 -0
  8. data/Gemfile +3 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +446 -0
  11. data/Rakefile +31 -0
  12. data/gemfiles/4.2.gemfile +6 -0
  13. data/gemfiles/5.0.gemfile +6 -0
  14. data/gemfiles/5.1.gemfile +6 -0
  15. data/gemfiles/5.2.gemfile +9 -0
  16. data/gemfiles/rails_edge.gemfile +9 -0
  17. data/generators/wicked_pdf/templates/wicked_pdf.rb +21 -0
  18. data/generators/wicked_pdf/wicked_pdf_generator.rb +7 -0
  19. data/init.rb +2 -0
  20. data/lib/generators/wicked_pdf_generator.rb +6 -0
  21. data/lib/wicked_pdf.rb +29 -0
  22. data/lib/wicked_pdf/asset_helper.rb +141 -0
  23. data/lib/wicked_pdf/binary.rb +56 -0
  24. data/lib/wicked_pdf/command.rb +52 -0
  25. data/lib/wicked_pdf/document.rb +47 -0
  26. data/lib/wicked_pdf/middleware.rb +101 -0
  27. data/lib/wicked_pdf/option_parser.rb +220 -0
  28. data/lib/wicked_pdf/pdf_helper.rb +17 -0
  29. data/lib/wicked_pdf/progress.rb +33 -0
  30. data/lib/wicked_pdf/railtie.rb +19 -0
  31. data/lib/wicked_pdf/renderer.rb +121 -0
  32. data/lib/wicked_pdf/tempfile.rb +13 -0
  33. data/lib/wicked_pdf/version.rb +3 -0
  34. data/test/dummy/app/assets/javascripts/application.js +16 -0
  35. data/test/dummy/app/assets/javascripts/wicked.js +1 -0
  36. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  37. data/test/dummy/app/assets/stylesheets/wicked.css +1 -0
  38. data/test/dummy/config/database.yml +3 -0
  39. data/test/dummy/config/routes.rb +5 -0
  40. data/test/dummy/log/.gitignore +1 -0
  41. data/test/dummy/public/favicon.ico +0 -0
  42. data/test/fixtures/database.yml +4 -0
  43. data/test/fixtures/document_with_long_line.html +16 -0
  44. data/test/fixtures/wicked.css +1 -0
  45. data/test/fixtures/wicked.js +1 -0
  46. data/test/functional/pdf_helper_test.rb +61 -0
  47. data/test/functional/wicked_pdf_asset_helper_test.rb +118 -0
  48. data/test/test_helper.rb +33 -0
  49. data/test/unit/wicked_pdf_binary_test.rb +52 -0
  50. data/test/unit/wicked_pdf_command_test.rb +4 -0
  51. data/test/unit/wicked_pdf_document_test.rb +60 -0
  52. data/test/unit/wicked_pdf_option_parser_test.rb +128 -0
  53. data/test/unit/wicked_pdf_renderer_test.rb +43 -0
  54. data/test/unit/wicked_pdf_test.rb +8 -0
  55. data/test/unit/wkhtmltopdf_location_test.rb +50 -0
  56. data/wicked_pdf.gemspec +38 -0
  57. metadata +249 -0
@@ -0,0 +1,43 @@
1
+ require 'test_helper'
2
+ require 'wicked_pdf/renderer'
3
+
4
+ class WickedPdfRendererTest < ActiveSupport::TestCase
5
+ def setup
6
+ @controller = stub(
7
+ 'Controller',
8
+ :send_data => 'SEND',
9
+ :render_to_string => 'contents',
10
+ :controller_path => 'foo',
11
+ :action_name => 'create'
12
+ )
13
+
14
+ WickedPdf::Document.expects(:new).returns(mock(:pdf_from_string => ''))
15
+
16
+ @renderer = WickedPdf::Renderer.new(@controller)
17
+ end
18
+
19
+ test 'should prerender header and footer :template options' do
20
+ @controller.expects(:render_to_string).with(has_entry(:template => 'header.html.erb'))
21
+ @controller.expects(:render_to_string).with(has_entry(:template => 'footer.html.erb'))
22
+
23
+ @renderer.render(
24
+ :pdf => 'template',
25
+ :header => { :html => { :template => 'header.html.erb' } },
26
+ :footer => { :html => { :template => 'footer.html.erb' } }
27
+ )
28
+ end
29
+
30
+ test 'should prerender cleanup temfiles' do
31
+ header_temp = mock('Header tempfile', :path => 'header', :close! => nil, :write => nil, :flush => nil)
32
+ footer_temp = mock('Footer tempfile', :path => 'footer', :close! => nil, :write => nil, :flush => nil)
33
+
34
+ WickedPdf::Tempfile.expects(:new).with('wicked_header_pdf.html').returns(header_temp)
35
+ WickedPdf::Tempfile.expects(:new).with('wicked_footer_pdf.html').returns(footer_temp)
36
+
37
+ @renderer.render(
38
+ :pdf => 'template',
39
+ :header => { :html => { :template => 'header.html.erb' } },
40
+ :footer => { :html => { :template => 'footer.html.erb' } }
41
+ )
42
+ end
43
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ module WickedPdf
4
+ attr_accessor :binary
5
+ end
6
+
7
+ class WickedPdfTest < ActiveSupport::TestCase
8
+ end
@@ -0,0 +1,50 @@
1
+
2
+
3
+ class WkhtmltopdfLocationTest < ActiveSupport::TestCase
4
+ setup do
5
+ @saved_config = WickedPdf.config
6
+ WickedPdf.config = {}
7
+ end
8
+
9
+ teardown do
10
+ WickedPdf.config = @saved_config
11
+ end
12
+
13
+ test 'should correctly locate wkhtmltopdf without bundler' do
14
+ bundler_module = Bundler
15
+ Object.send(:remove_const, :Bundler)
16
+
17
+ assert_nothing_raised do
18
+ WickedPdf.new
19
+ end
20
+
21
+ Object.const_set(:Bundler, bundler_module)
22
+ end
23
+
24
+ test 'should correctly locate wkhtmltopdf with bundler' do
25
+ assert_nothing_raised do
26
+ WickedPdf.new
27
+ end
28
+ end
29
+
30
+ class LocationNonWritableTest < ActiveSupport::TestCase
31
+ setup do
32
+ @saved_config = WickedPdf.config
33
+ WickedPdf.config = {}
34
+
35
+ @old_home = ENV['HOME']
36
+ ENV['HOME'] = '/not/a/writable/directory'
37
+ end
38
+
39
+ teardown do
40
+ WickedPdf.config = @saved_config
41
+ ENV['HOME'] = @old_home
42
+ end
43
+
44
+ test 'should correctly locate wkhtmltopdf with bundler while HOME is set to a non-writable directory' do
45
+ assert_nothing_raised do
46
+ WickedPdf.new
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wicked_pdf/version'
5
+ require 'English'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'adzap-wicked_pdf'
9
+ spec.version = WickedPdf::VERSION
10
+ spec.authors = ['Miles Z. Sterrett', 'David Jones', 'Adam Meehan']
11
+ spec.email = ['miles.sterrett@gmail.com', 'unixmonkey1@gmail.com', 'adam.meehan@gmail.com']
12
+ spec.summary = 'PDF generator (from HTML) gem for Ruby on Rails'
13
+ spec.homepage = 'https://github.com/adzap/wicked_pdf'
14
+ spec.license = 'MIT'
15
+ spec.date = Time.now.strftime('%Y-%m-%d')
16
+ spec.description = <<DESC.gsub(/^\s+/, '')
17
+ Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML.
18
+ In other words, rather than dealing with a PDF generation DSL of some sort,
19
+ you simply write an HTML view as you would normally, and let Wicked take care of the hard stuff.
20
+ DESC
21
+
22
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.requirements << 'wkhtmltopdf'
28
+
29
+ spec.add_dependency 'activesupport'
30
+
31
+ spec.add_development_dependency 'rails'
32
+ spec.add_development_dependency 'combustion'
33
+ spec.add_development_dependency 'bundler', '>= 1.3.0', '< 3'
34
+ spec.add_development_dependency 'rake'
35
+ spec.add_development_dependency 'rubocop', '~> 0.50.0'
36
+ spec.add_development_dependency 'sqlite3', '~> 1.3.6'
37
+ spec.add_development_dependency 'mocha', '= 1.3'
38
+ end
metadata ADDED
@@ -0,0 +1,249 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adzap-wicked_pdf
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0.beta1
5
+ platform: ruby
6
+ authors:
7
+ - Miles Z. Sterrett
8
+ - David Jones
9
+ - Adam Meehan
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2019-03-30 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rails
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: combustion
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: bundler
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.3.0
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '3'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 1.3.0
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '3'
77
+ - !ruby/object:Gem::Dependency
78
+ name: rake
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ - !ruby/object:Gem::Dependency
92
+ name: rubocop
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 0.50.0
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 0.50.0
105
+ - !ruby/object:Gem::Dependency
106
+ name: sqlite3
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 1.3.6
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: 1.3.6
119
+ - !ruby/object:Gem::Dependency
120
+ name: mocha
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '='
124
+ - !ruby/object:Gem::Version
125
+ version: '1.3'
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '='
131
+ - !ruby/object:Gem::Version
132
+ version: '1.3'
133
+ description: |
134
+ Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML.
135
+ In other words, rather than dealing with a PDF generation DSL of some sort,
136
+ you simply write an HTML view as you would normally, and let Wicked take care of the hard stuff.
137
+ email:
138
+ - miles.sterrett@gmail.com
139
+ - unixmonkey1@gmail.com
140
+ - adam.meehan@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - ".github/issue_template.md"
146
+ - ".gitignore"
147
+ - ".rubocop.yml"
148
+ - ".rubocop_todo.yml"
149
+ - ".travis.yml"
150
+ - CHANGELOG.md
151
+ - Gemfile
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - gemfiles/4.2.gemfile
156
+ - gemfiles/5.0.gemfile
157
+ - gemfiles/5.1.gemfile
158
+ - gemfiles/5.2.gemfile
159
+ - gemfiles/rails_edge.gemfile
160
+ - generators/wicked_pdf/templates/wicked_pdf.rb
161
+ - generators/wicked_pdf/wicked_pdf_generator.rb
162
+ - init.rb
163
+ - lib/generators/wicked_pdf_generator.rb
164
+ - lib/wicked_pdf.rb
165
+ - lib/wicked_pdf/asset_helper.rb
166
+ - lib/wicked_pdf/binary.rb
167
+ - lib/wicked_pdf/command.rb
168
+ - lib/wicked_pdf/document.rb
169
+ - lib/wicked_pdf/middleware.rb
170
+ - lib/wicked_pdf/option_parser.rb
171
+ - lib/wicked_pdf/pdf_helper.rb
172
+ - lib/wicked_pdf/progress.rb
173
+ - lib/wicked_pdf/railtie.rb
174
+ - lib/wicked_pdf/renderer.rb
175
+ - lib/wicked_pdf/tempfile.rb
176
+ - lib/wicked_pdf/version.rb
177
+ - test/dummy/app/assets/javascripts/application.js
178
+ - test/dummy/app/assets/javascripts/wicked.js
179
+ - test/dummy/app/assets/stylesheets/application.css
180
+ - test/dummy/app/assets/stylesheets/wicked.css
181
+ - test/dummy/config/database.yml
182
+ - test/dummy/config/routes.rb
183
+ - test/dummy/db/schema.rb
184
+ - test/dummy/log/.gitignore
185
+ - test/dummy/public/favicon.ico
186
+ - test/fixtures/database.yml
187
+ - test/fixtures/document_with_long_line.html
188
+ - test/fixtures/wicked.css
189
+ - test/fixtures/wicked.js
190
+ - test/functional/pdf_helper_test.rb
191
+ - test/functional/wicked_pdf_asset_helper_test.rb
192
+ - test/test_helper.rb
193
+ - test/unit/wicked_pdf_binary_test.rb
194
+ - test/unit/wicked_pdf_command_test.rb
195
+ - test/unit/wicked_pdf_document_test.rb
196
+ - test/unit/wicked_pdf_option_parser_test.rb
197
+ - test/unit/wicked_pdf_renderer_test.rb
198
+ - test/unit/wicked_pdf_test.rb
199
+ - test/unit/wkhtmltopdf_location_test.rb
200
+ - wicked_pdf.gemspec
201
+ homepage: https://github.com/adzap/wicked_pdf
202
+ licenses:
203
+ - MIT
204
+ metadata: {}
205
+ post_install_message:
206
+ rdoc_options: []
207
+ require_paths:
208
+ - lib
209
+ required_ruby_version: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ required_rubygems_version: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">"
217
+ - !ruby/object:Gem::Version
218
+ version: 1.3.1
219
+ requirements:
220
+ - wkhtmltopdf
221
+ rubyforge_project:
222
+ rubygems_version: 2.7.6.2
223
+ signing_key:
224
+ specification_version: 4
225
+ summary: PDF generator (from HTML) gem for Ruby on Rails
226
+ test_files:
227
+ - test/dummy/app/assets/javascripts/application.js
228
+ - test/dummy/app/assets/javascripts/wicked.js
229
+ - test/dummy/app/assets/stylesheets/application.css
230
+ - test/dummy/app/assets/stylesheets/wicked.css
231
+ - test/dummy/config/database.yml
232
+ - test/dummy/config/routes.rb
233
+ - test/dummy/db/schema.rb
234
+ - test/dummy/log/.gitignore
235
+ - test/dummy/public/favicon.ico
236
+ - test/fixtures/database.yml
237
+ - test/fixtures/document_with_long_line.html
238
+ - test/fixtures/wicked.css
239
+ - test/fixtures/wicked.js
240
+ - test/functional/pdf_helper_test.rb
241
+ - test/functional/wicked_pdf_asset_helper_test.rb
242
+ - test/test_helper.rb
243
+ - test/unit/wicked_pdf_binary_test.rb
244
+ - test/unit/wicked_pdf_command_test.rb
245
+ - test/unit/wicked_pdf_document_test.rb
246
+ - test/unit/wicked_pdf_option_parser_test.rb
247
+ - test/unit/wicked_pdf_renderer_test.rb
248
+ - test/unit/wicked_pdf_test.rb
249
+ - test/unit/wkhtmltopdf_location_test.rb