Skip to content

Commit

Permalink
rb - fix unwanted private method classification
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jun 8, 2016
1 parent 5827d7b commit d00ae13
Showing 1 changed file with 56 additions and 54 deletions.
110 changes: 56 additions & 54 deletions rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,59 +66,74 @@ def self.get(required_version, opts = {})
# Download the given version of the selenium-server-standalone jar.
#

def self.download(required_version)
required_version = latest if required_version == :latest
download_file_name = "selenium-server-standalone-#{required_version}.jar"
class << self
def download(required_version)
required_version = latest if required_version == :latest
download_file_name = "selenium-server-standalone-#{required_version}.jar"

if File.exists? download_file_name
return download_file_name
end
if File.exists? download_file_name
return download_file_name
end

begin
open(download_file_name, "wb") do |destination|
net_http.start("selenium-release.storage.googleapis.com") do |http|
resp = http.request_get("/#{required_version[/(\d+\.\d+)\./, 1]}/#{download_file_name}") do |response|
total = response.content_length
progress = 0
segment_count = 0

response.read_body do |segment|
progress += segment.length
segment_count += 1

if segment_count % 15 == 0
percent = (progress.to_f / total.to_f) * 100
print "#{CL_RESET}Downloading #{download_file_name}: #{percent.to_i}% (#{progress} / #{total})"
segment_count = 0
begin
open(download_file_name, "wb") do |destination|
net_http.start("selenium-release.storage.googleapis.com") do |http|
resp = http.request_get("/#{required_version[/(\d+\.\d+)\./, 1]}/#{download_file_name}") do |response|
total = response.content_length
progress = 0
segment_count = 0

response.read_body do |segment|
progress += segment.length
segment_count += 1

if segment_count % 15 == 0
percent = (progress.to_f / total.to_f) * 100
print "#{CL_RESET}Downloading #{download_file_name}: #{percent.to_i}% (#{progress} / #{total})"
segment_count = 0
end

destination.write(segment)
end

destination.write(segment)
end
end

unless resp.kind_of? Net::HTTPSuccess
raise Error, "#{resp.code} for #{download_file_name}"
unless resp.kind_of? Net::HTTPSuccess
raise Error, "#{resp.code} for #{download_file_name}"
end
end
end
rescue
FileUtils.rm download_file_name if File.exists? download_file_name
raise
end
rescue
FileUtils.rm download_file_name if File.exists? download_file_name
raise

download_file_name
end

download_file_name
end
#
# Ask Google Code what the latest selenium-server-standalone version is.
#

#
# Ask Google Code what the latest selenium-server-standalone version is.
#
def latest
require 'rexml/document'
net_http.start("selenium-release.storage.googleapis.com") do |http|
REXML::Document.new(http.get("/").body).root.get_elements("//Contents/Key").map { |e|
e.text[/selenium-server-standalone-(\d+\.\d+\.\d+)\.jar/, 1]
}.compact.max
end
end

def net_http
http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']

if http_proxy
http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?("http://")
uri = URI.parse(http_proxy)

def self.latest
require 'rexml/document'
net_http.start("selenium-release.storage.googleapis.com") do |http|
REXML::Document.new(http.get("/").body).root.get_elements("//Contents/Key").map { |e|
e.text[/selenium-server-standalone-(\d+\.\d+\.\d+)\.jar/, 1]
}.compact.max
Net::HTTP::Proxy(uri.host, uri.port)
else
Net::HTTP
end
end
end

Expand Down Expand Up @@ -204,19 +219,6 @@ def <<(arg)

private

def self.net_http
http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']

if http_proxy
http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?("http://")
uri = URI.parse(http_proxy)

Net::HTTP::Proxy(uri.host, uri.port)
else
Net::HTTP
end
end

def stop_process
return unless @process.alive?

Expand Down

0 comments on commit d00ae13

Please sign in to comment.