Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (39 sloc) 1.271 kb
# This Rake Task is a striped down version of Buildr download task
# I took the code from
# I've striped down dependencies on Net::SSH and Facets to
# stay as simple as possible.
# Original code from Assaf Arkin, released under Apache License
# (
require 'rake'
require 'tempfile'
require File.join(File.dirname(__FILE__), 'contrib', 'uri_ext')
def download(args)
args = URI.parse(args) if args.is_a?(String)
options = {
:progress => true,
:verbose => Rake.application.options.trace
# Given only a download URL, download into a temporary file.
# You can infer the file from task name.
if URI === args
temp =
file_create(temp.path) do |task|
# Since temporary file exists, force a download.
class << task ; def needed?() ; true ; end ; end
task.sources << args
task.enhance {, options) }
# Download to a file task instead
fail unless args.keys.size == 1
uri = URI.parse(args.values.first.to_s)
file_create(args.keys.first) do |task|
task.sources << uri
task.enhance {, options) }
Jump to Line
Something went wrong with that request. Please try again.