# Download the given URI object to <outfile_name>.
# Should use the progress_proc parameter to show
# a progress bar using the Ruby/ProgressBar library.
# Download the given URI object to <outfile_name>.
# Should use the progress_proc parameter to show
# a progress bar using the Ruby/ProgressBar library.
# We wrap the whole thing in a begin/rescue so that
# we can clean up afterwards in case of an error.
begin
File.open(outfile_name, 'wb') do |outfile|
pbar = nil
# We wrap the whole thing in a begin/rescue so that
# we can clean up afterwards in case of an error.
begin
File.open(outfile_name, 'wb') do |outfile|
pbar = nil
- uri.open(:content_length_proc => lambda {|content_length|
- if content_length && (0 < content_length)
+ uri.open({:content_length_proc => lambda {|content_length|
+ if content_length && (0 < content_length)
pbar = ProgressBar.new("Download", content_length)
pbar.instance_eval { @bar_mark = '=' }
pbar.file_transfer_mode
pbar = ProgressBar.new("Download", content_length)
pbar.instance_eval { @bar_mark = '=' }
pbar.file_transfer_mode