Sha256: 30cd05bd1d2167c95c660f3f6fa6033d9674aecfb01c14f132632d1551c1dcb2
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require 'nokogiri' require 'open-uri' require 'zip' module Webdrivers class Chromedriver < Common class << self def current return nil unless downloaded? puts binary string = %x(#{binary} --version) puts string normalize string.match(/ChromeDriver (\d\.\d+)/)[1] end private def normalize(string) string.size == 3 ? string.gsub('.', '.0').to_f : string.to_f end def file_name platform == "win" ? "chromedriver.exe" : "chromedriver" end def base_url 'http://chromedriver.storage.googleapis.com' end def downloads raise StandardError, "Can not reach site" unless site_available? @downloads ||= begin doc = Nokogiri::XML.parse(OpenURI.open_uri(base_url)) items = doc.css("Contents Key").collect(&:text) items.select! {|item| item.include?(platform)} items.each_with_object({}) do |item, hash| key = normalize item[/^[^\/]+/] hash[key] = "#{base_url}/#{item}" end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
webdrivers-3.0.1 | lib/webdrivers/chromedriver.rb |
webdrivers-3.0.0 | lib/webdrivers/chromedriver.rb |
webdrivers-3.0.0.beta3 | lib/webdrivers/chromedriver.rb |