Class: CarthageCacheRes::Application
- Inherits:
-
Object
- Object
- CarthageCacheRes::Application
- Defined in:
- lib/carthage_cache_res/application.rb
Constant Summary collapse
- CACHE_DIR_NAME =
"carthage_cache_res"
Instance Attribute Summary collapse
-
#archiver ⇒ Object
readonly
Returns the value of attribute archiver.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#terminal ⇒ Object
readonly
Returns the value of attribute terminal.
Instance Method Summary collapse
- #archive_exist? ⇒ Boolean
- #create_archive(force = false, prune = nil, prune_white_list = nil, platforms = nil) ⇒ Object
-
#initialize(project_path, verbose, config, repository: AWSRepository, terminal: Terminal, swift_version_resolver: SwiftVersionResolver) ⇒ Application
constructor
A new instance of Application.
- #install_archive ⇒ Object
- #prune_build_directory(white_list) ⇒ Object
- #validate_installation ⇒ Object
Constructor Details
#initialize(project_path, verbose, config, repository: AWSRepository, terminal: Terminal, swift_version_resolver: SwiftVersionResolver) ⇒ Application
Returns a new instance of Application.
15 16 17 18 19 20 21 22 |
# File 'lib/carthage_cache_res/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 |
Instance Attribute Details
#archiver ⇒ Object (readonly)
Returns the value of attribute archiver.
10 11 12 |
# File 'lib/carthage_cache_res/application.rb', line 10 def archiver @archiver end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/carthage_cache_res/application.rb', line 13 def config @config end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
12 13 14 |
# File 'lib/carthage_cache_res/application.rb', line 12 def project @project end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
11 12 13 |
# File 'lib/carthage_cache_res/application.rb', line 11 def repository @repository end |
#terminal ⇒ Object (readonly)
Returns the value of attribute terminal.
9 10 11 |
# File 'lib/carthage_cache_res/application.rb', line 9 def terminal @terminal end |
Instance Method Details
#archive_exist? ⇒ Boolean
24 25 26 |
# File 'lib/carthage_cache_res/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) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/carthage_cache_res/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_res_lock.write_lock_digest(project.archive_key) prune_build_directory(prune_white_list) if prune archive_builder.build(platforms) end end |
#install_archive ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/carthage_cache_res/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) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/carthage_cache_res/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 ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/carthage_cache_res/application.rb', line 63 def validate_installation if carthage_cache_res_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_res_lock.lock_digest}' in '#{carthage_cache_res_lock.lock_file_path}'" false end end |