Since downloading a .zip is easier then explaining how to git clone something, i packed my programming pearls in ruby book into a nice little .zip file.
Original folder — resulting zip
def compress(path) gem 'rubyzip' require 'zip/zip' require 'zip/zipfilesystem' path.sub!(%r[/$],'') archive = File.join(path,File.basename(path))+'.zip' FileUtils.rm archive, :force=>true Zip::ZipFile.open(archive, 'w') do |zipfile| Dir["#{path}/**/**"].reject{|f|f==archive}.each do |file| zipfile.add(file.sub(path+'/',''),file) end end end
Hi, here’s my take to the problem : http://ruby-indah-elegan.blogspot.com/2008/12/zipping-folders-in-folder-ruby-script.html
GIST: http://gist.github.com/41921
seems to compress all folders in a directory by using installed zip library, definitely fewer LOC, only requires zip is installed.
Ill give it a try and see if it works…
Hi, sorry for not being concise.
I’ve used it in Ubuntu box that has standard zip command installed.
Kind of like http://jamesit.wordpress.com/2008/12/04/7-zipping-multiple-folders-to-individual-ziparchive-files/ but with Ruby flavors 🙂