/
resolver.rb
34 lines (32 loc) · 1004 Bytes
/
resolver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Pod
class Resolver
def initialize(specification)
@specification = specification
end
def resolve
@sets = []
find_dependency_sets(@specification)
#@sets.reject(&:only_part_of_other_pod?).map(&:podspec)
@sets
end
def find_dependency_sets(specification)
specification.read(:dependencies).each do |dependency|
sets = Source.search(dependency)
if sets.empty?
raise "Unable to find a pod named `#{dependency.name}'"
end
sets.each do |set|
# TODO ultimately this compatibility check should be used to try and
# resolve the conflicts, but for now we'll keep it simple.
if existing_set = @sets.find { |s| s == set }
existing_set.required_by(specification, dependency)
else
set.required_by(specification, dependency)
@sets << set
find_dependency_sets(set.podspec)
end
end
end
end
end
end