Module: Pod::Installer::Analyzer::LockingDependencyAnalyzer

Defined in:
lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb

Overview

Generates dependencies that require the specific version of the Pods that haven’t changed in the Lockfile.

Class Method Summary collapse

Class Method Details

.generate_version_locking_dependencies(lockfile, pods_to_update, pods_to_unlock = []) ⇒ Molinillo::DependencyGraph<Dependency>

Generates dependencies that require the specific version of the Pods that haven’t changed in the Lockfile.

These dependencies are passed to the Resolver, unless the installer is in update mode, to prevent it from upgrading the Pods that weren’t changed in the Podfile.

Parameters:

  • lockfile (Lockfile)

    the lockfile containing dependency constraints

  • pods_to_update (Array<String>)

    List of pod names which needs to be updated because installer is in update mode for these pods. Pods in this list and all their recursive dependencies will not be included in generated dependency graph

  • pods_to_unlock (Array<String>) (defaults to: [])

    List of pod names whose version constraints will be removed from the generated dependency graph. Recursive dependencies of the pods won’t be affected. This is currently used to force local pods to be evaluated again whenever checksum of the specification of the local pods changes.

Returns:

  • (Molinillo::DependencyGraph<Dependency>)

    the dependencies generated by the lockfile that prevent the resolver to update a Pod.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb', line 32

def self.generate_version_locking_dependencies(lockfile, pods_to_update, pods_to_unlock = [])
  dependency_graph = Molinillo::DependencyGraph.new

  if lockfile
    added_dependency_strings = Set.new

    explicit_dependencies = lockfile.dependencies
    explicit_dependencies.each do |dependency|
      dependency_graph.add_vertex(dependency.name, dependency, true)
    end

    pods = lockfile.to_hash['PODS'] || []
    pods.each do |pod|
      add_to_dependency_graph(pod, [], dependency_graph, pods_to_unlock, added_dependency_strings)
    end

    pods_to_update = pods_to_update.flat_map do |u|
      root_name = Specification.root_name(u).downcase
      dependency_graph.vertices.each_key.select { |n| Specification.root_name(n).downcase == root_name }
    end

    pods_to_update.each do |u|
      dependency_graph.detach_vertex_named(u)
    end

    dependency_graph.each do |vertex|
      next unless dep = vertex.payload
      dep.podspec_repo ||= lockfile.spec_repo(dep.root_name)
    end
  end

  dependency_graph
end

.unlocked_dependency_graphMolinillo::DependencyGraph<Dependency>

Generates a completely ‘unlocked’ dependency graph.

Returns:

  • (Molinillo::DependencyGraph<Dependency>)

    an empty dependency graph



71
72
73
# File 'lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb', line 71

def self.unlocked_dependency_graph
  Molinillo::DependencyGraph.new
end