diff options
Diffstat (limited to 'lib/rubygems/resolver/molinillo')
9 files changed, 39 insertions, 18 deletions
diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo.rb b/lib/rubygems/resolver/molinillo/lib/molinillo.rb index 34dc7787dc..0ae4b6a912 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo.rb @@ -1,6 +1,10 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rubygems/resolver/molinillo/lib/molinillo/gem_metadata' require 'rubygems/resolver/molinillo/lib/molinillo/errors' require 'rubygems/resolver/molinillo/lib/molinillo/resolver' require 'rubygems/resolver/molinillo/lib/molinillo/modules/ui' require 'rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider' + +# Gem::Resolver::Molinillo is a generic dependency resolution algorithm. +module Gem::Resolver::Molinillo +end diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb index c3a1d5a2ef..deb4659448 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'set' require 'tsort' @@ -15,8 +15,10 @@ module Gem::Resolver::Molinillo include TSort + # @visibility private alias_method :tsort_each_node, :each + # @visibility private def tsort_each_child(vertex, &block) vertex.successors.each(&block) end @@ -42,12 +44,14 @@ module Gem::Resolver::Molinillo # by {Vertex#name} attr_reader :vertices + # Initializes an empty dependency graph def initialize @vertices = {} end # Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices} # are properly copied. + # @param [DependencyGraph] other the graph to copy. def initialize_copy(other) super @vertices = {} @@ -101,6 +105,7 @@ module Gem::Resolver::Molinillo vertex end + # Adds a vertex with the given name, or updates the existing one. # @param [String] name # @param [Object] payload # @return [Vertex] the vertex that was added to `self` @@ -151,6 +156,8 @@ module Gem::Resolver::Molinillo private + # Adds a new {Edge} to the dependency graph without checking for + # circularity. def add_edge_no_circular(origin, destination, requirement) edge = Edge.new(origin, destination, requirement) origin.outgoing_edges << edge @@ -175,6 +182,7 @@ module Gem::Resolver::Molinillo attr_accessor :root alias_method :root?, :root + # Initializes a vertex with the given name and payload. # @param [String] name see {#name} # @param [Object] payload see {#payload} def initialize(name, payload) @@ -241,6 +249,7 @@ module Gem::Resolver::Molinillo successors.to_set == other.successors.to_set end + # @param [Vertex] other the other vertex to compare to # @return [Boolean] whether the two vertices are equal, determined # solely by {#name} and {#payload} equality def shallow_eql?(other) diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb index 074ee9dd7d..3fad948392 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Gem::Resolver::Molinillo # An error that occurred during the resolution process class ResolverError < StandardError; end @@ -12,6 +12,7 @@ module Gem::Resolver::Molinillo # @return [Array<Object>] the specifications that depended upon {#dependency} attr_accessor :required_by + # Initializes a new error with the given missing dependency. # @param [Object] dependency @see {#dependency} # @param [Array<Object>] required_by @see {#required_by} def initialize(dependency, required_by = []) @@ -20,6 +21,8 @@ module Gem::Resolver::Molinillo super() end + # The error message for the missing dependency, including the specifications + # that had this dependency. def message sources = required_by.map { |r| "`#{r}`" }.join(' and ') message = "Unable to find a specification for `#{dependency}`" @@ -37,6 +40,7 @@ module Gem::Resolver::Molinillo # [Set<Object>] the dependencies responsible for causing the error attr_reader :dependencies + # Initializes a new error with the given circular vertices. # @param [Array<DependencyGraph::Vertex>] nodes the nodes in the dependency # that caused the error def initialize(nodes) @@ -51,6 +55,7 @@ module Gem::Resolver::Molinillo # resolution to fail attr_reader :conflicts + # Initializes a new error with the given version conflicts. # @param [{String => Resolution::Conflict}] conflicts see {#conflicts} def initialize(conflicts) pairs = [] diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb index 8140c57a58..79cae2c697 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb @@ -1,4 +1,5 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Gem::Resolver::Molinillo - VERSION = '0.4.0' + # The version of Gem::Resolver::Molinillo. + VERSION = '0.4.1'.freeze end diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb index 10c655ac32..916345b12a 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Gem::Resolver::Molinillo # Provides information about specifcations and dependencies to the resolver, # allowing the {Resolver} class to remain generic while still providing power diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb index 100b694ebc..348ace286a 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Gem::Resolver::Molinillo # Conveys information about the resolution process to a user. module UI diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb index 5a0eb36849..0f822f0b82 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Gem::Resolver::Molinillo class Resolver # A specific resolution from a given {Resolver} @@ -39,6 +39,7 @@ module Gem::Resolver::Molinillo # @return [Array] the dependencies that were explicitly required attr_reader :original_requested + # Initializes a new resolution. # @param [SpecificationProvider] specification_provider # see {#specification_provider} # @param [UI] resolver_ui see {#resolver_ui} diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb index a92b3273ab..5c59a45c3d 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb @@ -1,10 +1,10 @@ -# frozen_string_literal: false +# frozen_string_literal: true require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph' module Gem::Resolver::Molinillo # This class encapsulates a dependency resolver. # The resolver is responsible for determining which set of dependencies to - # activate, with feedback from the the {#specification_provider} + # activate, with feedback from the {#specification_provider} # # class Resolver @@ -18,6 +18,7 @@ module Gem::Resolver::Molinillo # during the resolution process attr_reader :resolver_ui + # Initializes a new resolver. # @param [SpecificationProvider] specification_provider # see {#specification_provider} # @param [UI] resolver_ui diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb index 7bc9d98927..ac25538a5a 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/state.rb @@ -1,13 +1,13 @@ -# frozen_string_literal: false +# frozen_string_literal: true module Gem::Resolver::Molinillo # A state that a {Resolution} can be in - # @attr [String] name - # @attr [Array<Object>] requirements - # @attr [DependencyGraph] activated - # @attr [Object] requirement - # @attr [Object] possibility - # @attr [Integer] depth - # @attr [Set<Object>] conflicts + # @attr [String] name the name of the current requirement + # @attr [Array<Object>] requirements currently unsatisfied requirements + # @attr [DependencyGraph] activated the graph of activated dependencies + # @attr [Object] requirement the current requirement + # @attr [Object] possibilities the possibilities to satisfy the current requirement + # @attr [Integer] depth the depth of the resolution + # @attr [Set<Object>] conflicts unresolved conflicts ResolutionState = Struct.new( :name, :requirements, |