Class: ChromedriverDownloader
- Inherits:
-
DriverDownloader
- Object
- DriverDownloader
- ChromedriverDownloader
- Defined in:
- lib/chauffeur/downloaders/chromedriver_downloader.rb
Overview
ChromeDriver specific functions for driver downloading.
Constant Summary collapse
- CHROMEDRIVER_URL =
'http://chromedriver.storage.googleapis.com/'.freeze
Instance Method Summary collapse
-
#all_driver_versions ⇒ Object
Returns all available versions of Chromedriver.
- #all_platforms ⇒ Object
- #browser_name ⇒ Object
-
#driver_download_url(version, platform) ⇒ Object
Returns the url for the desired version of chromedriver version: string - must match exactly the version in the download URL platform: string - must be one of: linux32, linux64, mac32, win32.
- #driver_url ⇒ Object
-
#initialize(verbose = true) ⇒ ChromedriverDownloader
constructor
A new instance of ChromedriverDownloader.
-
#latest_driver_version(platform) ⇒ Object
Returns the most recent version of chromedriver for the desired platform.
Methods inherited from DriverDownloader
#download_and_unzip, #install_driver, #install_driver_all_platforms, #path_for, #upgrade_driver, #upgrade_driver_all_platforms
Constructor Details
#initialize(verbose = true) ⇒ ChromedriverDownloader
Returns a new instance of ChromedriverDownloader.
5 6 7 8 |
# File 'lib/chauffeur/downloaders/chromedriver_downloader.rb', line 5 def initialize(verbose = true) @all_driver_versions = all_driver_versions super(verbose) end |
Instance Method Details
#all_driver_versions ⇒ Object
Returns all available versions of Chromedriver
32 33 34 35 |
# File 'lib/chauffeur/downloaders/chromedriver_downloader.rb', line 32 def all_driver_versions resp = HTTParty.get(CHROMEDRIVER_URL).parsed_response resp['ListBucketResult']['Contents'].map { |c| c['Key'] } end |
#all_platforms ⇒ Object
18 19 20 |
# File 'lib/chauffeur/downloaders/chromedriver_downloader.rb', line 18 def all_platforms %w[linux32 linux64 mac32 win32] end |
#browser_name ⇒ Object
10 11 12 |
# File 'lib/chauffeur/downloaders/chromedriver_downloader.rb', line 10 def browser_name 'chromedriver' end |
#driver_download_url(version, platform) ⇒ Object
Returns the url for the desired version of chromedriver version: string - must match exactly the version in the download URL platform: string - must be one of: linux32, linux64, mac32, win32
40 41 42 43 44 45 46 47 |
# File 'lib/chauffeur/downloaders/chromedriver_downloader.rb', line 40 def driver_download_url(version, platform) raise unknown_platform_error(platform) unless valid_platform?(platform) rel_path = @all_driver_versions.find do |v| v.eql?("#{version}/chromedriver_#{platform}.zip") end raise unknown_version_error(version) unless rel_path "#{CHROMEDRIVER_URL}#{rel_path}" end |
#driver_url ⇒ Object
14 15 16 |
# File 'lib/chauffeur/downloaders/chromedriver_downloader.rb', line 14 def driver_url CHROMEDRIVER_URL end |
#latest_driver_version(platform) ⇒ Object
Returns the most recent version of chromedriver for the desired platform. platform must be one of: linux32, linux64, mac32, win32
25 26 27 28 29 |
# File 'lib/chauffeur/downloaders/chromedriver_downloader.rb', line 25 def latest_driver_version(platform) raise unknown_platform_error(platform) unless valid_platform?(platform) platform_drivers = @all_driver_versions.select { |v| v.include?(platform) } platform_drivers.map { |v| version_of(v.split('/')[0]) }.max end |