puppeteer-ruby 0.37.2 → 0.37.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a83ed41b8bd2c8068dc4a1738fa16abe80e88e59fb21c4768994ae640bb5b567
4
- data.tar.gz: 6e67fb0d381644bb376d09d01213320170aa5f9ec429694c9b98888bd2006722
3
+ metadata.gz: 84ede7b4fc083303903e960a08d2a21b44866b2b47662489005e09e6e955df01
4
+ data.tar.gz: aba2c71b916d6779560a200fff6685cb9f4ba83dc2b04e092926fb121add3155
5
5
  SHA512:
6
- metadata.gz: b229ccf33f63425298aa0d70051d6d6a1d61d9509bf6030499521b11494fb7b9ece03fa63ab5c31be6b0a552f28b5d7b571b6c930027445cee60bbcadaada24c
7
- data.tar.gz: 6f35fb3ea22f4cd557e062576fdb95939f16e62c611f09469bf8d7647f72ff380000e1b94ac8e1412b03f9107124a5ce21914c4e2b839e893ecd275ed73b9ef3
6
+ metadata.gz: 3b6a5cc66476c8954ab1ae942df3be6ad161ffe3aeb9b1ea51bde681f6cd9cf32d61d251980ab5d7f0907923b5ac42871cd7e99fbb55f0c00205ee231190f595
7
+ data.tar.gz: 7329fc6a4f8d1933efee34180c6d051e73613da2189b2af5226629d681c9f4b52abadf5eb548f45cb3af37d3ab1f093067b5e67e10e8c3cde09815a4fa3a0e4c
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
- ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.2...master)]
1
+ ### master [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.3...master)]
2
2
 
3
3
  - xxx
4
4
 
5
+ ### 0.37.3 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.2...0.37.3)]
6
+
7
+ Improvement:
8
+
9
+ - Improve the logic of detection of Chrome/Firefox executable path on Linux.
10
+
5
11
  ### 0.37.2 [[diff](https://github.com/YusukeIwaki/puppeteer-ruby/compare/0.37.1...0.37.2)]
6
12
 
7
13
  Bugfix:
data/README.md CHANGED
@@ -41,7 +41,7 @@ NOTE: `require 'puppeteer-ruby'` is not necessary in Rails.
41
41
  ```ruby
42
42
  require 'puppeteer-ruby'
43
43
 
44
- Puppeteer.launch(headless: false, slow_mo: 50, args: ['--guest', '--window-size=1280,800']) do |browser|
44
+ Puppeteer.launch(headless: false, slow_mo: 50, args: ['--window-size=1280,800']) do |browser|
45
45
  page = browser.new_page
46
46
  page.viewport = Puppeteer::Viewport.new(width: 1280, height: 800)
47
47
  page.goto("https://github.com/", wait_until: 'domcontentloaded')
data/docs/api_coverage.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # API coverages
2
- - Puppeteer version: v11.0.0
3
- - puppeteer-ruby version: 0.37.2
2
+ - Puppeteer version: v12.0.0
3
+ - puppeteer-ruby version: 0.37.3
4
4
 
5
5
  ## Puppeteer
6
6
 
@@ -0,0 +1,28 @@
1
+ class Puppeteer::ExecutablePathFinder
2
+ # @param executable_names [Array<String>] executable file names to find.
3
+ def initialize(*executable_names)
4
+ @executable_names = executable_names
5
+ end
6
+
7
+ def find_executables_in_path
8
+ Enumerator.new do |result|
9
+ @executable_names.each do |name|
10
+ # Find the first existing path.
11
+ paths.each do |path|
12
+ candidate = File.join(path, name)
13
+ next unless File.exist?(candidate)
14
+ result << candidate
15
+ break
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ def find_first
22
+ find_executables_in_path.first
23
+ end
24
+
25
+ private def paths
26
+ ENV['PATH'].split(File::PATH_SEPARATOR)
27
+ end
28
+ end
@@ -48,7 +48,7 @@ module Puppeteer::Launcher
48
48
  if @launch_options.channel
49
49
  executable_path_for_channel(@launch_options.channel.to_s)
50
50
  else
51
- @launch_options.executable_path || executable_path_for_channel('chrome')
51
+ @launch_options.executable_path || fallback_executable_path
52
52
  end
53
53
  use_pipe = chrome_arguments.include?('--remote-debugging-pipe')
54
54
  runner = Puppeteer::BrowserRunner.new(chrome_executable, chrome_arguments, temporary_user_data_dir)
@@ -216,10 +216,14 @@ module Puppeteer::Launcher
216
216
  if channel
217
217
  executable_path_for_channel(channel.to_s)
218
218
  else
219
- executable_path_for_channel('chrome')
219
+ fallback_executable_path
220
220
  end
221
221
  end
222
222
 
223
+ private def fallback_executable_path
224
+ executable_path_for_channel('chrome')
225
+ end
226
+
223
227
  CHROMIUM_CHANNELS = {
224
228
  windows: {
225
229
  'chrome' => "#{ENV['PROGRAMFILES']}\\Google\\Chrome\\Application\\chrome.exe",
@@ -236,7 +240,16 @@ module Puppeteer::Launcher
236
240
  'msedge' => '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
237
241
  },
238
242
  linux: {
239
- 'chrome' => '/opt/google/chrome/chrome',
243
+ 'chrome' => -> {
244
+ Puppeteer::ExecutablePathFinder.new(
245
+ 'google-chrome-stable',
246
+ 'google-chrome',
247
+ 'chrome',
248
+ 'chromium-freeworld',
249
+ 'chromium-browser',
250
+ 'chromium',
251
+ ).find_first
252
+ },
240
253
  'chrome-beta' => '/opt/google/chrome-beta/chrome',
241
254
  'chrome-dev' => '/opt/google/chrome-unstable/chrome',
242
255
  },
@@ -254,6 +267,10 @@ module Puppeteer::Launcher
254
267
  end
255
268
 
256
269
  chrome_path = chrome_path_map[channel]
270
+ if chrome_path.is_a?(Proc)
271
+ chrome_path = chrome_path.call
272
+ end
273
+
257
274
  unless chrome_path
258
275
  raise ArgumentError.new("Invalid channel: '#{channel}'. Allowed channel is #{chrome_path_map.keys}")
259
276
  end
@@ -42,7 +42,7 @@ module Puppeteer::Launcher
42
42
  if @launch_options.channel
43
43
  executable_path_for_channel(@launch_options.channel.to_s)
44
44
  else
45
- @launch_options.executable_path || executable_path_for_channel('nightly')
45
+ @launch_options.executable_path || fallback_executable_path
46
46
  end
47
47
  runner = Puppeteer::BrowserRunner.new(firefox_executable, firefox_arguments, temporary_user_data_dir)
48
48
  runner.start(
@@ -138,14 +138,18 @@ module Puppeteer::Launcher
138
138
  if channel
139
139
  executable_path_for_channel(channel.to_s)
140
140
  else
141
- executable_path_for_channel('firefox')
141
+ fallback_executable_path
142
142
  end
143
143
  end
144
144
 
145
+ private def fallback_executable_path
146
+ executable_path_for_channel('firefox')
147
+ end
148
+
145
149
  FIREFOX_EXECUTABLE_PATHS = {
146
150
  windows: "#{ENV['PROGRAMFILES']}\\Firefox Nightly\\firefox.exe",
147
151
  darwin: '/Applications/Firefox Nightly.app/Contents/MacOS/firefox',
148
- linux: '/usr/bin/firefox',
152
+ linux: -> { Puppeteer::ExecutablePathFinder.new('firefox').find_first },
149
153
  }.freeze
150
154
 
151
155
  # @param channel [String]
@@ -163,6 +167,9 @@ module Puppeteer::Launcher
163
167
  else
164
168
  FIREFOX_EXECUTABLE_PATHS[:linux]
165
169
  end
170
+ if firefox_path.is_a?(Proc)
171
+ firefox_path = firefox_path.call
172
+ end
166
173
 
167
174
  unless File.exist?(firefox_path)
168
175
  raise "Nightly version of Firefox is not installed on this system.\nExpected path: #{firefox_path}"
@@ -1,3 +1,3 @@
1
1
  module Puppeteer
2
- VERSION = '0.37.2'
2
+ VERSION = '0.37.3'
3
3
  end
data/lib/puppeteer.rb CHANGED
@@ -33,6 +33,7 @@ require 'puppeteer/dialog'
33
33
  require 'puppeteer/dom_world'
34
34
  require 'puppeteer/emulation_manager'
35
35
  require 'puppeteer/exception_details'
36
+ require 'puppeteer/executable_path_finder'
36
37
  require 'puppeteer/execution_context'
37
38
  require 'puppeteer/file_chooser'
38
39
  require 'puppeteer/frame'
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.37.2
4
+ version: 0.37.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-21 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -282,6 +282,7 @@ files:
282
282
  - lib/puppeteer/event_callbackable.rb
283
283
  - lib/puppeteer/events.rb
284
284
  - lib/puppeteer/exception_details.rb
285
+ - lib/puppeteer/executable_path_finder.rb
285
286
  - lib/puppeteer/execution_context.rb
286
287
  - lib/puppeteer/file_chooser.rb
287
288
  - lib/puppeteer/frame.rb