Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Another more concise way to add a directory recursively to a zip file #66

Closed
brendon opened this Issue Nov 21, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

brendon commented Nov 21, 2012

I've discovered this technique for recursively adding a directory to a zip file:

http://grosser.it/2009/02/04/compressing-a-folder-to-a-zip-archive-with-ruby/

The essence of it is:

Dir["#{path}/**/**"].each do |file|
  zipfile.add(file.sub(path+'/',''),file)
end

This loops over every entry in the subdirectory (recursively) and adds it in replicating the directory names in the zip file. Thought it would make for a more concise example in your samples section.

Owner

simonoff commented Apr 13, 2013

You can fork, add samles/doc entries and make pull request.

@simonoff simonoff closed this Aug 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment