Created
March 5, 2013 20:29
-
-
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]'
This file contains 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 '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 |
This file contains 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
#!/usr/bin/env rake | |
Dir.glob('*.rake').each { |r| import r } |
This file contains 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
#!/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