Module: Makit::ZipUtility
- Defined in:
- lib/makit/zip_utility.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
-
.create_from_directory(source_dir:, zip_path:, exclude_pattern: "*.pdb") ⇒ Object
Creates a zip file from a directory, preserving directory structure.
Class Method Details
.create_from_directory(source_dir:, zip_path:, exclude_pattern: "*.pdb") ⇒ Object
Creates a zip file from a directory, preserving directory structure. Excludes files matching the exclude_pattern from the archive.
Examples:
Makit::ZipUtility.create_from_directory(
source_dir: "artifacts/Musco.Aim3.AspNet.Host",
zip_path: "artifacts/Musco.Aim3.AspNet.Host.zip"
)
Makit::ZipUtility.create_from_directory(
source_dir: "artifacts/build",
zip_path: "artifacts/build.zip",
exclude_pattern: "*.{pdb,log}"
)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/makit/zip_utility.rb', line 30 def self.create_from_directory(source_dir:, zip_path:, exclude_pattern: "*.pdb") source_dir = File.(source_dir) zip_path = File.(zip_path) unless Dir.exist?(source_dir) raise Error, "Source directory does not exist: #{source_dir}" end # Delete existing zip if it exists File.delete(zip_path) if File.exist?(zip_path) # Use RubyZip gem (cross-platform, no shell commands needed) create_zip_with_rubyzip(source_dir, zip_path, exclude_pattern) unless File.exist?(zip_path) raise Error, "Failed to create zip file: #{zip_path}" end zip_path end |