puppeteer-ruby 0.0.21 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +32 -22
- data/.github/workflows/reviewdog.yml +1 -1
- data/.rubocop.yml +37 -0
- data/CHANGELOG.md +74 -0
- data/Dockerfile +1 -1
- data/README.md +15 -0
- data/lib/puppeteer.rb +9 -2
- data/lib/puppeteer/browser.rb +19 -28
- data/lib/puppeteer/browser_context.rb +48 -49
- data/lib/puppeteer/browser_runner.rb +19 -5
- data/lib/puppeteer/cdp_session.rb +11 -7
- data/lib/puppeteer/concurrent_ruby_utils.rb +22 -6
- data/lib/puppeteer/connection.rb +30 -11
- data/lib/puppeteer/define_async_method.rb +15 -6
- data/lib/puppeteer/dom_world.rb +2 -2
- data/lib/puppeteer/event_callbackable.rb +4 -0
- data/lib/puppeteer/events.rb +184 -0
- data/lib/puppeteer/exception_details.rb +38 -0
- data/lib/puppeteer/frame_manager.rb +20 -16
- data/lib/puppeteer/geolocation.rb +24 -0
- data/lib/puppeteer/launcher.rb +0 -1
- data/lib/puppeteer/launcher/browser_options.rb +2 -1
- data/lib/puppeteer/launcher/chrome.rb +4 -8
- data/lib/puppeteer/launcher/firefox.rb +4 -8
- data/lib/puppeteer/lifecycle_watcher.rb +6 -6
- data/lib/puppeteer/network_manager.rb +6 -6
- data/lib/puppeteer/page.rb +119 -141
- data/lib/puppeteer/page/screenshot_options.rb +2 -2
- data/lib/puppeteer/page/screenshot_task_queue.rb +13 -0
- data/lib/puppeteer/target.rb +4 -6
- data/lib/puppeteer/version.rb +1 -1
- data/puppeteer-ruby.gemspec +6 -4
- metadata +43 -10
@@ -32,14 +32,14 @@ class Puppeteer::Page
|
|
32
32
|
@type ||= 'png'
|
33
33
|
|
34
34
|
if options[:quality]
|
35
|
-
unless @type == '
|
35
|
+
unless @type == 'jpeg'
|
36
36
|
raise ArgumentError.new("options.quality is unsupported for the #{@type} screenshots")
|
37
37
|
end
|
38
38
|
unless options[:quality].is_a?(Numeric)
|
39
39
|
raise ArgumentError.new("Expected options.quality to be a number but found #{options[:quality].class}")
|
40
40
|
end
|
41
41
|
quality = options[:quality].to_i
|
42
|
-
unless (0..100).include?(
|
42
|
+
unless (0..100).include?(quality)
|
43
43
|
raise ArgumentError.new("Expected options.quality to be between 0 and 100 (inclusive), got #{quality}")
|
44
44
|
end
|
45
45
|
@quality = quality
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Puppeteer::Page
|
2
|
+
class ScreenshotTaskQueue
|
3
|
+
def initialize
|
4
|
+
@chain = Concurrent::Promises.fulfilled_future(nil)
|
5
|
+
end
|
6
|
+
|
7
|
+
def post_task(&block)
|
8
|
+
result = @chain.then { block.call }
|
9
|
+
@chain = result.rescue { nil }
|
10
|
+
result.value!
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/puppeteer/target.rb
CHANGED
@@ -18,15 +18,13 @@ class Puppeteer::Target
|
|
18
18
|
# @param {!function():!Promise<!Puppeteer.CDPSession>} sessionFactory
|
19
19
|
# @param {boolean} ignoreHTTPSErrors
|
20
20
|
# @param {?Puppeteer.Viewport} defaultViewport
|
21
|
-
|
22
|
-
def initialize(target_info:, browser_context:, session_factory:, ignore_https_errors:, default_viewport:, screenshot_task_queue:)
|
21
|
+
def initialize(target_info:, browser_context:, session_factory:, ignore_https_errors:, default_viewport:)
|
23
22
|
@target_info = target_info
|
24
23
|
@browser_context = browser_context
|
25
24
|
@target_id = target_info.target_id
|
26
25
|
@session_factory = session_factory
|
27
26
|
@ignore_https_errors = ignore_https_errors
|
28
27
|
@default_viewport = default_viewport
|
29
|
-
@screenshot_task_queue = screenshot_task_queue
|
30
28
|
|
31
29
|
|
32
30
|
# /** @type {?Promise<!Puppeteer.Page>} */
|
@@ -68,10 +66,10 @@ class Puppeteer::Target
|
|
68
66
|
if opener_page.nil? || type != 'page'
|
69
67
|
return true
|
70
68
|
end
|
71
|
-
# if (!openerPage.listenerCount(
|
69
|
+
# if (!openerPage.listenerCount(PageEmittedEvents::Popup))
|
72
70
|
# return true;
|
73
71
|
popup_page = page
|
74
|
-
opener_page.emit_event(
|
72
|
+
opener_page.emit_event(PageEmittedEvents::Popup, popup_page)
|
75
73
|
|
76
74
|
true
|
77
75
|
end
|
@@ -87,7 +85,7 @@ class Puppeteer::Target
|
|
87
85
|
def page
|
88
86
|
if ['page', 'background_page', 'webview'].include?(@target_info.type) && @page.nil?
|
89
87
|
client = @session_factory.call
|
90
|
-
@page = Puppeteer::Page.create(client, self, @ignore_https_errors, @default_viewport
|
88
|
+
@page = Puppeteer::Page.create(client, self, @ignore_https_errors, @default_viewport)
|
91
89
|
end
|
92
90
|
@page
|
93
91
|
end
|
data/lib/puppeteer/version.rb
CHANGED
data/puppeteer-ruby.gemspec
CHANGED
@@ -21,13 +21,15 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'concurrent-ruby', '~> 1.1.0'
|
22
22
|
spec.add_dependency 'websocket-driver', '>= 0.6.0'
|
23
23
|
spec.add_dependency 'mime-types', '>= 3.0'
|
24
|
-
spec.add_development_dependency 'bundler', '~>
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.2.3'
|
25
|
+
spec.add_development_dependency 'chunky_png'
|
25
26
|
spec.add_development_dependency 'pry-byebug'
|
26
|
-
spec.add_development_dependency 'rake', '~>
|
27
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'rake', '~> 13.0.3'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.10.0 '
|
28
29
|
spec.add_development_dependency 'rspec_junit_formatter' # for CircleCI.
|
29
|
-
spec.add_development_dependency 'rubocop', '~>
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 1.6.1'
|
30
31
|
spec.add_development_dependency 'rubocop-rspec'
|
31
32
|
spec.add_development_dependency 'sinatra'
|
33
|
+
spec.add_development_dependency 'webrick'
|
32
34
|
spec.add_development_dependency 'yard'
|
33
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppeteer-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -58,14 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.2.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.2.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: chunky_png
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pry-byebug
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +100,28 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 13.0.3
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 13.0.3
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rspec
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
117
|
+
version: 3.10.0
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
124
|
+
version: 3.10.0
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rspec_junit_formatter
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +142,14 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: 1.6.1
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
152
|
+
version: 1.6.1
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: rubocop-rspec
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +178,20 @@ dependencies:
|
|
164
178
|
- - ">="
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: webrick
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: yard
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,6 +221,7 @@ files:
|
|
193
221
|
- ".rspec"
|
194
222
|
- ".rubocop.yml"
|
195
223
|
- ".travis.yml"
|
224
|
+
- CHANGELOG.md
|
196
225
|
- Dockerfile
|
197
226
|
- Gemfile
|
198
227
|
- README.md
|
@@ -223,10 +252,13 @@ files:
|
|
223
252
|
- lib/puppeteer/env.rb
|
224
253
|
- lib/puppeteer/errors.rb
|
225
254
|
- lib/puppeteer/event_callbackable.rb
|
255
|
+
- lib/puppeteer/events.rb
|
256
|
+
- lib/puppeteer/exception_details.rb
|
226
257
|
- lib/puppeteer/execution_context.rb
|
227
258
|
- lib/puppeteer/file_chooser.rb
|
228
259
|
- lib/puppeteer/frame.rb
|
229
260
|
- lib/puppeteer/frame_manager.rb
|
261
|
+
- lib/puppeteer/geolocation.rb
|
230
262
|
- lib/puppeteer/if_present.rb
|
231
263
|
- lib/puppeteer/js_handle.rb
|
232
264
|
- lib/puppeteer/keyboard.rb
|
@@ -245,6 +277,7 @@ files:
|
|
245
277
|
- lib/puppeteer/page.rb
|
246
278
|
- lib/puppeteer/page/pdf_options.rb
|
247
279
|
- lib/puppeteer/page/screenshot_options.rb
|
280
|
+
- lib/puppeteer/page/screenshot_task_queue.rb
|
248
281
|
- lib/puppeteer/remote_object.rb
|
249
282
|
- lib/puppeteer/request.rb
|
250
283
|
- lib/puppeteer/response.rb
|