Skip to content
Browse files

Use new Chromedriver download url

We now pull the latest release version
  • Loading branch information...
1 parent b47e93c commit ecd8ea41b7d419c2a2acb4ed3dd9aefa3f623c9a @ismell ismell committed Dec 16, 2013
Showing with 16 additions and 15 deletions.
  1. +11 −10 lib/chromedriver/helper.rb
  2. +5 −5 lib/chromedriver/helper/google_code_parser.rb
View
21 lib/chromedriver/helper.rb
@@ -6,7 +6,7 @@
module Chromedriver
class Helper
- DOWNLOAD_URL = "http://code.google.com/p/chromedriver/downloads/list?can=4"
+ DOWNLOAD_URL = "http://chromedriver.storage.googleapis.com"
def run *args
download
@@ -18,12 +18,12 @@ def download hit_network=false
url = download_url
filename = File.basename url
Dir.chdir platform_install_dir do
- unless File.exists? filename
- system("wget -c -O #{filename} #{url}") || system("curl -C - -o #{filename} #{url}")
- raise "Could not download #{url}" unless File.exists? filename
- system "unzip -o #{filename}"
- end
+ system(*%W[wget -c -O #{filename} #{url}]) || system(*%W[curl -C - -o #{filename} #{url}])
+ raise "Could not download #{url}" unless File.exists? filename
+
+ system *%W[unzip -o #{filename}]
end
+
raise "Could not unzip #{filename} to get #{binary_path}" unless File.exists? binary_path
end
@@ -33,8 +33,9 @@ def update
def download_url
downloads = GoogleCodeParser.new(open(DOWNLOAD_URL)).downloads
- url = downloads.grep(/chromedriver2_#{platform}_0\.9.*\.zip/).last
- url = "http:#{url}" if url !~ /^http/
+ downloads = downloads.grep(/^[\d\.]+\/chromedriver_#{platform}\.zip$/).sort_by{|_| /^([\d\.]+)/.match(_) && Gem::Version.new($1)}
+ url = downloads.last
+ url = "#{DOWNLOAD_URL}/#{url}"
url
end
@@ -59,8 +60,8 @@ def platform
case cfg['host_os']
when /linux/ then
cfg['host_cpu'] =~ /x86_64|amd64/ ? "linux64" : "linux32"
- when /darwin/ then "mac"
- else "win"
+ when /darwin/ then "mac32"
+ else "win32"
end
end
end
View
10 lib/chromedriver/helper/google_code_parser.rb
@@ -3,15 +3,15 @@
module Chromedriver
class Helper
class GoogleCodeParser
- attr_reader :html
+ attr_reader :xml
- def initialize html
- @html = html
+ def initialize xml
+ @xml= xml
end
def downloads
- doc = Nokogiri::HTML html
- doc.css("td.vt a[@title=Download]").collect {|_| _["href"]}
+ doc = Nokogiri::XML xml
+ doc.search("Contents Key").collect {|_| _.content}
end
end
end

0 comments on commit ecd8ea4

Please sign in to comment.
Something went wrong with that request. Please try again.