Skip to content

Instantly share code, notes, and snippets.

@ivaravko
Created December 1, 2011 19:33
Show Gist options
  • Select an option

  • Save ivaravko/1419219 to your computer and use it in GitHub Desktop.

Select an option

Save ivaravko/1419219 to your computer and use it in GitHub Desktop.
Download file ...
require 'net/http'
download_file_name = "selenium-server-standalone-2.14.0.jar"
begin
open(download_file_name, "wb") do |destination|
Net::HTTP.start("selenium.googlecode.com") do |http|
resp = http.request_get("/files/#{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 % 300 == 0
percent = (progress.to_f / total.to_f) * 100
print "#Downloading #{download_file_name}: #{percent.to_i}% (#{progress} / #{total}) \n"
segment_count = 0
end
destination.write(segment)
end
end
end
end
end
@ivaravko
Copy link
Copy Markdown
Author

ivaravko commented Dec 2, 2011

кошерней на руби

@dovg
Copy link
Copy Markdown

dovg commented Dec 4, 2011

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment