class Roger::Release::Finalizers::Zip

The zip finalizer

Public Instance Methods

default_options() click to toggle source

@option options [String] :prefix Prefix to put before the version (default = “html”) @option options [String] :zip The zip command @option options [String, Pathname] :target_path (release.target_path) The path to zip to

# File lib/roger/release/finalizers/zip.rb, line 10
def default_options
  {
    zip: "zip",
    prefix: "html",
    target_path: release.target_path
  }
end
perform() click to toggle source
# File lib/roger/release/finalizers/zip.rb, line 18
def perform
  target_path = ensure_target_path(@options[:target_path])

  name = [options[:prefix], @release.scm.version].join("-") + ".zip"
  zip_path = target_path + name

  @release.log(self, "Finalizing release to #{zip_path}")

  cleanup_existing_zip(zip_path)

  check_zip_command(@options[:zip])

  ::Dir.chdir(@release.build_path) do
    `#{@options[:zip]} -r -9 "#{zip_path}" ./*`
  end
end

Protected Instance Methods

check_zip_command(command) click to toggle source
# File lib/roger/release/finalizers/zip.rb, line 50
def check_zip_command(command)
  `#{command} -v`
rescue Errno::ENOENT
  raise "Could not find zip in #{command.inspect}"
end
cleanup_existing_zip(path) click to toggle source
# File lib/roger/release/finalizers/zip.rb, line 43
def cleanup_existing_zip(path)
  return unless File.exist?(path)

  release.log(self, "Removing existing target #{path}")
  FileUtils.rm_rf(path)
end
ensure_target_path(path) click to toggle source
# File lib/roger/release/finalizers/zip.rb, line 37
def ensure_target_path(path)
  target_path = Pathname.new(path)
  FileUtils.mkdir_p(target_path) unless target_path.exist?
  target_path
end