Sha256: 389429cfb9dc6d72c65c0a03eb7b660b2f75919f787c313e0e0add5878884627
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module Capistrano module Middleman module Utils def zip( source_directory, destination_file, prefix: nil, working_directory: Dir.getwd, exclude_patterns: [], keep_filesystem_permissions: false, file_permissions: 0664, directory_permissions: 2775 ) list = Rake::FileList.new(File.join(source_directory, '**', '*')) list.exclude { |f| !File.file? f } exclude_patterns.each { |e| list.exclude e } Zip::File.open(destination_file, Zip::File::CREATE) do |z| list.each do |filename| paths = [] paths << Pathname.new(prefix) unless prefix.nil? || prefix.empty? paths << Pathname.new(filename).relative_path_from(Pathname.new(working_directory)) z.add(File.join(*paths), File.expand_path(filename)) next if keep_filesystem_permissions z.file.chmod(file_permissions , File.join(*paths)) if z.file.file? File.join(*paths) z.file.chmod(directory_permissions, File.join(*paths)) if z.file.directory? File.join(*paths) end end end module_function :zip end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-middleman-0.1.0 | lib/capistrano/middleman/utils.rb |