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 +5 -5
- data/lib/grover.rb +18 -5
- data/lib/grover/middleware.rb +1 -1
- data/lib/grover/version.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0dd2633e1565fccf5aba8c538c7ebbb0d0479f7145b1785031a9029195f20811
|
4
|
+
data.tar.gz: ee046e2a56a34fdb63fb6714c1a0ef6ab3ad1e5273b69d3ffcc59e55449636fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 785dcbf00a08efa14ec417f9064844e3bc9ef43dc9968aee31b201af40f1d8a231639bcc0fbd38f991ffa9ed4d202a28f8e48d3d06dde59fd87d06f7b54f3518
|
7
|
+
data.tar.gz: 1c3ebd039422218cc318d91006fd1229449a602bbc6addcddc1a1626224bf193a2811ad80f06b8521cc639d801284c985f3fd4f20d4e6839b39c98d3346f3316
|
data/lib/grover.rb
CHANGED
@@ -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(
|
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
|
-
//
|
73
|
-
|
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
|
|
data/lib/grover/middleware.rb
CHANGED
data/lib/grover/version.rb
CHANGED
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.
|
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:
|
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
|
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
|