lib/berkshelf/resolver.rb in berkshelf-3.0.0.beta7 vs lib/berkshelf/resolver.rb in berkshelf-3.0.0.beta8
- old
+ new
@@ -2,22 +2,22 @@
class Resolver
require_relative 'resolver/graph'
extend Forwardable
- # @return [Berkshelf::Berksfile]
+ # @return [Berksfile]
attr_reader :berksfile
# @return [Resolver::Graph]
attr_reader :graph
- # @return [Array<Berkshelf::Dependency>]
+ # @return [Array<Dependency>]
# an array of dependencies that must be satisfied
attr_reader :demands
- # @param [Berkshelf::Berksfile] berksfile
- # @param [Array<Berkshelf::Dependency>, Berkshelf::Dependency] demands
+ # @param [Berksfile] berksfile
+ # @param [Array<Dependency>, Dependency] demands
# a dependency, or array of dependencies, which must be satisfied
def initialize(berksfile, demands = [])
@berksfile = berksfile
@graph = Graph.new
@demands = Array.new
@@ -25,16 +25,16 @@
Array(demands).each { |demand| add_demand(demand) }
end
# Add the given dependency to the collection of demands
#
- # @param [Berkshelf::Dependency] demand
+ # @param [Dependency] demand
# add a dependency that must be satisfied to the graph
#
# @raise [DuplicateDemand]
#
- # @return [Array<Berkshelf::Dependency>]
+ # @return [Array<Dependency>]
def add_demand(demand)
if has_demand?(demand)
raise DuplicateDemand, "A demand named '#{demand.name}' is already present."
end
@@ -42,11 +42,11 @@
end
# Add dependencies of a locally cached cookbook which will take precedence over anything
# found in the universe.
#
- # @param [Berkshelf::CachedCookbook] cookbook
+ # @param [CachedCookbook] cookbook
#
# @return [Hash]
def add_explicit_dependencies(cookbook)
graph.populate_local(cookbook)
end
@@ -61,11 +61,11 @@
end
# Finds a solution for the currently added dependencies and their dependencies and
# returns an array of CachedCookbooks.
#
- # @raise [Berkshelf::NoSolutionError] when a solution could not be found for the given demands
+ # @raise [NoSolutionError] when a solution could not be found for the given demands
#
# @return [Array<Array<String, String, Dependency>>]
def resolve
graph.populate_store
graph.populate(berksfile.sources)
@@ -75,27 +75,27 @@
dependency.locked_version = version
dependency
end
rescue Solve::Errors::NoSolutionError
- raise Berkshelf::NoSolutionError.new(demands)
+ raise NoSolutionError.new(demands)
end
# Retrieve the given demand from the resolver
#
- # @param [Berkshelf::Dependency, #to_s] demand
+ # @param [Dependency, #to_s] demand
# name of the dependency to return
#
- # @return [Berkshelf::Dependency]
+ # @return [Dependency]
def [](demand)
name = demand.respond_to?(:name) ? demand.name : demand.to_s
demands.find { |demand| demand.name == name }
end
alias_method :get_demand, :[]
# Check if the given demand has been added to the resolver
#
- # @param [Berkshelf::Dependency, #to_s] demand
+ # @param [Dependency, #to_s] demand
# the demand or the name of the demand to check for
def has_demand?(demand)
!get_demand(demand).nil?
end
end