Sha256: d781e7f2fda8fad7e093d951b7250556d2b11b4de1d16916477ad38cac15c6a1

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# ABOUT NAMES
#
# There are many kinds of name in cocoapods. Two main names are widely used in this plugin.
# - root_spec.name (spec.root_name, targe.pod_name):
#   aka "pod_name"
#   the name we use in podfile. the concept.
#
# - target.name:
#   aka "target_name"
#   the name of the final target in xcode project. the final real thing.
#
# One pod may have multiple targets in xcode project, due to one pod can be used in mutiple
# platform simultaneously. So one `root_spec.name` may have multiple coresponding `target.name`s.
# Therefore, map a spec to/from targets is a little complecated. It's one to many.
#

# Tool to transform Pod_name to target efficiently
module Pod
  def self.fast_get_targets_for_pod_name(pod_name, targets, cache)
    pod_name = pod_name.split("/")[0] # Look for parent spec instead of subspecs
    pod_name_to_targets_hash = nil
    if cache.empty?
      pod_name_to_targets_hash = targets.reduce({}) do |sum, target|
        array = sum[target.pod_name] || []
        array << target
        sum[target.pod_name] = array
        sum
      end
      cache << pod_name_to_targets_hash
    else
      pod_name_to_targets_hash = cache.first
    end

    pod_name_to_targets_hash[pod_name] || []
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cocoapods-binary-cache-0.1.3 lib/cocoapods-binary-cache/pod-binary/helper/names.rb
cocoapods-binary-cache-0.1.2 lib/cocoapods-binary-cache/pod-binary/helper/names.rb
cocoapods-binary-cache-0.1.1 lib/cocoapods-binary-cache/pod-binary/helper/names.rb