Class: Pod::Installer::ProjectCache::ProjectMetadataCache
- Inherits:
-
Object
- Object
- Pod::Installer::ProjectCache::ProjectMetadataCache
- Defined in:
- lib/cocoapods/installer/project_cache/project_metadata_cache.rb
Overview
Represents the metadata cache
Instance Attribute Summary collapse
-
#sandbox ⇒ Sandbox
readonly
The sandbox where the Pods should be installed.
-
#target_label_by_metadata ⇒ Hash{String => TargetMetadata}
readonly
Hash of string by target metadata.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(sandbox, target_label_by_metadata = {}) ⇒ ProjectMetadataCache
constructor
Initialize a new instance.
-
#save_as(path) ⇒ void
Rewrites the entire cache to the given path.
- #to_hash ⇒ Object
-
#update_metadata!(pod_target_installation_results, aggregate_target_installation_results) ⇒ Object
Updates the metadata cache based on installation results.
Constructor Details
#initialize(sandbox, target_label_by_metadata = {}) ⇒ ProjectMetadataCache
Initialize a new instance.
23 24 25 26 |
# File 'lib/cocoapods/installer/project_cache/project_metadata_cache.rb', line 23 def initialize(sandbox, = {}) @sandbox = sandbox @target_label_by_metadata = end |
Instance Attribute Details
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox where the Pods should be installed.
11 12 13 |
# File 'lib/cocoapods/installer/project_cache/project_metadata_cache.rb', line 11 def sandbox @sandbox end |
#target_label_by_metadata ⇒ Hash{String => TargetMetadata} (readonly)
Returns Hash of string by target metadata.
16 17 18 |
# File 'lib/cocoapods/installer/project_cache/project_metadata_cache.rb', line 16 def @target_label_by_metadata end |
Class Method Details
.from_file(sandbox, path) ⇒ Object
64 65 66 67 68 69 |
# 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) = Hash[contents.map { |target_label, hash| [target_label, TargetMetadata.from_hash(hash)] }] ProjectMetadataCache.new(sandbox, ) end |
Instance Method Details
#save_as(path) ⇒ void
This method returns an undefined value.
Rewrites the entire cache to the given path.
40 41 42 |
# 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 ⇒ Object
28 29 30 31 32 |
# File 'lib/cocoapods/installer/project_cache/project_metadata_cache.rb', line 28 def to_hash Hash[.map do |target_label, metdata| [target_label, metdata.to_hash] end] end |
#update_metadata!(pod_target_installation_results, aggregate_target_installation_results) ⇒ Object
Updates the metadata cache based on installation results.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cocoapods/installer/project_cache/project_metadata_cache.rb', line 52 def (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 [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| [app_target.name] = TargetMetadata.from_native_target(sandbox, app_target) end end end |