In Files

  • rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb

Class/Module Index [+]

Quicksearch

Gem::Resolver::Molinillo::DependencyGraph::DetachVertexNamed

Attributes

name[R]

@return [String] the name of the vertex to detach

Public Class Methods

action_name() click to toggle source

(see Action#name)

 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 10
def self.action_name
  :add_vertex
end
            
new(name) click to toggle source

Initialize an action to detach a vertex from a dependency graph @param [String] name the name of the vertex to detach

 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 54
def initialize(name)
  @name = name
end
            

Public Instance Methods

down(graph) click to toggle source

(see Gem::Resolver::Molinillo::DependencyGraph::Action#down)

 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 36
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
            
up(graph) click to toggle source

(see Gem::Resolver::Molinillo::DependencyGraph::Action#up)

 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb, line 15
def up(graph)
  return [] unless @vertex = graph.vertices.delete(name)

  removed_vertices = [@vertex]
  @vertex.outgoing_edges.each do |e|
    v = e.destination
    v.incoming_edges.delete(e)
    if !v.root? && v.incoming_edges.empty?
      removed_vertices.concat graph.detach_vertex_named(v.name)
    end
  end

  @vertex.incoming_edges.each do |e|
    v = e.origin
    v.outgoing_edges.delete(e)
  end

  removed_vertices
end