Class: Pod::Installer::ProjectCache::ProjectMetadataCache

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

Overview

Represents the metadata cache

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sandbox, target_label_by_metadata = {}) ⇒ ProjectMetadataCache

Initialize a new instance.

Parameters:

  • sandbox (Sandbox)

    see #sandbox

  • target_label_by_metadata (Hash{String => TargetMetadata}) (defaults to: {})

    @see #target_label_by_metadata


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

#sandboxSandbox (readonly)

Returns The sandbox where the Pods should be installed.

Returns:

  • (Sandbox)

    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_metadataHash{String => TargetMetadata} (readonly)

Returns Hash of string by target metadata.

Returns:

  • (Hash{String => TargetMetadata})

    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


60
61
62
63
64
65
# File 'lib/cocoapods/installer/project_cache/project_metadata_cache.rb', line 60

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.

Parameters:

  • path (String)

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_hashObject


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.

Parameters:

  • pod_target_installation_results (Hash{String => TargetInstallationResult})

    The installation results for pod targets installed.

  • aggregate_target_installation_results (Hash{String => TargetInstallationResult})

    The installation results for aggregate targets installed.


52
53
54
55
56
57
58
# 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
    [native_target.name] = TargetMetadata.from_native_target(sandbox, native_target)
  end
end