class CarthageCacheRes::ArchiveBuilder

Attributes

archiver[R]
project[R]
repository[R]
terminal[R]

Public Class Methods

new(terminal, repository, archiver, project) click to toggle source
# File lib/carthage_cache_res/archive_builder.rb, line 10
def initialize(terminal, repository, archiver, project)
  @terminal = terminal
  @repository = repository
  @archiver = archiver
  @project = project
end

Public Instance Methods

build(platforms = nil) click to toggle source
# File lib/carthage_cache_res/archive_builder.rb, line 17
def build(platforms = nil)
  archive_path = archive(platforms)
  upload_archive(archive_path)
  # TODO check if some old archives can be deleted
  # I would store the last N archives and then delete
  # the rest
end

Private Instance Methods

archive(platforms = nil) click to toggle source
# File lib/carthage_cache_res/archive_builder.rb, line 27
def archive(platforms = nil)
  archive_path = File.join(project.tmpdir, project.archive_filename)
  if platforms
    terminal.puts "Archiving Carthage build directory for #{platforms.join(',')} platforms."
  else
    terminal.puts "Archiving Carthage build directory for all platforms."
  end

  filter_block = nil
  if platforms
    filter_block = ->(file) do
      lock_file?(file) || platforms.map(&:downcase).include?(file.downcase)
    end
  end

  archiver.archive(project.carthage_build_directory, archive_path, &filter_block)
  archive_path
end
lock_file?(file) click to toggle source
# File lib/carthage_cache_res/archive_builder.rb, line 51
def lock_file?(file)
  file == CarthageCacheResLock::LOCK_FILE_NAME
end
upload_archive(archive_path) click to toggle source
# File lib/carthage_cache_res/archive_builder.rb, line 46
def upload_archive(archive_path)
  terminal.puts "Uploading archive with key '#{project.archive_key}'."
  repository.upload(project.archive_path, archive_path)
end