Class: Bundler::Molinillo::DependencyGraph::Log
- Inherits:
-
Object
- Object
- Bundler::Molinillo::DependencyGraph::Log
- Extended by:
- Enumerable
- Defined in:
- lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb
Overview
A log for dependency graph actions
Instance Method Summary collapse
-
#add_edge_no_circular(graph, origin, destination, requirement) ⇒ Edge
Adds a new Edge to the dependency graph without checking for circularity.
-
#add_vertex(graph, name, payload, root) ⇒ Vertex
Adds a vertex with the given name, or updates the existing one.
-
#delete_edge(graph, origin_name, destination_name, requirement) ⇒ Void
Deletes an Edge from the dependency graph
-
#detach_vertex_named(graph, name) ⇒ Array<Vertex>
Detaches the #vertex_named ‘name` Vertex from the graph, recursively removing any non-root vertices that were orphaned in the process
-
#initialize ⇒ Log
constructor
Initializes an empty log.
-
#pop!(graph) ⇒ Action
Pops the most recent action from the log and undoes the action.
-
#rewind_to(graph, tag) ⇒ Void
Rewinds the graph to the state tagged as ‘tag`
-
#set_payload(graph, name, payload) ⇒ Void
Sets the payload of the vertex with the given name
-
#tag(graph, tag) ⇒ Void
Tags the current state of the dependency as the given tag
Constructor Details
#initialize ⇒ Log
Initializes an empty log
15 16 17 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 15 def initialize @current_action = @first_action = nil end |
Instance Method Details
#add_edge_no_circular(graph, origin, destination, requirement) ⇒ Edge
41 42 43 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 41 def add_edge_no_circular(graph, origin, destination, requirement) push_action(graph, AddEdgeNoCircular.new(origin, destination, requirement)) end |
#add_vertex(graph, name, payload, root) ⇒ Vertex
31 32 33 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 31 def add_vertex(graph, name, payload, root) push_action(graph, AddVertex.new(name, payload, root)) end |
#delete_edge(graph, origin_name, destination_name, requirement) ⇒ Void
51 52 53 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 51 def delete_edge(graph, origin_name, destination_name, requirement) push_action(graph, DeleteEdge.new(origin_name, destination_name, requirement)) end |
#detach_vertex_named(graph, name) ⇒ Array<Vertex>
36 37 38 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 36 def detach_vertex_named(graph, name) push_action(graph, DetachVertexNamed.new(name)) end |
#pop!(graph) ⇒ Action
Pops the most recent action from the log and undoes the action
63 64 65 66 67 68 69 70 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 63 def pop!(graph) return unless action = @current_action unless @current_action = action.previous @first_action = nil end action.down(graph) action end |
#rewind_to(graph, tag) ⇒ Void
103 104 105 106 107 108 109 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 103 def rewind_to(graph, tag) loop do action = pop!(graph) raise "No tag #{tag.inspect} found" unless action break if action.class.action_name == :tag && action.tag == tag end end |
#set_payload(graph, name, payload) ⇒ Void
56 57 58 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 56 def set_payload(graph, name, payload) push_action(graph, SetPayload.new(name, payload)) end |
#tag(graph, tag) ⇒ Void
26 27 28 |
# File 'lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb', line 26 def tag(graph, tag) push_action(graph, Tag.new(tag)) end |