Module: Async::WebDriver::Installer::Chrome::Platform

Defined in:
lib/async/webdriver/installer/chrome/platform.rb

Overview

Platform detection for Chrome for Testing downloads.

Maps Ruby’s ‘RUBY_PLATFORM` to the platform strings used by the Chrome for Testing JSON API and zip file naming conventions.

Constant Summary collapse

PLATFORM_MAP =

Ordered list of (pattern, platform) pairs. First match wins.

[
	[/arm.*darwin|darwin.*arm|aarch64.*darwin|darwin.*aarch64/, "mac-arm64"],
	[/darwin/, "mac-x64"],
	[/aarch64.*linux|linux.*aarch64/, "linux-arm64"],
	[/linux/, "linux64"],
	[/x64.*mingw|mingw.*x64/, "win64"],
	[/mingw/, "win32"],
].freeze

Class Method Summary collapse

Class Method Details

.chrome_binary(platform) ⇒ Object

Relative path to the Chrome binary inside the extracted chrome zip.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/async/webdriver/installer/chrome/platform.rb', line 38

def self.chrome_binary(platform)
	case platform
	when "mac-arm64"
		"chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
	when "mac-x64"
		"chrome-mac-x64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"
	when "linux64"
		"chrome-linux64/chrome"
	when "linux-arm64"
		"chrome-linux-arm64/chrome"
	when "win64"
		"chrome-win64/chrome.exe"
	when "win32"
		"chrome-win32/chrome.exe"
	else
		raise "Unknown platform: #{platform}"
	end
end

.chromedriver_binary(platform) ⇒ Object

Relative path to the chromedriver binary inside the extracted chromedriver zip.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/async/webdriver/installer/chrome/platform.rb', line 60

def self.chromedriver_binary(platform)
	case platform
	when "mac-arm64"
		"chromedriver-mac-arm64/chromedriver"
	when "mac-x64"
		"chromedriver-mac-x64/chromedriver"
	when "linux64"
		"chromedriver-linux64/chromedriver"
	when "linux-arm64"
		"chromedriver-linux-arm64/chromedriver"
	when "win64"
		"chromedriver-win64/chromedriver.exe"
	when "win32"
		"chromedriver-win32/chromedriver.exe"
	else
		raise "Unknown platform: #{platform}"
	end
end

.currentObject

Detect the current platform.



28
29
30
31
32
33
# File 'lib/async/webdriver/installer/chrome/platform.rb', line 28

def self.current
	PLATFORM_MAP.each do |pattern, platform|
		return platform if RUBY_PLATFORM.match?(pattern)
	end
	raise "Unsupported platform: #{RUBY_PLATFORM}"
end