I have a ruby bash script to download a zip file and output a progress bar to the stdout. I have the following
# Temp file name
tmp = ActiveSupport::SecureRandom.hex(8)
file = temp_dl_dir+tmp+'.zip'
print file.inspect
# Download
progress_bar = nil
open(file, 'w', :content_length_proc => lambda { |length|
if length && 0 < length
progress_bar = ProgressBar.new('...', length)
progress_bar.file_transfer_mode
end
},
:progress_proc => lambda { |progress|
progress_bar.set(progress) if progress_bar
}) do |fo|
fo.print open(dl).read
end
But when I run it I get
open-uri.rb:32:in `initialize': can't convert Hash into Integer (TypeError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:32:in `open_uri_original_open'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/open-uri.rb:32:in `open'
from ./site.rb:191 (line 191 is the open(file, 'w' ...) one)
Which means there is a problem with my open(file, 'w' ... function
I can't figure out what's wrong +_+
def is_dir?(directory)