Skip to content

Instantly share code, notes, and snippets.

@barrettclark
Created January 7, 2011 17:44
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save barrettclark/769815 to your computer and use it in GitHub Desktop.
Save barrettclark/769815 to your computer and use it in GitHub Desktop.
Example file download rake task
require 'rake'
# http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html
require 'net/http'
desc "this is a test"
task :testing_rake do
puts "Hello from rake!"
end
namespace :remote_file do
desc "Get a file from a remote server"
task :fetch do
# based on http://snippets.dzone.com/posts/show/2469
# http://farm1.static.flickr.com/92/218926700_ecedc5fef7_o.jpg
Net::HTTP.start("farm1.static.flickr.com") do |http|
resp = http.get("/92/218926700_ecedc5fef7_o.jpg")
open("fun.jpg", "w") { |file| file.write(resp.body) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment