grover 1.2.8 → 1.2.9
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: 4f53cae1260aa636889607929ff735fc876e1d439ad656f18a71dab32ef911a2
|
|
4
|
+
data.tar.gz: e51808378914be56bf9c9d320633ec0db33db7646d83a7edb229c7517d36540a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dde098900baf3045083d5e60fdf431438c9fe599d373a44d21102c3bc9c2a5370fd6a7dadb580d74fd559f5cafcf2239c5249bd9849c4f2057f410b9fc88ce7f
|
|
7
|
+
data.tar.gz: b3a33f90d6658bde15d1bf9179f86fbb769d72c5c5ee3212f509aeda195def9233eb4a91ee4c17824d0646acd7e5d07907efa96374793ec23458ce4a60a1dffa
|
|
@@ -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
|
@@ -214,6 +214,11 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
|
214
214
|
await cdp.send('Browser.setPermission', { permission: { name: 'local-network-access' }, setting: 'granted' });
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
const javaScriptEnabled = options.javaScriptEnabled; delete options.javaScriptEnabled;
|
|
218
|
+
if (javaScriptEnabled !== undefined) {
|
|
219
|
+
await page.setJavaScriptEnabled(javaScriptEnabled);
|
|
220
|
+
}
|
|
221
|
+
|
|
217
222
|
const raiseOnRequestFailure = options.raiseOnRequestFailure; delete options.raiseOnRequestFailure;
|
|
218
223
|
if (raiseOnRequestFailure) {
|
|
219
224
|
page.on('requestfinished', (request) => {
|
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,13 @@
|
|
|
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.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Bromwich
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: nokogiri
|
|
@@ -52,7 +51,6 @@ licenses:
|
|
|
52
51
|
metadata:
|
|
53
52
|
allowed_push_host: https://rubygems.org
|
|
54
53
|
rubygems_mfa_required: 'true'
|
|
55
|
-
post_install_message:
|
|
56
54
|
rdoc_options: []
|
|
57
55
|
require_paths:
|
|
58
56
|
- lib
|
|
@@ -70,8 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
70
68
|
- !ruby/object:Gem::Version
|
|
71
69
|
version: '0'
|
|
72
70
|
requirements: []
|
|
73
|
-
rubygems_version: 3.
|
|
74
|
-
signing_key:
|
|
71
|
+
rubygems_version: 3.6.9
|
|
75
72
|
specification_version: 4
|
|
76
73
|
summary: A Ruby gem to transform HTML into PDF, PNG or JPEG by wrapping the NodeJS
|
|
77
74
|
Google Puppeteer driver for Chromium
|