class CarthageCache::Application

Constants

CACHE_DIR_NAME

Attributes

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

Public Class Methods

new(project_path, verbose, config, repository: AWSRepository, terminal: Terminal, swift_version_resolver: SwiftVersionResolver) click to toggle source
# File lib/carthage_cache/application.rb, line 15
def initialize(project_path, verbose, config, repository: AWSRepository, terminal: Terminal, swift_version_resolver: SwiftVersionResolver)
  @terminal = terminal.new(verbose)
  @archiver = Archiver.new
  @config = Configurator.new(@terminal, project_path, config).config
  clazz = @config.read_only? ? HTTPRepository : repository
  @repository = clazz.new(@config.bucket_name, @config.hash_object[:aws_s3_client_options])
  @project = Project.new(project_path, CACHE_DIR_NAME, @config.archive_base_path, @terminal, @config.tmpdir, swift_version_resolver.new)
end

Public Instance Methods

archive_exist?() click to toggle source
# File lib/carthage_cache/application.rb, line 24
def archive_exist?
  repository.archive_exist?(project.archive_path)
end
create_archive(force = false, prune = nil, prune_white_list = nil, platforms = nil) click to toggle source
# File lib/carthage_cache/application.rb, line 38
def create_archive(force = false, prune = nil, prune_white_list = nil, platforms = nil)
  prune ||= config.prune_on_publish
  platforms ||= config.platforms
  prune_white_list ||= config.prune_white_list

  if force || !archive_exist?
    carthage_cache_lock.write_lock_digest(project.archive_key)
    prune_build_directory(prune_white_list) if prune
    archive_builder.build(platforms)
  end
end
install_archive() click to toggle source
# File lib/carthage_cache/application.rb, line 28
def install_archive
  if archive_exist?
    archive_installer.install
    true
  else
    terminal.puts "There is no cached archive for the current Cartfile.resolved file."
    false
  end
end
prune_build_directory(white_list) click to toggle source
# File lib/carthage_cache/application.rb, line 50
def prune_build_directory(white_list)
  white_list ||= config.prune_white_list

  if white_list && File.exist?(white_list)
    terminal.vputs "Pruning build directory with white list '#{white_list}' ..."
    white_list = YAML.load(File.read(white_list))
  else
    white_list = {}
    terminal.vputs "Pruning build directory ..."
  end
  build_collector.delete_unused_frameworks(white_list)
end
validate_installation() click to toggle source
# File lib/carthage_cache/application.rb, line 63
def validate_installation
  if carthage_cache_lock.valid_digest?(project.archive_key)
    terminal.puts "Your installation is valid."
    true
  else
    terminal.puts "Your current Carthage digest '#{project.archive_key}' does not match digest '#{carthage_cache_lock.lock_digest}' in '#{carthage_cache_lock.lock_file_path}'"
    false
  end
end

Private Instance Methods

archive_builder() click to toggle source
# File lib/carthage_cache/application.rb, line 79
def archive_builder
  @archive_builder ||= ArchiveBuilder.new(terminal, repository, archiver, project)
end
archive_installer() click to toggle source
# File lib/carthage_cache/application.rb, line 75
def archive_installer
  @archive_installer ||= ArchiveInstaller.new(terminal, repository, archiver, project)
end
build_collector() click to toggle source
# File lib/carthage_cache/application.rb, line 83
def build_collector
  @build_collector ||= BuildCollector.new(terminal, project.carthage_build_directory, project.all_frameworks)
end
carthage_cache_lock() click to toggle source
# File lib/carthage_cache/application.rb, line 87
def carthage_cache_lock
  @carthage_cache_lock ||= CarthageCacheLock.new(project.carthage_build_directory)
end