Class: PodPrebuild::Lockfile

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-cache/helper/lockfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lockfile) ⇒ Lockfile

Returns a new instance of Lockfile.



7
8
9
10
# File 'lib/cocoapods-binary-cache/helper/lockfile.rb', line 7

def initialize(lockfile)
  @lockfile = lockfile
  @data = lockfile.to_hash
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/cocoapods-binary-cache/helper/lockfile.rb', line 5

def data
  @data
end

#lockfileObject (readonly)

Returns the value of attribute lockfile.



5
6
7
# File 'lib/cocoapods-binary-cache/helper/lockfile.rb', line 5

def lockfile
  @lockfile
end

Instance Method Details

#dev_pod_hash(pod_name) ⇒ Object

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



56
57
58
# 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_namesObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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_sourcesObject



20
21
22
# 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_podsObject



39
40
41
42
# 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_sourcesObject



16
17
18
# File 'lib/cocoapods-binary-cache/helper/lockfile.rb', line 16

def external_sources
  @data["EXTERNAL SOURCES"] || {}
end

#non_dev_podsObject



44
45
46
47
# 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

#podsObject



12
13
14
# 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_podsObject



49
50
51
52
# 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