grover 0.13.1 → 0.13.2

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: 7084b165657179f7954b473653ff58cb634e0444177c95978168f1a481c2a423
4
- data.tar.gz: aa4497878b0d4eb55b0cd5703011db42c9d8f79fd65da906ce770956f59f032e
3
+ metadata.gz: ce6455d4d8ede0f5b91972977f8e5d17d8fab13e60096625cd9eb05e759ee8db
4
+ data.tar.gz: 12484117509a4f5e06bcce9cd39b95f16f105b662ff204f0a0f45b5a22455b51
5
5
  SHA512:
6
- metadata.gz: 95f0001bdba9e31e8025f0e4c693d7d2b60c20c3e51c11b91e8ed9934dfad160f0733db6ed40344b42a4c20a59d5990a346195d08539c7098311f5de095d7b7a
7
- data.tar.gz: 14a75499dd49dfa219b3dd914f2cb82601a0151a06c325805f3419a2836a228707cf1e63e9bfbecb0253be850b25134d1b8e2fbb6fe12a769b007c3c77f2f13a
6
+ metadata.gz: b488843267799c52530b27b7a3b8ac8cc76d8767f76062aca8cd32e7560c169d5e8e4d3f4a3498041cd180c4b0487337a51039487846a8a317fb2ecc4499a24a
7
+ data.tar.gz: fe4681c363d61d1a50fdedd0bbc0d76efa52b5d7990443e0b5fd7f978639a9ee3907b453a54afc3d595f27e85ca0a8d07ea3c91b52784f3f33914c6e1e31b6bc
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2020 Studiosity
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -5,13 +5,14 @@ class Grover
5
5
  # Configuration of the options for Grover HTML to PDF conversion
6
6
  #
7
7
  class Configuration
8
- attr_accessor :options, :meta_tag_prefix, :ignore_path,
8
+ attr_accessor :options, :meta_tag_prefix, :ignore_path, :root_url,
9
9
  :use_pdf_middleware, :use_png_middleware, :use_jpeg_middleware
10
10
 
11
11
  def initialize
12
12
  @options = {}
13
13
  @meta_tag_prefix = 'grover-'
14
14
  @ignore_path = nil
15
+ @root_url = nil
15
16
  @use_pdf_middleware = true
16
17
  @use_png_middleware = false
17
18
  @use_jpeg_middleware = false
@@ -10,11 +10,14 @@ class Grover
10
10
  # @see https://github.com/pdfkit/pdfkit
11
11
  #
12
12
  class Middleware # rubocop:disable Metrics/ClassLength
13
- def initialize(app)
13
+ def initialize(app, *args)
14
14
  @app = app
15
15
  @pdf_request = false
16
16
  @png_request = false
17
17
  @jpeg_request = false
18
+
19
+ @root_url =
20
+ args.last.is_a?(Hash) && args.last.key?(:root_url) ? args.last[:root_url] : Grover.configuration.root_url
18
21
  end
19
22
 
20
23
  def call(env)
@@ -76,7 +76,7 @@ class Grover
76
76
  @package_json ||= JSON.parse(File.read(package_json_path))
77
77
  end
78
78
 
79
- def call_js_method(method, url_or_html, options) # rubocop:disable Metrics/MethodLength
79
+ def call_js_method(method, url_or_html, options) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
80
80
  stdin.puts JSON.dump([method, url_or_html, options])
81
81
  input = stdout.gets
82
82
  raise Errno::EPIPE, "Can't read from worker" if input.nil?
@@ -90,6 +90,8 @@ class Grover
90
90
  else
91
91
  raise Grover::JavaScript.const_get(error_class, false), message
92
92
  end
93
+ rescue JSON::ParserError
94
+ raise Grover::Error, 'Malformed worker response'
93
95
  rescue Errno::EPIPE, IOError
94
96
  raise Grover::Error, "Worker process failed:\n#{stderr.read}"
95
97
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Grover
4
- VERSION = '0.13.1'
4
+ VERSION = '0.13.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bromwich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-29 00:00:00.000000000 Z
11
+ date: 2020-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: combine_pdf
@@ -163,6 +163,7 @@ executables: []
163
163
  extensions: []
164
164
  extra_rdoc_files: []
165
165
  files:
166
+ - LICENSE
166
167
  - lib/active_support_ext/object/deep_dup.rb
167
168
  - lib/active_support_ext/object/duplicable.rb
168
169
  - lib/grover.rb