Class: Pod::Installer::ProjectCache::TargetCacheKey
- Inherits:
-
Object
- Object
- Pod::Installer::ProjectCache::TargetCacheKey
- Defined in:
- lib/cocoapods/installer/project_cache/target_cache_key.rb
Overview
Uniquely identifies a Target.
Instance Attribute Summary collapse
-
#key_hash ⇒ Hash{String => Object}
readonly
The hash containing key-value pairs that identify the target.
-
#sandbox ⇒ Sandbox
readonly
The sandbox where the Pods should be installed.
-
#type ⇒ Symbol
readonly
The type of target.
Class Method Summary collapse
-
.from_aggregate_target(sandbox, aggregate_target) ⇒ TargetCacheKey
Construct a TargetCacheKey instance from an AggregateTarget.
-
.from_cache_hash(sandbox, key_hash) ⇒ TargetCacheKey
Creates a TargetCacheKey instance from the given hash.
-
.from_pod_target(sandbox, pod_target, is_local_pod: false, checkout_options: nil) ⇒ TargetCacheKey
Constructs a TargetCacheKey instance from a PodTarget.
Instance Method Summary collapse
-
#initialize(sandbox, type, key_hash) ⇒ TargetCacheKey
constructor
Initialize a new instance.
-
#key_difference(other) ⇒ Symbol
Equality function used to compare TargetCacheKey objects to each other.
-
#project_name ⇒ String
The name of the project the target belongs to.
- #to_h ⇒ Object
Constructor Details
#initialize(sandbox, type, key_hash) ⇒ TargetCacheKey
Initialize a new instance.
31 32 33 34 35 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 31 def initialize(sandbox, type, key_hash) @sandbox = sandbox @type = type @key_hash = key_hash end |
Instance Attribute Details
#key_hash ⇒ Hash{String => Object} (readonly)
Returns The hash containing key-value pairs that identify the target.
23 24 25 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 23 def key_hash @key_hash end |
#sandbox ⇒ Sandbox (readonly)
Returns The sandbox where the Pods should be installed.
13 14 15 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 13 def sandbox @sandbox end |
#type ⇒ Symbol (readonly)
Returns The type of target. Either aggregate or pod target.
18 19 20 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 18 def type @type end |
Class Method Details
.from_aggregate_target(sandbox, aggregate_target) ⇒ TargetCacheKey
Construct a TargetCacheKey instance from an AggregateTarget.
150 151 152 153 154 155 156 157 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 150 def self.from_aggregate_target(sandbox, aggregate_target) build_settings = {} aggregate_target.user_build_configurations.keys.each do |configuration| build_settings[configuration] = Digest::MD5.hexdigest(aggregate_target.build_settings(configuration).xcconfig.to_s) end TargetCacheKey.new(sandbox, :aggregate, 'BUILD_SETTINGS_CHECKSUM' => build_settings) end |
.from_cache_hash(sandbox, key_hash) ⇒ TargetCacheKey
Creates a TargetCacheKey instance from the given hash.
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 90 def self.from_cache_hash(sandbox, key_hash) cache_hash = key_hash.dup if files = cache_hash['FILES'] cache_hash['FILES'] = files.sort_by(&:downcase) end if specs = cache_hash['SPECS'] cache_hash['SPECS'] = specs.sort_by(&:downcase) end type = cache_hash['CHECKSUM'] ? :pod_target : :aggregate TargetCacheKey.new(sandbox, type, cache_hash) end |
.from_pod_target(sandbox, pod_target, is_local_pod: false, checkout_options: nil) ⇒ TargetCacheKey
Constructs a TargetCacheKey instance from a PodTarget.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 117 def self.from_pod_target(sandbox, pod_target, is_local_pod: false, checkout_options: nil) build_settings = {} build_settings[pod_target.label.to_s] = Digest::MD5.hexdigest(pod_target.build_settings.xcconfig.to_s) pod_target.test_spec_build_settings.each do |name, settings| build_settings[name] = Digest::MD5.hexdigest(settings.xcconfig.to_s) end pod_target.app_spec_build_settings.each do |name, settings| build_settings[name] = Digest::MD5.hexdigest(settings.xcconfig.to_s) end contents = { 'CHECKSUM' => pod_target.root_spec.checksum, 'SPECS' => pod_target.specs.map(&:to_s).sort_by(&:downcase), 'BUILD_SETTINGS_CHECKSUM' => build_settings, 'PROJECT_NAME' => pod_target.project_name, } if is_local_pod relative_file_paths = pod_target.all_files.map { |f| Pathname.new(f).relative_path_from(sandbox.root).to_s } contents['FILES'] = relative_file_paths.sort_by(&:downcase) end contents['CHECKOUT_OPTIONS'] = if TargetCacheKey.new(sandbox, :pod_target, contents) end |
Instance Method Details
#key_difference(other) ⇒ Symbol
Equality function used to compare TargetCacheKey objects to each other.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 45 def key_difference(other) if other.type != type :project else case type when :pod_target return :project if (other.key_hash.keys - key_hash.keys).any? return :project if other.key_hash['CHECKSUM'] != key_hash['CHECKSUM'] return :project if other.key_hash['SPECS'] != key_hash['SPECS'] return :project if other.key_hash['FILES'] != key_hash['FILES'] return :project if other.key_hash['PROJECT_NAME'] != key_hash['PROJECT_NAME'] end this_build_settings = key_hash['BUILD_SETTINGS_CHECKSUM'] other_build_settings = other.key_hash['BUILD_SETTINGS_CHECKSUM'] return :project if this_build_settings != other_build_settings = key_hash['CHECKOUT_OPTIONS'] = other.key_hash['CHECKOUT_OPTIONS'] return :project if != :none end end |
#project_name ⇒ String
Returns The name of the project the target belongs to.
77 78 79 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 77 def project_name key_hash['PROJECT_NAME'] end |
#to_h ⇒ Object
70 71 72 |
# File 'lib/cocoapods/installer/project_cache/target_cache_key.rb', line 70 def to_h key_hash end |