Class: Pod::Installer::Analyzer::PodfileDependencyCache
- Inherits:
-
Object
- Object
- Pod::Installer::Analyzer::PodfileDependencyCache
- 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
-
#podfile_dependencies ⇒ Array<Pod::Dependency>
readonly
All the dependencies in the podfile.
Class Method Summary collapse
-
.from_podfile(podfile) ⇒ PodfileDependencyCache
Creates a PodfileDependencyCache from the given Podfile.
Instance Method Summary collapse
-
#initialize(podfile_dependencies, dependencies_by_target_definition) ⇒ PodfileDependencyCache
constructor
A new instance of PodfileDependencyCache.
-
#target_definition_dependencies(target_definition) ⇒ Object
Returns the dependencies for the given target definition.
-
#target_definition_list ⇒ Object
Returns a list of all of the target definitions in the Podfile.
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_dependencies ⇒ Array<Pod::Dependency> (readonly)
Returns 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
Creates a Pod::Installer::Analyzer::PodfileDependencyCache from the given Podfile
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_list ⇒ Object
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 |