Created
January 7, 2011 17:44
-
-
Save barrettclark/769815 to your computer and use it in GitHub Desktop.
Example file download rake task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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