grover 1.1.11 → 1.2.1

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: 07f9183a814d7d598e29ee39cc4d7af3df619ba262aa1bef5be2de0cd9e7da3c
4
- data.tar.gz: 368d618c68428ff2f02832962463532a305ca48a2d6b8956dd978a80dc375052
3
+ metadata.gz: c1123f5ad0b72c13278999e8898b76407182df98c27e63061b5cbeeb8618b590
4
+ data.tar.gz: 49f20ea08de4248f4e5b28f7a8437831ae2cd25c0135b86cfbf51cb75c7bd26f
5
5
  SHA512:
6
- metadata.gz: 0deb217329f6141c3a7ed3da596945aa79213ca2216dbc914bb6b1e17104283bff1f8f45057f4fa099689fd8295560f9e0e2d023fa0e93551599a447649dace2
7
- data.tar.gz: 6e9b91209b59e8bc91ef38aa42906468c2b79614950f6d9e345d002468248519a633b69cbaeb4e6ad6e520e5f8acafa2356e084c1b167ac7717c344a287bcd72
6
+ metadata.gz: 985f49e244a7cfcc269b2240327f8da6639419a1343ced83cf119a0c5061cb04f2611d6672183ebd779b1f00f281db3a81aa7b6a1872ad49acfe89c5be75c2ed
7
+ data.tar.gz: 34eb183e68ab09b523acecb65e60be51131e518a54a6d0d6ea00ab70c2229070c842caf5326fd789d22ab0b990109b57fa742c1ff70bdf0b3ae6af6d2bf8ede1
@@ -7,9 +7,10 @@ class Grover
7
7
  class Configuration
8
8
  attr_accessor :options, :meta_tag_prefix, :ignore_path, :ignore_request,
9
9
  :root_url, :use_pdf_middleware, :use_png_middleware,
10
- :use_jpeg_middleware, :node_env_vars, :allow_file_uris
10
+ :use_jpeg_middleware, :js_runtime_bin,
11
+ :node_env_vars, :allow_file_uris
11
12
 
12
- def initialize
13
+ def initialize # rubocop:disable Metrics/MethodLength
13
14
  @options = {}
14
15
  @meta_tag_prefix = 'grover-'
15
16
  @ignore_path = nil
@@ -18,6 +19,7 @@ class Grover
18
19
  @use_pdf_middleware = true
19
20
  @use_png_middleware = false
20
21
  @use_jpeg_middleware = false
22
+ @js_runtime_bin = ['node']
21
23
  @node_env_vars = {}
22
24
  @allow_file_uris = false
23
25
  end
@@ -184,6 +184,12 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
184
184
  await page.setGeolocation(geolocation);
185
185
  }
186
186
 
187
+ // If specified, add script to evaluate before the page loads
188
+ const evaluateOnNewDocument = options.evaluateOnNewDocument; delete options.evaluateOnNewDocument;
189
+ if (evaluateOnNewDocument !== undefined) {
190
+ await page.evaluateOnNewDocument(evaluateOnNewDocument);
191
+ }
192
+
187
193
  const raiseOnRequestFailure = options.raiseOnRequestFailure; delete options.raiseOnRequestFailure;
188
194
  if (raiseOnRequestFailure) {
189
195
  page.on('requestfinished', (request) => {
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'combine_pdf'
4
-
5
3
  class Grover
6
4
  #
7
5
  # Rack middleware for catching PDF requests and returning the upstream HTML as a PDF
@@ -132,12 +130,19 @@ class Grover
132
130
  end
133
131
 
134
132
  def add_cover_content(grover)
133
+ load_combine_pdf
135
134
  pdf = CombinePDF.parse grover.to_pdf
136
135
  pdf >> fetch_cover_pdf(grover.front_cover_path) if grover.show_front_cover?
137
136
  pdf << fetch_cover_pdf(grover.back_cover_path) if grover.show_back_cover?
138
137
  pdf.to_pdf
139
138
  end
140
139
 
140
+ def load_combine_pdf
141
+ require 'combine_pdf'
142
+ rescue ::LoadError
143
+ raise Grover::Error, 'Please add/install the "combine_pdf" gem to use the front/back cover page feature'
144
+ end
145
+
141
146
  def fetch_cover_pdf(path)
142
147
  temp_env = env.deep_dup
143
148
  scrub_env! temp_env
@@ -33,7 +33,7 @@ class Grover
33
33
  def spawn_process
34
34
  @stdin, @stdout, @stderr, @wait_thr = Open3.popen3(
35
35
  Grover.configuration.node_env_vars,
36
- 'node',
36
+ *Grover.configuration.js_runtime_bin,
37
37
  File.expand_path(File.join(__dir__, 'js/processor.cjs')),
38
38
  chdir: app_root
39
39
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Grover
4
- VERSION = '1.1.11'
4
+ VERSION = '1.2.1'
5
5
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grover
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bromwich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-11 00:00:00.000000000 Z
11
+ date: 2024-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: combine_pdf
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: nokogiri
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '1.0'
19
+ version: '1'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '1.0'
26
+ version: '1'
41
27
  description: Transform HTML into PDF/PNG/JPEG using Google Puppeteer/Chromium
42
28
  email:
43
29
  - abromwich@studiosity.com