class CarthageCacheRes::Archiver

Attributes

executor[R]

Public Class Methods

new(executor = ShellCommandExecutor.new) click to toggle source
# File lib/carthage_cache_res/archiver.rb, line 7
def initialize(executor = ShellCommandExecutor.new)
  @executor = executor
end

Public Instance Methods

archive(archive_path, destination_path, &filter_block) click to toggle source
# File lib/carthage_cache_res/archiver.rb, line 11
def archive(archive_path, destination_path, &filter_block)
  files = Dir.entries(archive_path).select { |x| !x.start_with?(".") }
  files = files.select(&filter_block) if filter_block
  files = files.sort_by(&:downcase)
  executor.execute("cd #{archive_path} && zip -r -X #{File.expand_path(destination_path)} #{files.join(' ')} > /dev/null")
end
unarchive(archive_path, destination_path) click to toggle source
# File lib/carthage_cache_res/archiver.rb, line 18
def unarchive(archive_path, destination_path)
  executor.execute("unzip -o #{archive_path} -d #{destination_path} > /dev/null")
end