Created
December 1, 2011 19:33
-
-
Save ivaravko/1419219 to your computer and use it in GitHub Desktop.
Download file ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ok