class PodPrebuild::CacheFetcher

Attributes

cache_branch[R]

Public Class Methods

new(options) click to toggle source
Calls superclass method PodPrebuild::CommandExecutor::new
# File lib/command/executor/fetcher.rb, line 9
def initialize(options)
  super(options)
  @cache_branch = options[:cache_branch]
end

Public Instance Methods

run() click to toggle source
# File lib/command/executor/fetcher.rb, line 14
def run
  Pod::UI.step("Fetching cache") do
    if @config.local_cache?
      print_message_for_local_cache(@config.cache_path)
    else
      fetch_remote_cache(@config.cache_repo, @cache_branch, @config.cache_path)
    end
    unzip_cache
  end
end

Private Instance Methods

fetch_remote_cache(repo, branch, dest_dir) click to toggle source
# File lib/command/executor/fetcher.rb, line 37
def fetch_remote_cache(repo, branch, dest_dir)
  Pod::UI.puts "Fetching cache from #{repo} (branch: #{branch})".green
  if Dir.exist?(dest_dir + "/.git")
    git("fetch origin #{branch}")
    git("checkout -f FETCH_HEAD", ignore_output: true)
    git("branch -D #{branch}", ignore_output: true, can_fail: true)
    git("checkout -b #{branch}")
  else
    FileUtils.rm_rf(dest_dir)
    git_clone("--depth=1 --branch=#{branch} #{repo} #{dest_dir}")
  end
end
print_message_for_local_cache(cache_dir) click to toggle source
unzip_cache() click to toggle source
# File lib/command/executor/fetcher.rb, line 50
def unzip_cache
  Pod::UI.puts "Unzipping cache: #{@config.cache_path} -> #{@config.prebuild_sandbox_path}".green
  FileUtils.rm_rf(@config.prebuild_sandbox_path)
  FileUtils.mkdir_p(@config.prebuild_sandbox_path)

  if File.exist?(@config.manifest_path(in_cache: true))
    FileUtils.cp(
      @config.manifest_path(in_cache: true),
      @config.manifest_path
    )
  end
  zip_paths = Dir[@config.generated_frameworks_dir(in_cache: true) + "/*.zip"]
  Parallel.each(zip_paths, in_threads: 8) do |path|
    ZipUtils.unzip(path, to_dir: @config.generated_frameworks_dir)
  end
end