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, podfile_plugins = {}, installation_options = {}) ⇒ ProjectInstallationCache

Initializes a new instance.

Parameters:

  • cache_key_by_target_label (Hash{String => TargetCacheKey}) (defaults to: {})

    @see #cache_key_by_target_label

  • build_configurations (Hash{String => Symbol}) (defaults to: nil)

    @see #build_configurations

  • project_object_version (Integer) (defaults to: nil)

    @see #project_object_version

  • podfile_plugins (Hash<String, Hash>) (defaults to: {})

    @see #podfile_plugins

  • installation_options (Hash<Symbol, Object>) (defaults to: {})

    @see #installation_options


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

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

Instance Attribute Details

#build_configurationsHash{String => Symbol} (readonly)

Returns Build configurations stored in the cache.

Returns:

  • (Hash{String => Symbol})

    Build configurations stored in the cache.


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)

Returns Stored hash of target cache key objects for every pod target.

Returns:

  • (Hash{String => TargetCacheKey})

    Stored hash of target cache key objects for every pod target.


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

#installation_optionsHash<Symbol, Object> (readonly)

Returns Configured installation options.

Returns:

  • (Hash<Symbol, Object>)

    Configured installation options


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

def installation_options
  @installation_options
end

#podfile_pluginsHash<String, Hash> (readonly)

Returns Podfile plugins used with a particular install.

Returns:

  • (Hash<String, Hash>)

    Podfile plugins used with a particular install.


27
28
29
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 27

def podfile_plugins
  @podfile_plugins
end

#project_object_versionInteger (readonly)

Returns Project object stored in the cache.

Returns:

  • (Integer)

    Project object stored in the cache.


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


75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 75

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']
  podfile_plugins = contents['PLUGINS']
  installation_options = contents['INSTALLATION_OPTIONS']
  ProjectInstallationCache.new(cache_key_by_target_label, build_configurations, project_object_version, podfile_plugins, installation_options)
end

Instance Method Details

#save_as(path) ⇒ Object


70
71
72
73
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 70

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

#to_hashObject


89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 89

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['PLUGINS'] = podfile_plugins if podfile_plugins
  contents['INSTALLATION_OPTIONS'] = installation_options if installation_options
  contents
end

#update_build_configurations!(build_configurations) ⇒ Object


54
55
56
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 54

def update_build_configurations!(build_configurations)
  @build_configurations = build_configurations
end

#update_cache_key_by_target_label!(cache_key_by_target_label) ⇒ Object


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

def update_cache_key_by_target_label!(cache_key_by_target_label)
  @cache_key_by_target_label = cache_key_by_target_label
end

#update_installation_options!(installation_options) ⇒ Object


66
67
68
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 66

def update_installation_options!(installation_options)
  @installation_options = installation_options
end

#update_podfile_plugins!(podfile_plugins) ⇒ Object


62
63
64
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 62

def update_podfile_plugins!(podfile_plugins)
  @podfile_plugins = podfile_plugins
end

#update_project_object_version!(project_object_version) ⇒ Object


58
59
60
# File 'lib/cocoapods/installer/project_cache/project_installation_cache.rb', line 58

def update_project_object_version!(project_object_version)
  @project_object_version = project_object_version
end