modules/mu/master.rb in cloud-mu-3.2.0 vs modules/mu/master.rb in cloud-mu-3.3.0
- old
+ new
@@ -878,7 +878,28 @@
t.join
}
end
end
+ # Recursively zip a directory
+ # @param srcdir [String]
+ # @param outfile [String]
+ def self.zipDir(srcdir, outfile)
+ require 'zip'
+ ::Zip::File.open(outfile, ::Zip::File::CREATE) { |zipfile|
+ addpath = Proc.new { |zip_path, parent_path|
+ Dir.entries(parent_path).reject{ |d| [".", ".."].include?(d) }.each { |entry|
+ src = File.join(parent_path, entry)
+ dst = File.join(zip_path, entry).sub(/^\//, '')
+ if File.directory?(src)
+ addpath.call(dst, src)
+ else
+ zipfile.add(dst, src)
+ end
+ }
+ }
+ addpath.call("", srcdir)
+ }
+ end
+
end
end