Method: AsProject::AbstractRemoteFileTask#get_remote_file
- Defined in:
- lib/tasks/remote_file_task.rb
#get_remote_file(uri, target) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/tasks/remote_file_task.rb', line 135 def get_remote_file(uri, target) if(!File.exists?(target)) puts "Fetching #{uri.to_s} into #{target} now!" response = fetch(uri.to_s) File.makedirs(File.dirname(target)) # Store the downloaded file on disk File.open(target, 'wb') do |f| f.write(response.body) end puts "" puts "Downloaded #{(response.body.size / 1024).to_s} KB" puts "to: #{target}" puts "" end end |