class PodPrebuild::Lockfile

Attributes

data[R]
lockfile[R]

Public Class Methods

new(lockfile) click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 7
def initialize(lockfile)
  @lockfile = lockfile
  @data = lockfile.to_hash
end

Public Instance Methods

dev_pod_hash(pod_name) click to toggle source

Return content hash (Hash the directory at source path) of a dev_pod Return nil if it's not a dev_pod

# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 56
def dev_pod_hash(pod_name)
  dev_pod_hashes_map[pod_name]
end
dev_pod_names() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 24
def dev_pod_names
  # There are 2 types of external sources:
  # - Development pods: declared with `:path` option in Podfile, corresponding to `:path` in the Lockfile
  # - External remote pods: declared with `:git` option in Podfile, corresponding to `:git` in the Lockfile
  # --------------------
  # EXTERNAL SOURCES:
  #   ADevPod:
  #     :path: path/to/dev_pod
  #   AnExternalRemotePod:
  #     :git: git@remote_url
  #     :commit: abc1234
  # --------------------
  @dev_pod_names ||= dev_pod_sources.keys.to_set
end
dev_pod_sources() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 20
def dev_pod_sources
  @dev_pod_sources ||= external_sources.select { |_, attributes| attributes.key?(:path) } || {}
end
dev_pods() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 39
def dev_pods
  dev_pod_names_ = dev_pod_names
  @dev_pods ||= pods.select { |name, _| dev_pod_names_.include?(name) }
end
external_sources() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 16
def external_sources
  @data["EXTERNAL SOURCES"] || {}
end
non_dev_pods() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 44
def non_dev_pods
  dev_pod_names_ = dev_pod_names
  @non_dev_pods ||= pods.reject { |name, _| dev_pod_names_.include?(name) }
end
pods() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 12
def pods
  @pods ||= (@data["PODS"] || []).map { |v| pod_from(v) }.to_h
end
subspec_vendor_pods() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 49
def subspec_vendor_pods
  dev_pod_names_ = dev_pod_names
  @subspec_vendor_pods ||= subspec_pods.reject { |name, _| dev_pod_names_.include?(name) }
end

Private Instance Methods

dev_pod_hashes_map() click to toggle source

Generate a map between a dev_pod and it source hash

# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 69
def dev_pod_hashes_map
  @dev_pod_hashes_map ||=
    dev_pod_sources.map { |name, attribs| [name, FolderChecksum.git_checksum(attribs[:path])] }.to_h
end
pod_from(hash_or_string) click to toggle source

Parse an item under `PODS` section of a Lockfile @param hash_or_string: an item under `PODS` section, could be a Hash (if having dependencies) or a String

Examples:

PODS:
  - FrameworkA (0.0.1)
  - FrameworkB (0.0.2):
    - DependencyOfB

@return [framework_name, version] (for ex. [“AFramework”, “0.0.1”])

# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 84
def pod_from(hash_or_string)
  name_with_version = hash_or_string.is_a?(Hash) ? hash_or_string.keys[0] : hash_or_string
  match = name_with_version.match(/(\S+) \((\S+)\)/)
  [match[1], match[2]]
end
subspec_pods() click to toggle source
# File lib/cocoapods-binary-cache/helper/lockfile.rb, line 62
def subspec_pods
  @subspec_pods ||= pods.keys
    .select { |k| k.include?("/") }
    .group_by { |k| k.split("/")[0] }
end