Sha256: 397569632d6a18499da8561677760950f839a34227eaff6b2ea591b812976554
Contents?: true
Size: 1.23 KB
Versions: 5
Compression:
Stored size: 1.23 KB
Contents
require "tempfile" module Buildr # Create a task that will download a file from a URL. # # Takes a single argument, a hash with one pair. The key is the file being # created, the value if the URL to download. The task executes only if the # file does not exist; the URL is not checked for updates. # # The task will show download progress on the console; if there are MD5/SHA1 # checksums on the server it will verify the download before saving it. # # For example: # download "image.jpg"=>"http://example.com/theme/image.jpg" def download(args) if String === args || URI === args # Given only a download URL, download into a temporary file. # You can infer the file from task name. temp = Tempfile.new(File.basename(args.to_s)) task = file_create(temp.path) do |task| Transports.download task.source, task.name end task.sources << args else # Download to a file created by the task. fail unless args.keys.size == 1 url = args.values.first task = file_create(args.keys.first) do |task| mkpath File.dirname(task.name), :verbose=>false Transports.download task.source, task.name end task.sources << url end task end end
Version data entries
5 entries across 5 versions & 2 rubygems
Version | Path |
---|---|
Buildr-0.17.0 | lib/tasks/download.rb |
buildr-0.14.0 | lib/tasks/download.rb |
buildr-0.15.0 | lib/tasks/download.rb |
buildr-0.16.0 | lib/tasks/download.rb |
buildr-0.18.0 | lib/tasks/download.rb |