-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pulls in PR rubygems/rubygems#1644 so we can merge #3972.
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
Showing
27 changed files
with
901 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
module Gem::Resolver::Molinillo | ||
# @!visibility private | ||
module Delegates | ||
# Delegates all {Gem::Resolver::Molinillo::ResolutionState} methods to a `#state` property. | ||
module ResolutionState | ||
# (see Gem::Resolver::Molinillo::ResolutionState#name) | ||
def name | ||
current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty | ||
current_state.name | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::ResolutionState#requirements) | ||
def requirements | ||
current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty | ||
current_state.requirements | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::ResolutionState#activated) | ||
def activated | ||
current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty | ||
current_state.activated | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::ResolutionState#requirement) | ||
def requirement | ||
current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty | ||
current_state.requirement | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::ResolutionState#possibilities) | ||
def possibilities | ||
current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty | ||
current_state.possibilities | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::ResolutionState#depth) | ||
def depth | ||
current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty | ||
current_state.depth | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::ResolutionState#conflicts) | ||
def conflicts | ||
current_state = state || Gem::Resolver::Molinillo::ResolutionState.empty | ||
current_state.conflicts | ||
end | ||
end | ||
end | ||
end |
80 changes: 80 additions & 0 deletions
80
...ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# frozen_string_literal: true | ||
module Gem::Resolver::Molinillo | ||
module Delegates | ||
# Delegates all {Gem::Resolver::Molinillo::SpecificationProvider} methods to a | ||
# `#specification_provider` property. | ||
module SpecificationProvider | ||
# (see Gem::Resolver::Molinillo::SpecificationProvider#search_for) | ||
def search_for(dependency) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.search_for(dependency) | ||
end | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::SpecificationProvider#dependencies_for) | ||
def dependencies_for(specification) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.dependencies_for(specification) | ||
end | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::SpecificationProvider#requirement_satisfied_by?) | ||
def requirement_satisfied_by?(requirement, activated, spec) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.requirement_satisfied_by?(requirement, activated, spec) | ||
end | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::SpecificationProvider#name_for) | ||
def name_for(dependency) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.name_for(dependency) | ||
end | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::SpecificationProvider#name_for_explicit_dependency_source) | ||
def name_for_explicit_dependency_source | ||
with_no_such_dependency_error_handling do | ||
specification_provider.name_for_explicit_dependency_source | ||
end | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::SpecificationProvider#name_for_locking_dependency_source) | ||
def name_for_locking_dependency_source | ||
with_no_such_dependency_error_handling do | ||
specification_provider.name_for_locking_dependency_source | ||
end | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::SpecificationProvider#sort_dependencies) | ||
def sort_dependencies(dependencies, activated, conflicts) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.sort_dependencies(dependencies, activated, conflicts) | ||
end | ||
end | ||
|
||
# (see Gem::Resolver::Molinillo::SpecificationProvider#allow_missing?) | ||
def allow_missing?(dependency) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.allow_missing?(dependency) | ||
end | ||
end | ||
|
||
private | ||
|
||
# Ensures any raised {NoSuchDependencyError} has its | ||
# {NoSuchDependencyError#required_by} set. | ||
# @yield | ||
def with_no_such_dependency_error_handling | ||
yield | ||
rescue NoSuchDependencyError => error | ||
if state | ||
vertex = activated.vertex_named(name_for(error.dependency)) | ||
error.required_by += vertex.incoming_edges.map { |e| e.origin.name } | ||
error.required_by << name_for_explicit_dependency_source unless vertex.explicit_requirements.empty? | ||
end | ||
raise | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# An action that modifies a {DependencyGraph} that is reversible. | ||
# @abstract | ||
class Action | ||
# rubocop:disable Lint/UnusedMethodArgument | ||
|
||
# @return [Symbol] The name of the action. | ||
def self.name | ||
raise 'Abstract' | ||
end | ||
|
||
# Performs the action on the given graph. | ||
# @param [DependencyGraph] graph the graph to perform the action on. | ||
# @return [Void] | ||
def up(graph) | ||
raise 'Abstract' | ||
end | ||
|
||
# Reverses the action on the given graph. | ||
# @param [DependencyGraph] graph the graph to reverse the action on. | ||
# @return [Void] | ||
def down(graph) | ||
raise 'Abstract' | ||
end | ||
|
||
# @return [Action,Nil] The previous action | ||
attr_accessor :previous | ||
|
||
# @return [Action,Nil] The next action | ||
attr_accessor :next | ||
end | ||
end | ||
end |
58 changes: 58 additions & 0 deletions
58
...stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action' | ||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# @!visibility private | ||
# (see DependencyGraph#add_edge_no_circular) | ||
class AddEdgeNoCircular < Action | ||
# @!group Action | ||
|
||
# (see Action.name) | ||
def self.name | ||
:add_vertex | ||
end | ||
|
||
# (see Action#up) | ||
def up(graph) | ||
edge = make_edge(graph) | ||
edge.origin.outgoing_edges << edge | ||
edge.destination.incoming_edges << edge | ||
edge | ||
end | ||
|
||
# (see Action#down) | ||
def down(graph) | ||
edge = make_edge(graph) | ||
edge.origin.outgoing_edges.delete(edge) | ||
edge.destination.incoming_edges.delete(edge) | ||
end | ||
|
||
# @!group AddEdgeNoCircular | ||
|
||
# @return [String] the name of the origin of the edge | ||
attr_reader :origin | ||
|
||
# @return [String] the name of the destination of the edge | ||
attr_reader :destination | ||
|
||
# @return [Object] the requirement that the edge represents | ||
attr_reader :requirement | ||
|
||
# @param [DependencyGraph] graph the graph to find vertices from | ||
# @return [Edge] The edge this action adds | ||
def make_edge(graph) | ||
Edge.new(graph.vertex_named(origin), graph.vertex_named(destination), requirement) | ||
end | ||
|
||
# Initialize an action to add an edge to a dependency graph | ||
# @param [String] origin the name of the origin of the edge | ||
# @param [String] destination the name of the destination of the edge | ||
# @param [Object] requirement the requirement that the edge represents | ||
def initialize(origin, destination, requirement) | ||
@origin = origin | ||
@destination = destination | ||
@requirement = requirement | ||
end | ||
end | ||
end | ||
end |
61 changes: 61 additions & 0 deletions
61
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action' | ||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# @!visibility private | ||
# (see DependencyGraph#add_vertex) | ||
class AddVertex < Action # :nodoc: | ||
# @!group Action | ||
|
||
# (see Action.name) | ||
def self.name | ||
:add_vertex | ||
end | ||
|
||
# (see Action#up) | ||
def up(graph) | ||
if existing = graph.vertices[name] | ||
@existing_payload = existing.payload | ||
@existing_root = existing.root | ||
end | ||
vertex = existing || Vertex.new(name, payload) | ||
graph.vertices[vertex.name] = vertex | ||
vertex.payload ||= payload | ||
vertex.root ||= root | ||
vertex | ||
end | ||
|
||
# (see Action#down) | ||
def down(graph) | ||
if defined?(@existing_payload) | ||
vertex = graph.vertices[name] | ||
vertex.payload = @existing_payload | ||
vertex.root = @existing_root | ||
else | ||
graph.vertices.delete(name) | ||
end | ||
end | ||
|
||
# @!group AddVertex | ||
|
||
# @return [String] the name of the vertex | ||
attr_reader :name | ||
|
||
# @return [Object] the payload for the vertex | ||
attr_reader :payload | ||
|
||
# @return [Boolean] whether the vertex is root or not | ||
attr_reader :root | ||
|
||
# Initialize an action to add a vertex to a dependency graph | ||
# @param [String] name the name of the vertex | ||
# @param [Object] payload the payload for the vertex | ||
# @param [Boolean] root whether the vertex is root or not | ||
def initialize(name, payload, root) | ||
@name = name | ||
@payload = payload | ||
@root = root | ||
end | ||
end | ||
end | ||
end |
53 changes: 53 additions & 0 deletions
53
.../stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action' | ||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# @!visibility private | ||
# @see DependencyGraph#detach_vertex_named | ||
class DetachVertexNamed < Action | ||
# @!group Action | ||
|
||
# (see Action#name) | ||
def self.name | ||
:add_vertex | ||
end | ||
|
||
# (see Action#up) | ||
def up(graph) | ||
return unless @vertex = graph.vertices.delete(name) | ||
@vertex.outgoing_edges.each do |e| | ||
v = e.destination | ||
v.incoming_edges.delete(e) | ||
graph.detach_vertex_named(v.name) unless v.root? || v.predecessors.any? | ||
end | ||
@vertex.incoming_edges.each do |e| | ||
v = e.origin | ||
v.outgoing_edges.delete(e) | ||
end | ||
end | ||
|
||
# (see Action#down) | ||
def down(graph) | ||
return unless @vertex | ||
graph.vertices[@vertex.name] = @vertex | ||
@vertex.outgoing_edges.each do |e| | ||
e.destination.incoming_edges << e | ||
end | ||
@vertex.incoming_edges.each do |e| | ||
e.origin.outgoing_edges << e | ||
end | ||
end | ||
|
||
# @!group DetachVertexNamed | ||
|
||
# @return [String] the name of the vertex to detach | ||
attr_reader :name | ||
|
||
# Initialize an action to detach a vertex from a dependency graph | ||
# @param [String] name the name of the vertex to detach | ||
def initialize(name) | ||
@name = name | ||
end | ||
end | ||
end | ||
end |
114 changes: 114 additions & 0 deletions
114
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# frozen_string_literal: true | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular' | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex' | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named' | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload' | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag' | ||
|
||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# A log for dependency graph actions | ||
class Log | ||
# Initializes an empty log | ||
def initialize | ||
@current_action = @first_action = nil | ||
end | ||
|
||
# @!macro [new] action | ||
# {include:DependencyGraph#$0} | ||
# @param [Graph] graph the graph to perform the action on | ||
# @param (see DependencyGraph#$0) | ||
# @return (see DependencyGraph#$0) | ||
|
||
# @macro action | ||
def tag(graph, tag) | ||
push_action(graph, Tag.new(tag)) | ||
end | ||
|
||
# @macro action | ||
def add_vertex(graph, name, payload, root) | ||
push_action(graph, AddVertex.new(name, payload, root)) | ||
end | ||
|
||
# @macro action | ||
def detach_vertex_named(graph, name) | ||
push_action(graph, DetachVertexNamed.new(name)) | ||
end | ||
|
||
# @macro action | ||
def add_edge_no_circular(graph, origin, destination, requirement) | ||
push_action(graph, AddEdgeNoCircular.new(origin, destination, requirement)) | ||
end | ||
|
||
# @macro action | ||
def set_payload(graph, name, payload) | ||
push_action(graph, SetPayload.new(name, payload)) | ||
end | ||
|
||
# Pops the most recent action from the log and undoes the action | ||
# @param [DependencyGraph] graph | ||
# @return [Action] the action that was popped off the log | ||
def pop!(graph) | ||
return unless action = @current_action | ||
unless @current_action = action.previous | ||
@first_action = nil | ||
end | ||
action.down(graph) | ||
action | ||
end | ||
|
||
extend Enumerable | ||
|
||
# @!visibility private | ||
# Enumerates each action in the log | ||
# @yield [Action] | ||
def each | ||
return enum_for unless block_given? | ||
action = @first_action | ||
loop do | ||
break unless action | ||
yield action | ||
action = action.next | ||
end | ||
self | ||
end | ||
|
||
# @!visibility private | ||
# Enumerates each action in the log in reverse order | ||
# @yield [Action] | ||
def reverse_each | ||
return enum_for(:reverse_each) unless block_given? | ||
action = @current_action | ||
loop do | ||
break unless action | ||
yield action | ||
action = action.previous | ||
end | ||
self | ||
end | ||
|
||
# @macro action | ||
def rewind_to(graph, tag) | ||
loop do | ||
action = pop!(graph) | ||
raise "No tag #{tag.inspect} found" unless action | ||
break if action.class.name == :tag && action.tag == tag | ||
end | ||
end | ||
|
||
private | ||
|
||
# Adds the given action to the log, running the action | ||
# @param [DependencyGraph] graph | ||
# @param [Action] action | ||
# @return The value returned by `action.up` | ||
def push_action(graph, action) | ||
action.previous = @current_action | ||
@current_action.next = action if @current_action | ||
@current_action = action | ||
@first_action ||= action | ||
action.up(graph) | ||
end | ||
end | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action' | ||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# @!visibility private | ||
# @see DependencyGraph#set_payload | ||
class SetPayload < Action # :nodoc: | ||
# @!group Action | ||
|
||
# (see Action.name) | ||
def self.name | ||
:set_payload | ||
end | ||
|
||
# (see Action#up) | ||
def up(graph) | ||
vertex = graph.vertex_named(name) | ||
@old_payload = vertex.payload | ||
vertex.payload = payload | ||
end | ||
|
||
# (see Action#down) | ||
def down(graph) | ||
graph.vertex_named(name).payload = @old_payload | ||
end | ||
|
||
# @!group SetPayload | ||
|
||
# @return [String] the name of the vertex | ||
attr_reader :name | ||
|
||
# @return [Object] the payload for the vertex | ||
attr_reader :payload | ||
|
||
# Initialize an action to add set the payload for a vertex in a dependency | ||
# graph | ||
# @param [String] name the name of the vertex | ||
# @param [Object] payload the payload for the vertex | ||
def initialize(name, payload) | ||
@name = name | ||
@payload = payload | ||
end | ||
end | ||
end | ||
end |
35 changes: 35 additions & 0 deletions
35
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
require 'rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action' | ||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# @!visibility private | ||
# @see DependencyGraph#tag | ||
class Tag < Action | ||
# @!group Action | ||
|
||
# (see Action.name) | ||
def self.name | ||
:tag | ||
end | ||
|
||
# (see Action#up) | ||
def up(_graph) | ||
end | ||
|
||
# (see Action#down) | ||
def down(_graph) | ||
end | ||
|
||
# @!group Tag | ||
|
||
# @return [Object] An opaque tag | ||
attr_reader :tag | ||
|
||
# Initialize an action to tag a state of a dependency graph | ||
# @param [Object] tag an opaque tag | ||
def initialize(tag) | ||
@tag = tag | ||
end | ||
end | ||
end | ||
end |
123 changes: 123 additions & 0 deletions
123
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# frozen_string_literal: true | ||
module Gem::Resolver::Molinillo | ||
class DependencyGraph | ||
# A vertex in a {DependencyGraph} that encapsulates a {#name} and a | ||
# {#payload} | ||
class Vertex | ||
# @return [String] the name of the vertex | ||
attr_accessor :name | ||
|
||
# @return [Object] the payload the vertex holds | ||
attr_accessor :payload | ||
|
||
# @return [Arrary<Object>] the explicit requirements that required | ||
# this vertex | ||
attr_reader :explicit_requirements | ||
|
||
# @return [Boolean] whether the vertex is considered a root vertex | ||
attr_accessor :root | ||
alias 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) | ||
@name = name.frozen? ? name : name.dup.freeze | ||
@payload = payload | ||
@explicit_requirements = [] | ||
@outgoing_edges = [] | ||
@incoming_edges = [] | ||
end | ||
|
||
# @return [Array<Object>] all of the requirements that required | ||
# this vertex | ||
def requirements | ||
incoming_edges.map(&:requirement) + explicit_requirements | ||
end | ||
|
||
# @return [Array<Edge>] the edges of {#graph} that have `self` as their | ||
# {Edge#origin} | ||
attr_accessor :outgoing_edges | ||
|
||
# @return [Array<Edge>] the edges of {#graph} that have `self` as their | ||
# {Edge#destination} | ||
attr_accessor :incoming_edges | ||
|
||
# @return [Array<Vertex>] the vertices of {#graph} that have an edge with | ||
# `self` as their {Edge#destination} | ||
def predecessors | ||
incoming_edges.map(&:origin) | ||
end | ||
|
||
# @return [Array<Vertex>] the vertices of {#graph} where `self` is a | ||
# {#descendent?} | ||
def recursive_predecessors | ||
vertices = predecessors | ||
vertices += vertices.map(&:recursive_predecessors).flatten(1) | ||
vertices.uniq! | ||
vertices | ||
end | ||
|
||
# @return [Array<Vertex>] the vertices of {#graph} that have an edge with | ||
# `self` as their {Edge#origin} | ||
def successors | ||
outgoing_edges.map(&:destination) | ||
end | ||
|
||
# @return [Array<Vertex>] the vertices of {#graph} where `self` is an | ||
# {#ancestor?} | ||
def recursive_successors | ||
vertices = successors | ||
vertices += vertices.map(&:recursive_successors).flatten(1) | ||
vertices.uniq! | ||
vertices | ||
end | ||
|
||
# @return [String] a string suitable for debugging | ||
def inspect | ||
"#{self.class}:#{name}(#{payload.inspect})" | ||
end | ||
|
||
# @return [Boolean] whether the two vertices are equal, determined | ||
# by a recursive traversal of each {Vertex#successors} | ||
def ==(other) | ||
shallow_eql?(other) && | ||
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) | ||
other && | ||
name == other.name && | ||
payload == other.payload | ||
end | ||
|
||
alias eql? == | ||
|
||
# @return [Fixnum] a hash for the vertex based upon its {#name} | ||
def hash | ||
name.hash | ||
end | ||
|
||
# Is there a path from `self` to `other` following edges in the | ||
# dependency graph? | ||
# @return true iff there is a path following edges within this {#graph} | ||
def path_to?(other) | ||
equal?(other) || successors.any? { |v| v.path_to?(other) } | ||
end | ||
|
||
alias descendent? path_to? | ||
|
||
# Is there a path from `other` to `self` following edges in the | ||
# dependency graph? | ||
# @return true iff there is a path following edges within this {#graph} | ||
def ancestor?(other) | ||
other.path_to?(self) | ||
end | ||
|
||
alias is_reachable_from? ancestor? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
module Gem::Resolver::Molinillo | ||
# The version of Gem::Resolver::Molinillo. | ||
VERSION = '0.4.3'.freeze | ||
VERSION = '0.5.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
lib/ruby/stdlib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG | ||
A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv | ||
b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw | ||
MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i | ||
YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT | ||
aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ | ||
jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp | ||
xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp | ||
1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG | ||
snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ | ||
U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8 | ||
9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E | ||
BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B | ||
AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz | ||
yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE | ||
38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP | ||
AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad | ||
DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME | ||
HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== | ||
-----END CERTIFICATE----- |
25 changes: 25 additions & 0 deletions
25
lib/ruby/stdlib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU | ||
MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs | ||
IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 | ||
MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux | ||
FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h | ||
bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v | ||
dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt | ||
H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 | ||
uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX | ||
mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX | ||
a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN | ||
E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 | ||
WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD | ||
VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 | ||
Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU | ||
cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx | ||
IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN | ||
AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH | ||
YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 | ||
6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC | ||
Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX | ||
c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a | ||
mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= | ||
-----END CERTIFICATE----- |