Skip to content

Instantly share code, notes, and snippets.

@doomspork
Created March 5, 2013 20:29
Show Gist options
  • Save doomspork/5093985 to your computer and use it in GitHub Desktop.
Save doomspork/5093985 to your computer and use it in GitHub Desktop.
Example Rake task for downloading and unzipping a file. Usage: rake 'pull[remote_file, local_file]'
require 'net/http'
require 'zipruby'
task :pull, :remote_path, :output_file do |t, args|
uri = URI(args[:remote_path])
data = Net::HTTP.get(uri)
Zip::Archive.open_buffer(data) do |z|
z.fopen(z.get_name(0)) do |e|
File.open(args[:output_file], 'w') do |f|
f.write e.read
end
end
end
end
#!/usr/bin/env rake
Dir.glob('*.rake').each { |r| import r }
#!/usr/bin/env rake
Dir.glob('*.rake').each { |r| import r }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment