pdfkit 0.8.5 → 0.8.6

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 709b9d124eeb6e972d0095d078ce39be54ef3335eb57b4042cc5499a423ac3ba
4
- data.tar.gz: 7de22b6ec750dc0f4aebe1f0c58b871cba29253a455310b9cc00b5915627ccce
3
+ metadata.gz: 2c5255fcf07a7c382fc239a68a805d8a2950df682166a5913ca60c34bac9fe44
4
+ data.tar.gz: 43555629ecdba193f051ab0ea10f025f7917acf558af58ea30ae69cac6f6b210
5
5
  SHA512:
6
- metadata.gz: c76d4d622db3fa8250aa396d5782e6b04d3569da187a740fd600b757956226514c01ccee0ab4e9ffc0d1e9ee828a50efb37d92109aa7a461b0ff0de2e2cdf0e6
7
- data.tar.gz: a09547f979b4742c9e4d2ddf898fea4ead8c86906ed89c100cbd476c1f022db46ecb3e0d7c6fa614c3f4ea5173699678d5621230706ad0ea3527ef3968b5a989
6
+ metadata.gz: eb5f31eb9f0f84eb8d9b626c5c804f4f58ab0230b410740cad8810c4b0f673608ebb4874a0aa5f3fffade6c78b551e2a3fa339075fe0aad0f446117eb4af23bb
7
+ data.tar.gz: a9e6dd403b4ec4795e9af96fd1d2e896d1d1cb497adaca1fd96044504877bf264dfd5cf3a161012430a5930aaf4921271b1ad4ee294ec1e357f3e39366ec6be3
@@ -12,8 +12,8 @@ jobs:
12
12
  steps:
13
13
  # Drafts your next Release notes as Pull Requests are merged into "master"
14
14
  - uses: release-drafter/release-drafter@v5
15
- with:
15
+ # with:
16
16
  # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
17
17
  # config-name: my-config.yml
18
18
  env:
19
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,59 @@
1
+ name: Test workflow
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os: [ubuntu-latest]
11
+ ruby:
12
+ - '2.5'
13
+ - '2.6'
14
+ - '2.7'
15
+ - '3.0'
16
+ - '3.1'
17
+ rails:
18
+ - '~> 4.1'
19
+ - '~> 5.2'
20
+ - '~> 6.0.0'
21
+ - '~> 6.1'
22
+ - '~> 7.0.0'
23
+ exclude:
24
+ - ruby: '2.5'
25
+ rails: '~> 7.0.0'
26
+ - ruby: '2.6'
27
+ rails: '~> 7.0.0'
28
+ - ruby: '2.7'
29
+ rails: '~> 4.1'
30
+ - ruby: '3.0'
31
+ rails: '~> 4.1'
32
+ - ruby: '3.0'
33
+ rails: '~> 5.2'
34
+ - ruby: '3.1'
35
+ rails: '~> 4.1'
36
+ - ruby: '3.1'
37
+ rails: '~> 5.2'
38
+ - ruby: '3.1'
39
+ rails: '~> 6.0.0'
40
+ runs-on: ${{ matrix.os }}
41
+ env:
42
+ RAILS_VERSION: ${{ matrix.rails }}
43
+ steps:
44
+ - uses: actions/checkout@v2
45
+ - uses: ruby/setup-ruby@v1
46
+ with:
47
+ ruby-version: ${{ matrix.ruby }}
48
+ rubygems: latest
49
+ bundler: latest
50
+ bundler-cache: true
51
+
52
+ - name: Setup wkhtmltopdf
53
+ run: |
54
+ sudo apt-get install -y xfonts-base xfonts-75dpi
55
+ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
56
+ sudo dpkg -i wkhtmltox_0.12.6-1.bionic_amd64.deb
57
+
58
+ - name: Run tests
59
+ run: bundle exec rake
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.4
1
+ 2.6.9
data/.travis.yml CHANGED
@@ -3,12 +3,38 @@ language: ruby
3
3
  rvm:
4
4
  - 2.5
5
5
  - 2.6
6
+ - 2.7
7
+ - 3.0
8
+ - 3.1
6
9
 
7
10
  env:
8
11
  matrix:
9
12
  - RAILS_VERSION="~> 4.1"
10
13
  - RAILS_VERSION="~> 5.2"
11
14
  - RAILS_VERSION="~> 6.0.0"
15
+ - RAILS_VERSION="~> 6.1"
16
+ - RAILS_VERSION="~> 7.0.0"
17
+
18
+ jobs:
19
+ exclude:
20
+ - rvm: 2.5
21
+ env: RAILS_VERSION="~> 7.0.0"
22
+ - rvm: 2.6
23
+ env: RAILS_VERSION="~> 7.0.0"
24
+ - rvm: 2.7
25
+ env: RAILS_VERSION="~> 4.1"
26
+ - rvm: 3.0
27
+ env: RAILS_VERSION="~> 4.1"
28
+ - rvm: 3.0
29
+ env: RAILS_VERSION="~> 5.2"
30
+ - rvm: 3.1
31
+ env: RAILS_VERSION="~> 4.1"
32
+ - rvm: 3.1
33
+ env: RAILS_VERSION="~> 5.2"
34
+ - rvm: 3.1
35
+ env: RAILS_VERSION="~> 6.0.0"
36
+
37
+ cache: bundler
12
38
 
13
39
  before_install:
14
40
  - gem update --system
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 2022-04-11
2
+ =================
3
+ * Bump to 0.8.6
4
+ * Update ruby and rails versions
5
+
1
6
  2021-01-23
2
7
  =================
3
8
  * Bump to 0.8.5
data/README.md CHANGED
@@ -4,8 +4,8 @@ Create PDFs using plain old HTML+CSS. Uses [wkhtmltopdf](http://github.com/antia
4
4
 
5
5
  ## Supported versions
6
6
 
7
- - Ruby 2.5, 2.6
8
- - Rails 4.2, 5.2, 6.0
7
+ - Ruby 2.5, 2.6, 2.7, 3.0, 3.1
8
+ - Rails 4.2, 5.2, 6.0, 6.1, 7.0
9
9
 
10
10
  ## Install
11
11
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PDFKit
2
4
  class Configuration
3
5
  attr_accessor :meta_tag_prefix, :root_url
@@ -26,7 +28,7 @@ class PDFKit
26
28
 
27
29
  def default_wkhtmltopdf
28
30
  return @default_command_path if @default_command_path
29
- if defined?(Bundler::GemfileError) && File.exists?('Gemfile')
31
+ if defined?(Bundler::GemfileError) && File.exist?('Gemfile')
30
32
  @default_command_path = `bundle exec which wkhtmltopdf`.chomp.lines.last
31
33
  end
32
34
  @default_command_path = `which wkhtmltopdf`.chomp if @default_command_path.nil? || @default_command_path.empty?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PDFKit
2
4
  module HTMLPreprocessor
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PDFKit
2
4
  class Middleware
3
5
  def initialize(app, options = {}, conditions = {})
data/lib/pdfkit/os.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rbconfig'
2
4
 
3
5
  class PDFKit
data/lib/pdfkit/pdfkit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'shellwords'
2
4
  require 'tempfile'
3
5
 
@@ -6,8 +8,8 @@ class PDFKit
6
8
 
7
9
  class NoExecutableError < Error
8
10
  def initialize
9
- msg = "No wkhtmltopdf executable found at #{PDFKit.configuration.wkhtmltopdf}\n"
10
- msg << ">> Please install wkhtmltopdf - https://github.com/pdfkit/PDFKit/wiki/Installing-WKHTMLTOPDF"
11
+ msg = "No wkhtmltopdf executable found at #{PDFKit.configuration.wkhtmltopdf}\n" \
12
+ ">> Please install wkhtmltopdf - https://github.com/pdfkit/PDFKit/wiki/Installing-WKHTMLTOPDF"
11
13
  super(msg)
12
14
  end
13
15
  end
@@ -40,7 +42,7 @@ class PDFKit
40
42
  @renderer = WkHTMLtoPDF.new options
41
43
  @renderer.normalize_options
42
44
 
43
- raise NoExecutableError unless File.exists?(PDFKit.configuration.wkhtmltopdf)
45
+ raise NoExecutableError unless File.exist?(PDFKit.configuration.wkhtmltopdf)
44
46
  end
45
47
 
46
48
  def command(path = nil)
data/lib/pdfkit/source.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tempfile'
2
4
  require 'uri'
3
5
 
@@ -7,6 +9,8 @@ class PDFKit
7
9
 
8
10
  def initialize(url_file_or_html)
9
11
  @source = url_file_or_html
12
+ # @source is assumed to be modifiable, so make sure it is.
13
+ @source = @source.dup if @source.is_a?(String) && @source.frozen?
10
14
  end
11
15
 
12
16
  def url?
@@ -38,11 +42,11 @@ class PDFKit
38
42
  private
39
43
 
40
44
  def shell_safe_url
41
- url_needs_escaping? ? URI::escape(@source) : @source
45
+ url_needs_escaping? ? URI::DEFAULT_PARSER.escape(@source) : @source
42
46
  end
43
47
 
44
48
  def url_needs_escaping?
45
- URI::decode(@source) == @source
49
+ URI::DEFAULT_PARSER.unescape(@source) == @source
46
50
  end
47
51
  end
48
52
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PDFKit
2
- VERSION = '0.8.5'
4
+ VERSION = '0.8.6'
3
5
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class PDFKit
2
4
  class WkHTMLtoPDF
3
5
  attr_reader :options
4
6
  # Pulled from:
5
7
  # https://github.com/wkhtmltopdf/wkhtmltopdf/blob/ebf9b6cfc4c58a31349fb94c568b254fac37b3d3/README_WKHTMLTOIMAGE#L27
6
- REPEATABLE_OPTIONS = %w[--allow --cookie --custom-header --post --post-file --run-script]
7
- SPECIAL_OPTIONS = %w[cover toc]
8
+ REPEATABLE_OPTIONS = %w[--allow --cookie --custom-header --post --post-file --run-script].freeze
9
+ SPECIAL_OPTIONS = %w[cover toc].freeze
8
10
 
9
11
  def initialize(options)
10
12
  @options = options
data/lib/pdfkit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pdfkit/source'
2
4
  require 'pdfkit/pdfkit'
3
5
  require 'pdfkit/middleware'
data/pdfkit.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.required_ruby_version = '>= 2.5'
21
+ s.required_ruby_version = ">= 2.5"
22
22
 
23
23
  s.requirements << "wkhtmltopdf"
24
24
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency(%q<activesupport>, [">= 4.1.11"])
27
27
  s.add_development_dependency(%q<mocha>, [">= 0.9.10"])
28
28
  s.add_development_dependency(%q<rack-test>, [">= 0.5.6"])
29
- s.add_development_dependency(%q<rake>, ["~>12.3.3"])
30
- s.add_development_dependency(%q<rdoc>, ["~> 4.0.1"])
29
+ s.add_development_dependency(%q<rake>, [">= 12.3.3"])
30
+ s.add_development_dependency(%q<rdoc>, [">= 4.0.1"])
31
31
  s.add_development_dependency(%q<rspec>, ["~> 3.0"])
32
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe PDFKit::Configuration do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe PDFKit::HTMLPreprocessor do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  def app; Rack::Lint.new(@app); end
@@ -267,8 +269,8 @@ describe PDFKit::Middleware do
267
269
  describe "saving generated pdf to disk" do
268
270
  before do
269
271
  #make sure tests don't find an old test_save.pdf
270
- File.delete('spec/test_save.pdf') if File.exists?('spec/test_save.pdf')
271
- expect(File.exists?('spec/test_save.pdf')).to eq(false)
272
+ File.delete('spec/test_save.pdf') if File.exist?('spec/test_save.pdf')
273
+ expect(File.exist?('spec/test_save.pdf')).to eq(false)
272
274
  end
273
275
 
274
276
  context "when header PDFKit-save-pdf is present" do
@@ -276,7 +278,7 @@ describe PDFKit::Middleware do
276
278
  headers = { 'PDFKit-save-pdf' => 'spec/test_save.pdf' }
277
279
  mock_app({}, {only: '/public'}, headers)
278
280
  get 'http://www.example.org/public/test_save.pdf'
279
- expect(File.exists?('spec/test_save.pdf')).to eq(true)
281
+ expect(File.exist?('spec/test_save.pdf')).to eq(true)
280
282
  end
281
283
 
282
284
  it "does not raise when target directory does not exist" do
@@ -292,7 +294,7 @@ describe PDFKit::Middleware do
292
294
  it "does not saved the .pdf to disk" do
293
295
  mock_app({}, {only: '/public'}, {} )
294
296
  get 'http://www.example.org/public/test_save.pdf'
295
- expect(File.exists?('spec/test_save.pdf')).to eq(false)
297
+ expect(File.exist?('spec/test_save.pdf')).to eq(false)
296
298
  end
297
299
  end
298
300
  end
data/spec/os_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  #encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'spec_helper'
3
5
  require 'rbconfig'
4
6
 
data/spec/pdfkit_spec.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  #encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'spec_helper'
3
5
 
4
6
  describe PDFKit do
@@ -27,7 +29,7 @@ describe PDFKit do
27
29
  file_path = File.join(SPEC_ROOT,'fixtures','example.html')
28
30
  pdfkit = PDFKit.new(Tempfile.new(file_path))
29
31
  expect(pdfkit.source).to be_file
30
- expect(pdfkit.source.to_s).to match /^#{Dir.tmpdir}/
32
+ expect(pdfkit.source.to_s).to match(/^#{Dir.tmpdir}/)
31
33
  end
32
34
 
33
35
  # Options
@@ -239,12 +241,12 @@ describe PDFKit do
239
241
 
240
242
  it "read the source from stdin if it is html" do
241
243
  pdfkit = PDFKit.new('html')
242
- expect(pdfkit.command).to match /- -$/
244
+ expect(pdfkit.command).to match(/- -$/)
243
245
  end
244
246
 
245
247
  it "specifies the URL to the source if it is a url" do
246
248
  pdfkit = PDFKit.new('http://google.com')
247
- expect(pdfkit.command).to match /"http:\/\/google.com" -$/
249
+ expect(pdfkit.command).to match(/"http:\/\/google.com" -$/)
248
250
  end
249
251
 
250
252
  it "does not break Windows paths" do
@@ -256,19 +258,19 @@ describe PDFKit do
256
258
  it "specifies the path to the source if it is a file" do
257
259
  file_path = File.join(SPEC_ROOT,'fixtures','example.html')
258
260
  pdfkit = PDFKit.new(File.new(file_path))
259
- expect(pdfkit.command).to match /#{file_path} -$/
261
+ expect(pdfkit.command).to match(/#{file_path} -$/)
260
262
  end
261
263
 
262
264
  it "specifies the path to the source if it is a tempfile" do
263
265
  file_path = File.join(SPEC_ROOT,'fixtures','example.html')
264
266
  pdfkit = PDFKit.new(Tempfile.new(file_path))
265
- expect(pdfkit.command).to match /#{Dir.tmpdir}\S+ -$/
267
+ expect(pdfkit.command).to match(/#{Dir.tmpdir}\S+ -$/)
266
268
  end
267
269
 
268
270
  it "specifies the path for the ouput if a path is given" do
269
271
  file_path = "/path/to/output.pdf"
270
272
  pdfkit = PDFKit.new("html")
271
- expect(pdfkit.command(file_path)).to match /#{file_path}$/
273
+ expect(pdfkit.command(file_path)).to match(/#{file_path}$/)
272
274
  end
273
275
 
274
276
  it "detects special pdfkit meta tags" do
data/spec/source_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe PDFKit::Source do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  SPEC_ROOT = File.dirname(__FILE__)
2
4
  $LOAD_PATH.unshift(SPEC_ROOT)
3
5
  $LOAD_PATH.unshift(File.join(SPEC_ROOT, '..', 'lib'))
@@ -6,13 +8,15 @@ SimpleCov.start do
6
8
  add_filter 'spec/'
7
9
  end
8
10
 
11
+ Warning[:deprecated] = true if defined?(Warning.[]=)
12
+
9
13
  require 'pdfkit'
10
14
  require 'rspec'
11
15
  require 'mocha'
12
16
  require 'rack'
13
17
  require 'rack/test'
14
18
  require 'active_support'
15
- require 'custom_wkhtmltopdf_path' if File.exists?(File.join(SPEC_ROOT, 'custom_wkhtmltopdf_path.rb'))
19
+ require 'custom_wkhtmltopdf_path' if File.exist?(File.join(SPEC_ROOT, 'custom_wkhtmltopdf_path.rb'))
16
20
 
17
21
  RSpec.configure do |config|
18
22
  include Rack::Test::Methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Pace
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-24 00:00:00.000000000 Z
12
+ date: 2022-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -57,28 +57,28 @@ dependencies:
57
57
  name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 12.3.3
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: 12.3.3
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rdoc
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: 4.0.1
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: 4.0.1
84
84
  - !ruby/object:Gem::Dependency
@@ -105,6 +105,7 @@ files:
105
105
  - ".document"
106
106
  - ".github/workflows/release-drafter.yml"
107
107
  - ".github/workflows/stale.yml"
108
+ - ".github/workflows/test.yml"
108
109
  - ".gitignore"
109
110
  - ".rspec"
110
111
  - ".ruby-gemset"
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  version: '0'
157
158
  requirements:
158
159
  - wkhtmltopdf
159
- rubygems_version: 3.0.3
160
+ rubygems_version: 3.0.3.1
160
161
  signing_key:
161
162
  specification_version: 4
162
163
  summary: HTML+CSS -> PDF