grover 1.2.8 → 1.2.10
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6975e57956621f04557b7b9634611de621cfbca81f067dec8f0f302adb861cdc
|
|
4
|
+
data.tar.gz: 922fb8f8df08bbbe4870fa013e543ca332703bcf888308d894047689824a9ee5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc2c71aa2cd450e562425f9f14df68c3e1fa4dfd3281a71a6d830a1acecf574c629d52c3d0b033414a6d1d9e675533f38d0300e2a97413845db2b354e559efb5
|
|
7
|
+
data.tar.gz: cc6ff7f47a9e34b7dc01d8a2a15c09482e90e7af414720eb05b64b1616829fddb10f738de696cac215cf8db5c079960cf55817ed5ff6ce8350b4762e141cb1de
|
|
@@ -20,7 +20,7 @@ class Object
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
class Array
|
|
23
|
+
class Array # rubocop:disable Style/OneClassPerFile
|
|
24
24
|
# Returns a deep copy of array.
|
|
25
25
|
#
|
|
26
26
|
# array = [1, [2, 3]]
|
|
@@ -34,7 +34,7 @@ class Array
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
class Hash
|
|
37
|
+
class Hash # rubocop:disable Style/OneClassPerFile
|
|
38
38
|
# Returns a deep copy of hash.
|
|
39
39
|
#
|
|
40
40
|
# hash = { a: { b: 'b' } }
|
|
@@ -31,7 +31,7 @@ class Object
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
class Method
|
|
34
|
+
class Method # rubocop:disable Style/OneClassPerFile
|
|
35
35
|
# Methods are not duplicable:
|
|
36
36
|
#
|
|
37
37
|
# method(:puts).duplicable? # => false
|
|
@@ -41,7 +41,7 @@ class Method
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
class UnboundMethod
|
|
44
|
+
class UnboundMethod # rubocop:disable Style/OneClassPerFile
|
|
45
45
|
# Unbound methods are not duplicable:
|
|
46
46
|
#
|
|
47
47
|
# method(:puts).unbind.duplicable? # => false
|
data/lib/grover/js/processor.cjs
CHANGED
|
@@ -34,7 +34,7 @@ function GroverError(name, errors) {
|
|
|
34
34
|
GroverError.prototype = Error.prototype;
|
|
35
35
|
|
|
36
36
|
const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
37
|
-
let browser, page, tmpDir, wsConnection = false;
|
|
37
|
+
let browser, context, page, tmpDir, wsConnection = false;
|
|
38
38
|
const requestErrors = [], pageErrors = [];
|
|
39
39
|
|
|
40
40
|
const captureRequestError = (request) => {
|
|
@@ -114,7 +114,12 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
|
114
114
|
browser = await puppeteer.launch(launchParams);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
if (wsConnection) {
|
|
118
|
+
context = await browser.createBrowserContext();
|
|
119
|
+
page = await context.newPage();
|
|
120
|
+
} else {
|
|
121
|
+
page = await browser.newPage();
|
|
122
|
+
}
|
|
118
123
|
|
|
119
124
|
// Basic auth
|
|
120
125
|
const username = options.username; delete options.username
|
|
@@ -214,6 +219,11 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
|
214
219
|
await cdp.send('Browser.setPermission', { permission: { name: 'local-network-access' }, setting: 'granted' });
|
|
215
220
|
}
|
|
216
221
|
|
|
222
|
+
const javaScriptEnabled = options.javaScriptEnabled; delete options.javaScriptEnabled;
|
|
223
|
+
if (javaScriptEnabled !== undefined) {
|
|
224
|
+
await page.setJavaScriptEnabled(javaScriptEnabled);
|
|
225
|
+
}
|
|
226
|
+
|
|
217
227
|
const raiseOnRequestFailure = options.raiseOnRequestFailure; delete options.raiseOnRequestFailure;
|
|
218
228
|
if (raiseOnRequestFailure) {
|
|
219
229
|
page.on('requestfinished', (request) => {
|
|
@@ -344,7 +354,7 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
|
344
354
|
} finally {
|
|
345
355
|
if (browser) {
|
|
346
356
|
if (wsConnection) {
|
|
347
|
-
if (
|
|
357
|
+
if (context) await context.close();
|
|
348
358
|
await browser.disconnect();
|
|
349
359
|
} else {
|
|
350
360
|
await browser.close();
|
data/lib/grover/options_fixer.rb
CHANGED
|
@@ -9,6 +9,9 @@ class Grover
|
|
|
9
9
|
class OptionsFixer
|
|
10
10
|
FALSE_VALUES = [nil, false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF'].freeze
|
|
11
11
|
|
|
12
|
+
JAVASCRIPT_OPTIONS = %w[evaluate_on_new_document execute_script script_tag_options wait_for_function].freeze
|
|
13
|
+
private_constant :JAVASCRIPT_OPTIONS
|
|
14
|
+
|
|
12
15
|
def initialize(options)
|
|
13
16
|
@options = options
|
|
14
17
|
end
|
|
@@ -18,6 +21,7 @@ class Grover
|
|
|
18
21
|
fix_integer_options!
|
|
19
22
|
fix_float_options!
|
|
20
23
|
fix_array_options!
|
|
24
|
+
disable_javascript_options!
|
|
21
25
|
@options
|
|
22
26
|
end
|
|
23
27
|
|
|
@@ -35,7 +39,7 @@ class Grover
|
|
|
35
39
|
fix_options!(
|
|
36
40
|
'display_header_footer', 'full_page', 'landscape', 'omit_background', 'prefer_css_page_size',
|
|
37
41
|
'print_background', 'viewport.has_touch', 'viewport.is_landscape', 'viewport.is_mobile', 'bypass_csp',
|
|
38
|
-
'raise_on_request_failure', 'raise_on_js_error'
|
|
42
|
+
'raise_on_request_failure', 'raise_on_js_error', 'javascript_enabled'
|
|
39
43
|
) { |value| !FALSE_VALUES.include?(value) }
|
|
40
44
|
end
|
|
41
45
|
|
|
@@ -60,5 +64,20 @@ class Grover
|
|
|
60
64
|
value.is_a?(String) ? YAML.safe_load(value) : value
|
|
61
65
|
end
|
|
62
66
|
end
|
|
67
|
+
|
|
68
|
+
def disable_javascript_options!
|
|
69
|
+
return if @options['javascript_enabled'] != false
|
|
70
|
+
|
|
71
|
+
JAVASCRIPT_OPTIONS.each do |option|
|
|
72
|
+
disable_javascript_option!(option)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def disable_javascript_option!(option)
|
|
77
|
+
return unless @options.key?(option)
|
|
78
|
+
|
|
79
|
+
@options.delete(option)
|
|
80
|
+
warn "#{self.class}: option #{option} has been disabled because javascript_enabled is set to false"
|
|
81
|
+
end
|
|
63
82
|
end
|
|
64
83
|
end
|
data/lib/grover/utils.rb
CHANGED
|
@@ -9,7 +9,8 @@ class Grover
|
|
|
9
9
|
'css' => 'CSS',
|
|
10
10
|
'csp' => 'CSP',
|
|
11
11
|
'http' => 'HTTP',
|
|
12
|
-
'js' => 'JS'
|
|
12
|
+
'js' => 'JS',
|
|
13
|
+
'javascript' => 'JavaScript'
|
|
13
14
|
}.freeze
|
|
14
15
|
private_constant :ACRONYMS
|
|
15
16
|
|
|
@@ -94,9 +95,9 @@ class Grover
|
|
|
94
95
|
# Regex sourced from ActiveSupport camelize
|
|
95
96
|
#
|
|
96
97
|
def self.normalize_key(key)
|
|
97
|
-
key.to_s.downcase.gsub(%r{(
|
|
98
|
+
key.to_s.downcase.gsub(%r{(?:^|_|(/))([a-z\d]*)}) do
|
|
98
99
|
"#{Regexp.last_match(1)}#{ACRONYMS[Regexp.last_match(2)] || Regexp.last_match(2).capitalize}"
|
|
99
|
-
end
|
|
100
|
+
end.sub(/^[[:alpha:]]/, &:downcase)
|
|
100
101
|
end
|
|
101
102
|
private_class_method :normalize_key
|
|
102
103
|
end
|
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: 1.2.
|
|
4
|
+
version: 1.2.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Bromwich
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02
|
|
11
|
+
date: 2026-04-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|