grover 0.6.2 → 0.7.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
- SHA1:
3
- metadata.gz: 1062c1738a1216a3c8fb5907b1abcb5abee7ef4e
4
- data.tar.gz: 7a6aea69f2eaa43d30f0c126f0baea36c3b70470
2
+ SHA256:
3
+ metadata.gz: 0dd2633e1565fccf5aba8c538c7ebbb0d0479f7145b1785031a9029195f20811
4
+ data.tar.gz: ee046e2a56a34fdb63fb6714c1a0ef6ab3ad1e5273b69d3ffcc59e55449636fc
5
5
  SHA512:
6
- metadata.gz: 3824873485392bc39b03509cd88f296555aaea0984eaff8158be31bee78fc282d790d86cb988bf05eac1035a866d0306131fd31dd4d67fdca0157e3e241e3721
7
- data.tar.gz: 7f2ce9086e1206c2464232f80893b7098272737cb74398299514b6c8ed2f817e4485706965f73f858ac0f5e13c10b58653d84b1d574042b76225da0a954d08bd
6
+ metadata.gz: 785dcbf00a08efa14ec417f9064844e3bc9ef43dc9968aee31b201af40f1d8a231639bcc0fbd38f991ffa9ed4d202a28f8e48d3d06dde59fd87d06f7b54f3518
7
+ data.tar.gz: 1c3ebd039422218cc318d91006fd1229449a602bbc6addcddc1a1626224bf193a2811ad80f06b8521cc639d801284c985f3fd4f20d4e6839b39c98d3346f3316
@@ -21,15 +21,24 @@ class Grover
21
21
  dependencies puppeteer: 'puppeteer'
22
22
 
23
23
  def self.launch_params
24
- ENV['CI'] == 'true' ? "{args: ['--no-sandbox', '--disable-setuid-sandbox']}" : ''
24
+ ENV['CI'] == 'true' ? "{args: ['--no-sandbox', '--disable-setuid-sandbox']}" : '{}'
25
25
  end
26
26
 
27
- method :convert_pdf, <<-FUNCTION
27
+ method :convert_pdf, Utils.strip_heredoc(<<-FUNCTION)
28
28
  async (url_or_html, options) => {
29
29
  let browser;
30
30
  try {
31
+ let launchParams = #{launch_params};
32
+
33
+ // Configure puppeteer debugging options
34
+ const debug = options.debug; delete options.debug;
35
+ if (debug != undefined) {
36
+ if (debug.headless != undefined) { launchParams.headless = debug.headless; }
37
+ if (debug.devtools != undefined) { launchParams.devtools = debug.devtools; }
38
+ }
39
+
31
40
  // Launch the browser and create a page
32
- browser = await puppeteer.launch(#{launch_params});
41
+ browser = await puppeteer.launch(launchParams);
33
42
  const page = await browser.newPage();
34
43
 
35
44
  // Set caching flag (if provided)
@@ -69,8 +78,10 @@ class Grover
69
78
  await page.emulateMedia(emulateMedia);
70
79
  }
71
80
 
72
- // Return the converted PDF
73
- return await page.pdf(options);
81
+ // If we're not running puppeteer in headless mode, return the converted PDF
82
+ if (debug == undefined || debug.headless == undefined || debug.headless) {
83
+ return await page.pdf(options);
84
+ }
74
85
  } finally {
75
86
  if (browser) {
76
87
  await browser.close();
@@ -113,6 +124,8 @@ class Grover
113
124
  normalized_options = Utils.normalize_object @options
114
125
  normalized_options['path'] = path if path.is_a? ::String
115
126
  result = processor.convert_pdf @url, normalized_options
127
+ return unless result
128
+
116
129
  result['data'].pack('c*')
117
130
  end
118
131
 
@@ -31,7 +31,7 @@ class Grover
31
31
 
32
32
  private
33
33
 
34
- PDF_REGEX = /\.pdf$/i
34
+ PDF_REGEX = /\.pdf$/i.freeze
35
35
 
36
36
  def rendering_pdf?
37
37
  @render_pdf
@@ -1,3 +1,3 @@
1
1
  class Grover
2
- VERSION = '0.6.2'.freeze
2
+ VERSION = '0.7.1'.freeze
3
3
  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.6.2
4
+ version: 0.7.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: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: combine_pdf
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.2'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.3'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.3'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: pdf-reader
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -199,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
185
  version: '0'
200
186
  requirements: []
201
187
  rubyforge_project:
202
- rubygems_version: 2.6.14.1
188
+ rubygems_version: 2.7.6
203
189
  signing_key:
204
190
  specification_version: 4
205
191
  summary: A Ruby gem to transform HTML into PDFs wrapper the NodeJS Google Puppeteer