grover 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grover.rb +11 -9
- data/lib/grover/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3499ca1308bdc11b92605c7f1efb995f64f873ef
|
4
|
+
data.tar.gz: 4cf09e30a261f9f343369b954e7e51512fb11773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f03c61dd07b4a9bd6698caad36fc9c60a1e2e07a7613c35b7e21166eacfe15c57ba65be64ce97045927b623075d4434d80d7e6bedbe17f79189dc5f90ed2b54a
|
7
|
+
data.tar.gz: ac097fe4fee335a54e06ed9cb12b1025463467fdddc918f8e113c6345fa73f72eb97f42bc8814e3cf29bb70f434b05afd674668706237e24c051778ee61b8c30
|
data/lib/grover.rb
CHANGED
@@ -21,28 +21,30 @@ 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
27
|
method :convert_pdf, Utils.squish(<<-FUNCTION)
|
28
28
|
async (url, options) => {
|
29
29
|
let browser;
|
30
30
|
try {
|
31
|
-
|
32
|
-
const timeout = options.timeout; delete options.timeout;
|
33
|
-
if (timeout) {
|
34
|
-
launch_params.timeout = timeout;
|
35
|
-
}
|
36
|
-
browser = await puppeteer.launch(launch_params);
|
31
|
+
browser = await puppeteer.launch(#{launch_params});
|
37
32
|
const page = await browser.newPage();
|
38
33
|
|
39
34
|
const cache = options.cache; delete options.cache;
|
40
35
|
await page.setCacheEnabled(cache);
|
41
36
|
|
37
|
+
let request_options = {};
|
38
|
+
const timeout = options.timeout; delete options.timeout;
|
39
|
+
if (timeout) {
|
40
|
+
request_options.timeout = timeout;
|
41
|
+
}
|
42
42
|
if (url.match(/^http/i)) {
|
43
|
-
|
43
|
+
request_options.waitUntil = 'networkidle2';
|
44
|
+
await page.goto(url, request_options);
|
44
45
|
} else {
|
45
|
-
|
46
|
+
request_options.waitUntil = 'networkidle0';
|
47
|
+
await page.goto(`data:text/html,${url}`, request_options);
|
46
48
|
}
|
47
49
|
|
48
50
|
const emulateMedia = options.emulateMedia; delete options.emulateMedia;
|
data/lib/grover/version.rb
CHANGED