Module: Chromedriver::Binary::VersionResolver
Constant Summary
collapse
- BASE_URL =
"https://chromedriver.storage.googleapis.com"
- CHROME_FOR_TESTING_BASE_URL =
"https://googlechromelabs.github.io/chrome-for-testing/"
Instance Method Summary
collapse
#download_file, #exec_get_request, #extract_zip
#call, #exists?
Instance Method Details
#browser_build_version ⇒ Object
22
23
24
|
# File 'lib/chromedriver/binary/version_resolver.rb', line 22
def browser_build_version
normalize_version(browser_version.segments[0..2].join("."))
end
|
#current_installed_version ⇒ Gem::Version
Returns current chromedriver version.
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/chromedriver/binary/version_resolver.rb', line 48
def current_installed_version
Chromedriver::Binary.logger.debug "Checking current version"
return nil unless exists?(driver_path)
version = query_binary_version
return nil if version.nil?
normalize_version version[/\d+\.\d+(\.\d+)?(\.\d+)?/]
end
|
#direct_url_from_api(driver_version, driver_filename) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/chromedriver/binary/version_resolver.rb', line 37
def direct_url_from_api(driver_version, driver_filename)
data = fetch_data("known-good-versions-with-downloads.json")
version_data = data[:versions].find { |e| e[:version] == driver_version.to_s }
platform = version_data.dig(:downloads, :chromedriver).find { |e| e[:platform] == driver_filename }
platform[:url]
end
|
#driver_path ⇒ Object
59
60
61
|
# File 'lib/chromedriver/binary/version_resolver.rb', line 59
def driver_path
raise "driver_path not defined"
end
|
#latest_patch_version_for_build ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/chromedriver/binary/version_resolver.rb', line 26
def latest_patch_version_for_build
data = fetch_data("latest-patch-versions-per-build.json")
patch_version = data.dig(:builds, browser_build_version.to_s.to_sym, :version)
raise "No patch version found for build #{browser_build_version}" unless patch_version
patch_version
rescue StandardError => e
raise "Error fetching latest patch version: #{e.message}"
end
|
#normalize_version(version) ⇒ Object
18
19
20
|
# File 'lib/chromedriver/binary/version_resolver.rb', line 18
def normalize_version(version)
Gem::Version.new(version.to_s)
end
|
#query_binary_version ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'lib/chromedriver/binary/version_resolver.rb', line 63
def query_binary_version
version = call(driver_path, "--version")
Chromedriver::Binary.logger.debug "Current version of #{driver_path} is #{version}"
version
rescue Errno::ENOENT
Chromedriver::Binary.logger.debug "No Such File or Directory: #{driver_path}"
nil
end
|