Class: FirefoxdriverDownloader
- Inherits:
-
DriverDownloader
- Object
- DriverDownloader
- FirefoxdriverDownloader
- Defined in:
- lib/chauffeur/downloaders/firefoxdriver_downloader.rb
Overview
FireFoxDriver specific functions for driver downloading.
Constant Summary collapse
- GECKODRIVER_URL =
'https://github.com/mozilla/geckodriver/releases/'.freeze
Instance Method Summary collapse
-
#all_driver_versions ⇒ Object
Returns all available versions of geckodriver.
- #all_platforms ⇒ Object
- #browser_name ⇒ Object
-
#driver_download_url(version, platform) ⇒ Object
Returns the url for the desired version of geckodriver 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) ⇒ FirefoxdriverDownloader
constructor
A new instance of FirefoxdriverDownloader.
-
#latest_driver_version(platform) ⇒ Object
Returns the most recent version of geckodriver for the desired platform.
- #valid_version?(version) ⇒ Boolean
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) ⇒ FirefoxdriverDownloader
Returns a new instance of FirefoxdriverDownloader.
5 6 7 8 |
# File 'lib/chauffeur/downloaders/firefoxdriver_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 geckodriver
31 32 33 34 35 36 37 |
# File 'lib/chauffeur/downloaders/firefoxdriver_downloader.rb', line 31 def all_driver_versions resp = HTTParty.get(GECKODRIVER_URL, verify: false).parsed_response doc = Nokogiri::XML.parse(resp) ver_array = doc.css('div.release div.release-header div a').map(&:text) raise 'No versions found' if ver_array.empty? ver_array - ['Latest release'] end |
#all_platforms ⇒ Object
18 19 20 |
# File 'lib/chauffeur/downloaders/firefoxdriver_downloader.rb', line 18 def all_platforms %w[linux32 linux64 macos win32 win64] end |
#browser_name ⇒ Object
10 11 12 |
# File 'lib/chauffeur/downloaders/firefoxdriver_downloader.rb', line 10 def browser_name 'geckodriver' end |
#driver_download_url(version, platform) ⇒ Object
Returns the url for the desired version of geckodriver version: string - must match exactly the version in the download URL platform: string - must be one of: linux32, linux64, mac32, win32
42 43 44 45 46 47 48 |
# File 'lib/chauffeur/downloaders/firefoxdriver_downloader.rb', line 42 def driver_download_url(version, platform) raise unknown_platform_error(platform) unless valid_platform?(platform) raise unknown_version_error(version) unless valid_version?(version) extension = platform.start_with?('win') ? 'zip' : 'tar.gz' rel_path = "/download/v#{version}/geckodriver-v#{version}-#{platform}.#{extension}" "#{GECKODRIVER_URL}#{rel_path}" end |
#driver_url ⇒ Object
14 15 16 |
# File 'lib/chauffeur/downloaders/firefoxdriver_downloader.rb', line 14 def driver_url GECKODRIVER_URL end |
#latest_driver_version(platform) ⇒ Object
Returns the most recent version of geckodriver for the desired platform. platform must be one of: linux32, linux64, mac32, win32
25 26 27 28 |
# File 'lib/chauffeur/downloaders/firefoxdriver_downloader.rb', line 25 def latest_driver_version(platform) raise unknown_platform_error(platform) unless valid_platform?(platform) @all_driver_versions.map { |v| Gem::Version.new(v.delete('v')) }.max end |
#valid_version?(version) ⇒ Boolean
50 51 52 53 |
# File 'lib/chauffeur/downloaders/firefoxdriver_downloader.rb', line 50 def valid_version?(version) valid_versions = @all_driver_versions valid_versions.include?("v#{version}") end |