wicked_pdf 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50ba6bd10f9e6f6a29b3db9d8b6df69bbcea50b76aa3c663f44a42dc0475d60f
4
- data.tar.gz: 68639e18162e3d3af6c825a9d72fc35af3f32e3c6e29dedd879be43b40db3d32
3
+ metadata.gz: db4dbc2079a0b29bddf81631c25ff650634c9d0c8eba113e3e221be3ab07a475
4
+ data.tar.gz: c585d8856402144601bbdfe0da056702ba2d501b9239a6339836c9389630263e
5
5
  SHA512:
6
- metadata.gz: d3390768c498abe569a314347239660b3b2e82bae7a28498d0da98085883da680f33fc8ffa01140775cd70f4c0fde1683bbdf1a7bfceec7ae3b2ec63c39db263
7
- data.tar.gz: bfa9bfceba95a83d81932729d0cf59db57339b01844c1dfcb94ad244b1b1f8f9e78c279b6811bdb14e9b54d41b1712f61b630c0f60b48d84086326f3ef30c4e8
6
+ metadata.gz: 6a23f141de26136b65e399a1a2a7281fddc9790ebaeecefdee406372a7859c3e87ba247775ef298a355b48e0cdf9ae4387ef0a8d453764fd0ffe65e2665fa79b
7
+ data.tar.gz: b16b6ff02dc084f55640c91552300d22afe5b73550feb42ecc036e65c896033fb95969ca4f3c276613aa360fb6dedc5129d0802558492277f7666ba8cd540b74
@@ -20,7 +20,7 @@ Metrics/ClassLength:
20
20
  Max: 300
21
21
 
22
22
  Metrics/ModuleLength:
23
- Max: 120
23
+ Max: 160
24
24
 
25
25
  # Offense count: 5
26
26
  Metrics/CyclomaticComplexity:
@@ -44,6 +44,10 @@ matrix:
44
44
  - gem install bundler -v '< 2'
45
45
  - rvm: 2.4
46
46
  gemfile: gemfiles/5.1.gemfile
47
+ before_install:
48
+ - "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
49
+ - rvm @global do gem uninstall bundler -a -x -I || true
50
+ - gem install bundler -v '< 2'
47
51
  - rvm: 2.5
48
52
  gemfile: gemfiles/5.2.gemfile
49
53
  - rvm: 2.5
@@ -2,22 +2,34 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [master branch] - Unreleased
6
+ ### Breaking Changes
7
+ - None
8
+ ### New Features
9
+ - None
10
+ ### Fixes
11
+ - None
12
+
13
+ ## [1.3.0] - 2019-05-20
14
+ ### New Features
15
+ - [Add support for Webpacker provided bundles](https://github.com/mileszs/wicked_pdf/pull/739)
16
+
5
17
  ## [1.2.2] - 2019-04-13
6
18
  ### Fixes
7
19
  - [Fix issue loading Pty on Windows](https://github.com/mileszs/wicked_pdf/pull/820)
8
20
  - [Fix conflict with remotipart causing SystemStackError](https://github.com/mileszs/wicked_pdf/pull/821)
9
21
 
10
22
  ## [1.2.1] - 2019-03-16
11
- ### Changed
23
+ ### Fixes
12
24
  - [Fix `SystemStackError` in some setups](https://github.com/mileszs/wicked_pdf/pull/813)
13
25
 
14
26
  ## [1.2.0] - 2019-03-16
15
- ### Added
27
+ ### New Features
16
28
  - [Add `raise_on_all_errors: true` option to raise on any error that prints to STDOUT during PDF generation](https://github.com/mileszs/wicked_pdf/pull/751)
17
29
  - [Add ability to use the `assigns` option to `render` to assign instance variables to a PDF template](https://github.com/mileszs/wicked_pdf/pull/801)
18
30
  - [Add ability to track console progress](https://github.com/mileszs/wicked_pdf/pull/804) with `progress: -> (output) { puts output }`. This is useful to add reporting hooks to show your frontend what page number is being generated.
19
31
 
20
- ### Changed
32
+ ### Fixes
21
33
  - [Fix conflict with other gems that hook into `render`](https://github.com/mileszs/wicked_pdf/pull/574) and avoid using `alias_method_chain` where possible
22
34
  - [Fix issue using the shell to locate `wkhtmltopdf` in a Bundler environment](https://github.com/mileszs/wicked_pdf/pull/728)
23
35
  - [Fix `wkhtmltopdf` path detection when HOME environment variable is unset](https://github.com/mileszs/wicked_pdf/pull/568)
@@ -46,71 +58,61 @@ This project adheres to [Semantic Versioning](http://semver.org/).
46
58
  - Updates to Travis CI pipeline to support newer versions of Ruby & Rails
47
59
 
48
60
  ## [1.1.0] - 2016-08-30
49
- ### Added
61
+ ### New Features
50
62
  - Support Rails 5.x and Sprockets 3.x
51
63
  - Support `window_status: 'somestring'` option, to instruct wkhtmltopdf to wait until the browser `window.status` is equal to the supplied string. This can be useful to force rendering to wait [as explained quite well here](https://spin.atomicobject.com/2015/08/29/ember-app-done-loading/)
52
64
  - Support `no_stop_slow_scripts: true` to let slow running scripts delay rendering
65
+ - [Changes to asset finding to support Rails 5](https://github.com/mileszs/wicked_pdf/pull/561)
53
66
 
54
- ### Changed
67
+ ### Fixes
55
68
  - [Improved error handling](https://github.com/mileszs/wicked_pdf/pull/543)
56
69
  - [Namespace helper classes under WickedPdf namespace](https://github.com/mileszs/wicked_pdf/pull/538)
57
- - [Changes to asset finding to support Rails 5](https://github.com/mileszs/wicked_pdf/pull/561)
58
70
 
59
71
  ## [1.0.6] - 2016-04-04
60
- ### Changed
72
+ ### Fixes
61
73
  - Revert shellescaping of options. The fix was causing more issues than it solved (like "[page] of [topage]" being escaped, and thus not parsed by `wkhtmltopdf`). See #514 for details.
62
74
 
63
75
  ## [1.0.5] - 2016-03-28
64
- ### Changed
76
+ ### Fixes
65
77
  - Numerous RuboCop style violation fixes, spelling errors, and test-setup issues from [indyrb.org](http://indyrb.org/) hack night. Thank you all for your contributions!
66
-
67
- ### Fixed
68
78
  - Shellescape options. A stray quote in `header` or `footer` would cause PDF to fail to generate, and this should close down many potential attack vectors if you allow user-supplied values to be passed into `wicked_pdf` render options.
69
79
 
70
80
  ## [1.0.4] - 2016-01-26
71
- ### Changed
81
+ ### Fixes
72
82
  - Check that logger responds to info before calling it. It was possible to have a `logger` method defined as a controller helper that would override `Rails.logger`.
73
-
74
- ### Fixed
75
83
  - [Issue with Sprockets 3.0](https://github.com/mileszs/wicked_pdf/issues/476) where an asset referenced in a stylesheet not existing would raise an exception `read_asset` on nil.
76
84
 
77
85
  ## [1.0.3] - 2015-12-02
78
- ### Changed
86
+ ### Fixes
79
87
  - Revert default DPI. Some installs of `wkhtmltopdf` would experience major slowdowns or crashes with it set to 72. It is suggested that a DPI of 75 may be better, but I'm holding off on making it a default without more information.
80
88
 
81
89
  ## [1.0.2] - 2015-11-30
82
- ### Changed
90
+ ### Fixes
83
91
  - The default dpi is now 72. Previously the default would be whatever your `wkhtmltopdf` version specified as the default. This change [speeds up generation of documents that contain `border-radius` dramatically](https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1510)
84
92
 
85
93
  ## [1.0.1] - 2015-11-19
86
- ### Changed
94
+ ### Fixes
87
95
  - Made minor RuboCop style tweaks.
88
-
89
- ### Added
90
96
  - Added default [RuboCop](https://github.com/bbatsov/rubocop) config and run after test suite.
91
-
92
- ### Fixed
93
97
  - Issue with `nil.basename` from asset helpers.
94
98
 
95
99
  ## [1.0.0] - 2015-11-03
96
- ### Changed
100
+ ### Breaking Changes
97
101
  - Accepted that `WickedPDF` cannot guarantee backwards compatibility with older versions of `wkthmltopdf`, and decided to publish a new version with the MAJOR number incremented, signaling that this may have breaking changes for some people, but providing a path forward for progress. This release number also signals that this is a mature (and relatively stable) project, and should be deemed ready for production (since it has been used in production since ~2009, and downloaded over a *million* times on [RubyGems.org](https://rubygems.org/gems/wicked_pdf)).
98
102
  - Stopped attempting to track with version number of `wkhtmltopdf` binary releases (`wkhtmltopdf` v9.x == `WickedPDF` v9.x)
99
103
  - Adopted [Semantic Versioning](http://semver.org/) for release numbering
100
104
  - Added a CHANGELOG (based on [keepachangelog.com](http://keepachangelog.com/))
101
105
  - Misc code tweaks as suggested by [RuboCop](https://github.com/bbatsov/rubocop)
102
106
 
103
- ### Added
107
+ ### New Features
104
108
  - Check version of `wkhtmltopdf` before deciding to pass arguments with or without dashes
105
109
  - New arguments and options for the table of contents supported in newer versions of wkhtmltopf: `text_size_shrink`, `level_indentation`, `disable_dotted_lines`, `disable_toc_links`, `xsl_style_sheet`
106
110
  - Merge in global options to `pdf_from_html_file` and `pdf_from_string`
107
111
  - Add ability to generate pdf from a web resource: `pdf_from_url(url)`
112
+ - Removed explicit dependency on [Rails](https://github.com/rails/rails), since parts of this library may be used without it.
108
113
 
109
- ### Removed
110
- - Explicit dependency on [Rails](https://github.com/rails/rails), since parts of this library may be used without it.
114
+ ### Fixes
111
115
  - Comment out the `:exe_path` option in the generated initalizer by default (since many systems won't have `wkthmltopdf` installed in that specific location)
112
-
113
- ### Fixed
114
116
  - Issues with `file://` paths on Windows-based systems
115
117
  - Issues with parsed options/argument ordering on versions of `wkthmltopdf` > 0.9
116
118
  - Issues with middleware headers when running Rails app mounted in a subdirectory
@@ -124,6 +126,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
124
126
 
125
127
  # Compare Releases
126
128
  - [1.2.2...HEAD](https://github.com/mileszs/wicked_pdf/compare/1.2.2...HEAD)
129
+ - [1.2.2...1.3.0](https://github.com/mileszs/wicked_pdf/compare/1.2.2...1.3.0)
127
130
  - [1.2.1...1.2.2](https://github.com/mileszs/wicked_pdf/compare/1.2.1...1.2.2)
128
131
  - [1.2.0...1.2.1](https://github.com/mileszs/wicked_pdf/compare/1.1.0...1.2.0)
129
132
  - [1.1.0...1.2.0](https://github.com/mileszs/wicked_pdf/compare/1.1.0...1.2.0)
data/README.md CHANGED
@@ -85,7 +85,6 @@ The wkhtmltopdf binary is run outside of your Rails application; therefore, your
85
85
  </body>
86
86
  </html>
87
87
  ```
88
-
89
88
  Using wicked_pdf_helpers with asset pipeline raises `Asset names passed to helpers should not include the "/assets/" prefix.` error. To work around this, you can use `wicked_pdf_asset_base64` with the normal Rails helpers, but be aware that this will base64 encode your content and inline it in the page. This is very quick for small assets, but large ones can take a long time.
90
89
 
91
90
  ```html
@@ -108,6 +107,13 @@ Using wicked_pdf_helpers with asset pipeline raises `Asset names passed to helpe
108
107
  </html>
109
108
  ```
110
109
 
110
+ #### Webpacker usage
111
+
112
+ wicked_pdf supports webpack stylesheets and javascript assets.
113
+
114
+ Use `wicked_pdf_stylesheet_pack_tag` for stylesheets
115
+ Use `wicked_pdf_javascript_pack_tag` for javascripts
116
+
111
117
  #### Asset pipeline usage
112
118
 
113
119
  It is best to precompile assets used in PDF views. This will help avoid issues when it comes to deploying, as Rails serves asset files differently between development and production (`config.assets.compile = false`), which can make it look like your PDFs work in development, but fail to load assets in production.
@@ -126,6 +132,9 @@ In this case, you can use that standard Rails helpers and point to the current C
126
132
  ```
127
133
 
128
134
  ### Advanced Usage with all available options
135
+
136
+ _NOTE: Certain options are only supported in specific versions of wkhtmltopdf._
137
+
129
138
  ```ruby
130
139
  class ThingsController < ApplicationController
131
140
  def show
@@ -1,3 +1,3 @@
1
1
  class WickedPdf
2
- VERSION = '1.2.2'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -1,4 +1,6 @@
1
1
  require 'open-uri'
2
+ # If webpacker is used, need to check for version
3
+ require 'webpacker/version' if defined?(Webpacker)
2
4
 
3
5
  class WickedPdf
4
6
  module WickedPdfHelper
@@ -27,6 +29,32 @@ class WickedPdf
27
29
  end.html_safe
28
30
  end
29
31
 
32
+ def wicked_pdf_stylesheet_pack_tag(*sources)
33
+ return unless defined?(Webpacker)
34
+ if running_in_development?
35
+ stylesheet_pack_tag(*sources)
36
+ else
37
+ css_text = sources.collect do |source|
38
+ source = WickedPdfHelper.add_extension(source, 'css')
39
+ wicked_pdf_stylesheet_link_tag(webpacker_source_url(source))
40
+ end.join("\n")
41
+ css_text.respond_to?(:html_safe) ? css_text.html_safe : css_text
42
+ end
43
+ end
44
+
45
+ def wicked_pdf_javascript_pack_tag(*sources)
46
+ return unless defined?(Webpacker)
47
+
48
+ if running_in_development?
49
+ javascript_pack_tag(*sources)
50
+ else
51
+ sources.collect do |source|
52
+ source = WickedPdfHelper.add_extension(source, 'js')
53
+ "<script type='text/javascript'>#{read_asset(webpacker_source_url(source))}</script>"
54
+ end.join("\n").html_safe
55
+ end
56
+ end
57
+
30
58
  def wicked_pdf_image_tag(img, options = {})
31
59
  image_tag wicked_pdf_asset_path(img), options
32
60
  end
@@ -130,6 +158,28 @@ class WickedPdf
130
158
  rescue Zlib::GzipFile::Error
131
159
  nil
132
160
  end
161
+
162
+ def webpacker_source_url(source)
163
+ return unless defined?(Webpacker) && defined?(Webpacker::VERSION)
164
+ # In Webpacker 3.2.0 asset_pack_url is introduced
165
+ if Webpacker::VERSION >= '3.2.0'
166
+ asset_pack_url(source)
167
+ else
168
+ source_path = asset_pack_path(source)
169
+ # Remove last slash from root path
170
+ root_url[0...-1] + source_path
171
+ end
172
+ end
173
+
174
+ def running_in_development?
175
+ return unless defined?(Webpacker)
176
+ # :dev_server method was added in webpacker 3.0.0
177
+ if Webpacker.respond_to?(:dev_server)
178
+ Webpacker.dev_server.running?
179
+ else
180
+ Rails.env.development? || Rails.env.test?
181
+ end
182
+ end
133
183
  end
134
184
  end
135
185
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wicked_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Z. Sterrett
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-03 00:00:00.000000000 Z
12
+ date: 2019-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  requirements:
201
201
  - wkhtmltopdf
202
- rubygems_version: 3.0.1
202
+ rubygems_version: 3.0.3
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: PDF generator (from HTML) gem for Ruby on Rails