chromium-pdf 1.0.4 → 1.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00ca3cc4b98adc752f0fc922ef246c613acfb35f915edc90ffb551803ba17d8c
4
- data.tar.gz: 6ac4d6928c6ef664e70b6429fa7b401a0b832a38cbdea17d94feaee3cefe7076
3
+ metadata.gz: afa7368ea8f9d35e2b64a1e8b19746e0197c5a78788693c6c8c193cf7a6b6095
4
+ data.tar.gz: bde5ed7f8ad0f0ef810466f9f3ff687e4087a6424acb9c01dff092e985a105ec
5
5
  SHA512:
6
- metadata.gz: 547f1f46062417cdfa4d80da94ce0aa4b1134ebc1a619372380680ecd859861055d3f8aafcd9409bff129de212c8f37096bc07346bde7e21c5a221ae0d1c6528
7
- data.tar.gz: dfc587b51a40b3ec10d122ddb3c5c2dda8c9fb4f4be346ae895211901fd0e69861b738f047319ebf77a85d08e68cf326b5b2dfe0a02da3b57693a5f9a806d9d3
6
+ metadata.gz: 6531912997d2a24850bb7d707d7464e71f26705a875e4ded22548e13310d55bf641c30d3cf28c73a00e2c87952e06dab1e9e6d8a17ed2c9eb9ca02bbc329e5a9
7
+ data.tar.gz: b3f8184f00a4a9f101a64d050a87708378227692614f806f26643d896d50ef10f3cad32d8c755499c9c2ff41415a67bae637443edca6b62735af783089b23eab
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Chromium
4
4
  module Pdf
5
- VERSION = '1.0.4'
5
+ VERSION = '1.0.6'
6
6
  end
7
7
  end
data/lib/chromium/pdf.rb CHANGED
@@ -29,20 +29,26 @@ module Chromium
29
29
 
30
30
  Dir.mktmpdir do |path|
31
31
  filepath = "#{path}/#{filename}"
32
- chrome_print(print_url, filename, filepath, arguments, &block)
32
+ chrome_print!(print_url, filepath, arguments)
33
+
34
+ File.open(filepath) do |file|
35
+ block&.call(file, filename)
36
+ end
33
37
  end
34
38
  end
35
39
 
36
40
  protected
37
41
 
38
- def chrome_print(print_url, filename, filepath, arguments, &block)
42
+ def chrome_print!(print_url, pdf_path, arguments)
39
43
  chrome_path = ENV.fetch('GOOGLE_CHROME_BIN', 'chrome')
40
- Kernel.system("LD_PRELOAD='' #{chrome_path} --print-to-pdf='#{filepath}' #{arguments.join(' ')} #{print_url}")
41
- sleep 0.1 until file_created?(filepath)
42
-
43
- File.open(filepath) do |file|
44
- block&.call(file, filename)
45
- end
44
+ Kernel.system(
45
+ { 'LD_PRELOAD' => '' },
46
+ chrome_path,
47
+ *arguments,
48
+ "--print-to-pdf=#{pdf_path}",
49
+ print_url,
50
+ exception: true
51
+ )
46
52
  end
47
53
 
48
54
  def file_created?(filepath)
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GeneratePdfJob < ApplicationJob
4
- JobTimeoutError = Class.new(StandardError)
4
+ class JobTimeoutError < StandardError
5
+ end
5
6
  include GoodJob::ActiveJobExtensions::Concurrency
6
7
  include Chromium::Pdf
7
8
 
@@ -16,9 +17,7 @@ class GeneratePdfJob < ApplicationJob
16
17
  )
17
18
 
18
19
  around_perform do |_job, block|
19
- Timeout.timeout(180.seconds, JobTimeoutError) do
20
- block.call
21
- end
20
+ Timeout.timeout(180.seconds, JobTimeoutError, &block)
22
21
  end
23
22
 
24
23
  def perform(model)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chromium-pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - RoleModel Software