1
|
# frozen_string_literal: true
|
2
|
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph'
|
3
|
|
4
|
module Gem::Resolver::Molinillo
|
5
|
# This class encapsulates a dependency resolver.
|
6
|
# The resolver is responsible for determining which set of dependencies to
|
7
|
# activate, with feedback from the {#specification_provider}
|
8
|
#
|
9
|
#
|
10
|
class Resolver
|
11
|
require 'rubygems/resolver/molinillo/lib/molinillo/resolution'
|
12
|
|
13
|
# @return [SpecificationProvider] the specification provider used
|
14
|
# in the resolution process
|
15
|
attr_reader :specification_provider
|
16
|
|
17
|
# @return [UI] the UI module used to communicate back to the user
|
18
|
# during the resolution process
|
19
|
attr_reader :resolver_ui
|
20
|
|
21
|
# Initializes a new resolver.
|
22
|
# @param [SpecificationProvider] specification_provider
|
23
|
# see {#specification_provider}
|
24
|
# @param [UI] resolver_ui
|
25
|
# see {#resolver_ui}
|
26
|
def initialize(specification_provider, resolver_ui)
|
27
|
@specification_provider = specification_provider
|
28
|
@resolver_ui = resolver_ui
|
29
|
end
|
30
|
|
31
|
# Resolves the requested dependencies into a {DependencyGraph},
|
32
|
# locking to the base dependency graph (if specified)
|
33
|
# @param [Array] requested an array of 'requested' dependencies that the
|
34
|
# {#specification_provider} can understand
|
35
|
# @param [DependencyGraph,nil] base the base dependency graph to which
|
36
|
# dependencies should be 'locked'
|
37
|
def resolve(requested, base = DependencyGraph.new)
|
38
|
Resolution.new(specification_provider,
|
39
|
resolver_ui,
|
40
|
requested,
|
41
|
base).
|
42
|
resolve
|
43
|
end
|
44
|
end
|
45
|
end
|
Comments