class Pod::Installer::ProjectCache::ProjectMetadataCache
Represents the metadata cache
Attributes
sandbox[R]
@return [Sandbox] The sandbox where the Pods should be installed.
target_label_by_metadata[R]
@return [Hash{String => TargetMetadata}]
Hash of string by target metadata.
Public Class Methods
from_file(sandbox, path)
click to toggle source
# File lib/cocoapods/installer/project_cache/project_metadata_cache.rb, line 64 def self.from_file(sandbox, path) return ProjectMetadataCache.new(sandbox) unless File.exist?(path) contents = YAMLHelper.load_file(path) target_by_label_metadata = Hash[contents.map { |target_label, hash| [target_label, TargetMetadata.from_hash(hash)] }] ProjectMetadataCache.new(sandbox, target_by_label_metadata) end
new(sandbox, target_label_by_metadata = {})
click to toggle source
Initialize a new instance.
@param [Sandbox] sandbox see sandbox
@param [Hash{String => TargetMetadata}] target_label_by_metadata
@see target_label_by_metadata
# File lib/cocoapods/installer/project_cache/project_metadata_cache.rb, line 23 def initialize(sandbox, target_label_by_metadata = {}) @sandbox = sandbox @target_label_by_metadata = target_label_by_metadata end
Public Instance Methods
save_as(path)
click to toggle source
Rewrites the entire cache to the given path.
@param [String] path
@return [void]
# File lib/cocoapods/installer/project_cache/project_metadata_cache.rb, line 40 def save_as(path) Sandbox.update_changed_file(path, YAMLHelper.convert_hash(to_hash, nil)) end
to_hash()
click to toggle source
# File lib/cocoapods/installer/project_cache/project_metadata_cache.rb, line 28 def to_hash Hash[target_label_by_metadata.map do |target_label, metdata| [target_label, metdata.to_hash] end] end
update_metadata!(pod_target_installation_results, aggregate_target_installation_results)
click to toggle source
Updates the metadata cache based on installation results.
@param [Hash{String => TargetInstallationResult}] pod_target_installation_results
The installation results for pod targets installed.
@param [Hash{String => TargetInstallationResult}] aggregate_target_installation_results
The installation results for aggregate targets installed.
# File lib/cocoapods/installer/project_cache/project_metadata_cache.rb, line 52 def update_metadata!(pod_target_installation_results, aggregate_target_installation_results) installation_results = pod_target_installation_results.values + aggregate_target_installation_results.values installation_results.each do |installation_result| native_target = installation_result.native_target target_label_by_metadata[native_target.name] = TargetMetadata.from_native_target(sandbox, native_target) # app targets need to be added to the cache because they can be used as app hosts for test targets, even if those test targets live inside a different pod (and thus project) installation_result.app_native_targets.each_value do |app_target| target_label_by_metadata[app_target.name] = TargetMetadata.from_native_target(sandbox, app_target) end end end