Skip to content

Instantly share code, notes, and snippets.

@SpencerCooley
Created April 20, 2013 23:41
Show Gist options
  • Save SpencerCooley/5427848 to your computer and use it in GitHub Desktop.
Save SpencerCooley/5427848 to your computer and use it in GitHub Desktop.
require 'zip/zip'
the_file = 'Nectir.zip'
the_directory = './directory'
def unzip(zip, unzip_dir, remove_after = false)
Zip::ZipFile.open(zip) do |zip_file|
zip_file.each do |f|
f_path=File.join(unzip_dir, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.extract(f, f_path) unless File.exist?(f_path)
end
end
FileUtils.rm(zip) if remove_after
end
unzip(the_file ,the_directory, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment