Module: Jxedt::CacheFetcher

Defined in:
lib/cocoapods-jxedt/git_helper/cache_fetcher.rb

Class Method Summary collapse

Class Method Details

.fetchObject



3
4
5
6
7
8
9
10
11
# File 'lib/cocoapods-jxedt/git_helper/cache_fetcher.rb', line 3

def self.fetch
    require_relative 'git_command'
    repo = Jxedt.config.git_remote_repo
    cache_path = Jxedt.config.git_cache_path
    branch = Jxedt.config.cache_branch

    commander = Jxedt::GitCommand.new(cache_path)
    commander.git_fetch(repo, branch)
end

.sync(binary_hash, to_dir) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cocoapods-jxedt/git_helper/cache_fetcher.rb', line 13

def self.sync(binary_hash, to_dir)
    # fetch
    fetch
    
    require_relative 'zip'

    cache_dir = Pathname.new(Jxedt.config.git_cache_path) + "GeneratedFrameworks"
    to_dir = Pathname.new(to_dir)
    binary_hash.each do |name, checksum|
        zip_file = cache_dir + name + "#{checksum}.zip"
        next unless zip_file.exist?

        file_path = to_dir + name + "#{checksum}.checksum"
        next if file_path.exist? # 存在同校验和的文件,跳过
        file_path.parent.rmtree if file_path.parent.exist?

        Jxedt::ZipUtils.unzip(zip_file, :to_dir => to_dir)
        Pod::UI.puts "✅  已从缓存下载组件#{name}, 校验和:#{checksum}".yellow
    end            
end