Class: Pod::Installer::Analyzer::PodfileDependencyCache

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb

Overview

Caches podfile & target definition dependencies, so they do not need to be re-computed from the internal hash on each access

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(podfile_dependencies, dependencies_by_target_definition) ⇒ PodfileDependencyCache

Returns a new instance of PodfileDependencyCache.



13
14
15
16
# File 'lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb', line 13

def initialize(podfile_dependencies, dependencies_by_target_definition)
  @podfile_dependencies = podfile_dependencies
  @dependencies_by_target_definition = dependencies_by_target_definition
end

Instance Attribute Details

#podfile_dependenciesArray<Pod::Dependency> (readonly)

Returns All the dependencies in the podfile.

Returns:

  • (Array<Pod::Dependency>)

    All the dependencies in the podfile



11
12
13
# File 'lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb', line 11

def podfile_dependencies
  @podfile_dependencies
end

Class Method Details

.from_podfile(podfile) ⇒ PodfileDependencyCache

Parameters:

  • podfile (Podfile)

    The Podfile from which dependencies should be cached

Returns:

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb', line 39

def self.from_podfile(podfile)
  raise ArgumentError, 'Must be initialized with a podfile' unless podfile
  podfile_dependencies = []
  dependencies_by_target_definition = {}
  podfile.target_definition_list.each do |target_definition|
    deps = target_definition.dependencies.freeze
    podfile_dependencies.concat deps
    dependencies_by_target_definition[target_definition] = deps
  end
  podfile_dependencies.uniq!

  new(podfile_dependencies.freeze, dependencies_by_target_definition.freeze)
end

Instance Method Details

#target_definition_dependencies(target_definition) ⇒ Object

Returns the dependencies for the given target definition



20
21
22
23
# File 'lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb', line 20

def target_definition_dependencies(target_definition)
  @dependencies_by_target_definition[target_definition] ||
    raise(ArgumentError, "dependencies for #{target_definition.inspect} do not exist in the cache")
end

#target_definition_listObject

Returns a list of all of the target definitions in the Podfile



27
28
29
# File 'lib/cocoapods/installer/analyzer/podfile_dependency_cache.rb', line 27

def target_definition_list
  @dependencies_by_target_definition.keys
end