Class: Pod::Installer::ProjectCache::ProjectInstallationCache

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/project_cache/project_installation_cache.rb

Overview

Represents the cache stored at Pods/.project/installation_cache

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache_key_by_target_label = {}, build_configurations = nil, project_object_version = nil) ⇒ ProjectInstallationCache

Initializes a new instance.


30
31
32
33
34
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 30

def initialize(cache_key_by_target_label = {}, build_configurations = nil, project_object_version = nil)
  @cache_key_by_target_label = cache_key_by_target_label
  @build_configurations = build_configurations
  @project_object_version = project_object_version
end

Instance Attribute Details

#build_configurationsHash{String => Symbol} (readonly)


17
18
19
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 17

def build_configurations
  @build_configurations
end

#cache_key_by_target_labelHash{String => TargetCacheKey} (readonly)


12
13
14
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 12

def cache_key_by_target_label
  @cache_key_by_target_label
end

#project_object_versionInteger (readonly)


22
23
24
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 22

def project_object_version
  @project_object_version
end

Class Method Details

.from_file(sandbox, path) ⇒ Object


53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 53

def self.from_file(sandbox, path)
  return ProjectInstallationCache.new unless File.exist?(path)
  contents = YAMLHelper.load_file(path)
  cache_keys = contents.fetch('CACHE_KEYS', {})
  cache_key_by_target_label = Hash[cache_keys.map do |name, key_hash|
    [name, TargetCacheKey.from_cache_hash(sandbox, key_hash)]
  end]
  project_object_version = contents['OBJECT_VERSION']
  build_configurations = contents['BUILD_CONFIGURATIONS']
  ProjectInstallationCache.new(cache_key_by_target_label, build_configurations, project_object_version)
end

Instance Method Details

#save_as(path) ⇒ Object


48
49
50
51
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 48

def save_as(path)
  Pathname(path).dirname.mkpath
  Sandbox.update_changed_file(path, YAMLHelper.convert(to_hash))
end

#to_hashObject


65
66
67
68
69
70
71
72
73
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 65

def to_hash
  cache_key_contents = Hash[cache_key_by_target_label.map do |label, key|
    [label, key.to_h]
  end]
  contents = { 'CACHE_KEYS' => cache_key_contents }
  contents['BUILD_CONFIGURATIONS'] = build_configurations if build_configurations
  contents['OBJECT_VERSION'] = project_object_version if project_object_version
  contents
end

#update_build_configurations!(build_configurations) ⇒ Object


40
41
42
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 40

def update_build_configurations!(build_configurations)
  @build_configurations = build_configurations
end

#update_cache_key_by_target_label!(cache_key_by_target_label) ⇒ Object


36
37
38
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 36

def update_cache_key_by_target_label!(cache_key_by_target_label)
  @cache_key_by_target_label = cache_key_by_target_label
end

#update_project_object_version!(project_object_version) ⇒ Object


44
45
46
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 44

def update_project_object_version!(project_object_version)
  @project_object_version = project_object_version
end