Class: Pod::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(specification, dependencies = nil) ⇒ Resolver

Returns a new instance of Resolver.



3
4
5
# File 'lib/cocoapods/resolver.rb', line 3

def initialize(specification, dependencies = nil)
  @specification, @dependencies = specification, dependencies || specification.dependencies
end

Instance Method Details

#find_dependency_set(dependency) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/cocoapods/resolver.rb', line 25

def find_dependency_set(dependency)
  if external_spec = dependency.specification
    Specification::Set::External.new(external_spec)
  else
    Source.search(dependency)
  end
end

#find_dependency_sets(specification, dependencies = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cocoapods/resolver.rb', line 13

def find_dependency_sets(specification, dependencies = nil)
  (dependencies || specification.dependencies).each do |dependency|
    set = find_dependency_set(dependency)
    set.required_by(specification)
    unless @sets.include?(set)
      validate_platform!(set)
      @sets << set
      find_dependency_sets(set.specification)
    end
  end
end

#resolveObject



7
8
9
10
11
# File 'lib/cocoapods/resolver.rb', line 7

def resolve
  @sets = []
  find_dependency_sets(@specification, @dependencies)
  @sets
end

#validate_platform!(set) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/cocoapods/resolver.rb', line 33

def validate_platform!(set)
  spec = set.specification
  unless spec.platform.nil? || spec.platform == @specification.platform
    raise Informative, "The platform required by the Podfile (:#{@specification.platform}) " \
                       "does not match that of #{spec} (:#{spec.platform})"
  end
end