bundler 1.12.6 → 1.13.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +15 -13
- data/.travis.yml +2 -2
- data/CHANGELOG.md +40 -3
- data/CONTRIBUTING.md +9 -5
- data/DEVELOPMENT.md +30 -18
- data/ISSUES.md +26 -22
- data/Rakefile +15 -4
- data/bin/rubocop +1 -1
- data/bundler.gemspec +2 -2
- data/exe/bundle +7 -0
- data/lib/bundler.rb +6 -3
- data/lib/bundler/capistrano.rb +1 -1
- data/lib/bundler/cli.rb +27 -10
- data/lib/bundler/cli/binstubs.rb +2 -0
- data/lib/bundler/cli/exec.rb +1 -1
- data/lib/bundler/cli/install.rb +87 -56
- data/lib/bundler/cli/lock.rb +5 -0
- data/lib/bundler/cli/open.rb +3 -1
- data/lib/bundler/cli/outdated.rb +8 -8
- data/lib/bundler/cli/plugin.rb +23 -0
- data/lib/bundler/cli/update.rb +2 -2
- data/lib/bundler/cli/viz.rb +3 -0
- data/lib/bundler/definition.rb +72 -16
- data/lib/bundler/dsl.rb +19 -7
- data/lib/bundler/endpoint_specification.rb +2 -2
- data/lib/bundler/env.rb +2 -2
- data/lib/bundler/errors.rb +15 -1
- data/lib/bundler/fetcher.rb +5 -2
- data/lib/bundler/fetcher/compact_index.rb +2 -2
- data/lib/bundler/fetcher/dependency.rb +8 -4
- data/lib/bundler/fetcher/downloader.rb +1 -1
- data/lib/bundler/friendly_errors.rb +1 -1
- data/lib/bundler/index.rb +29 -36
- data/lib/bundler/inline.rb +14 -4
- data/lib/bundler/installer.rb +22 -3
- data/lib/bundler/installer/gem_installer.rb +1 -1
- data/lib/bundler/installer/standalone.rb +1 -1
- data/lib/bundler/mirror.rb +4 -4
- data/lib/bundler/plugin.rb +156 -0
- data/lib/bundler/plugin/api.rb +56 -0
- data/lib/bundler/plugin/dsl.rb +29 -0
- data/lib/bundler/plugin/index.rb +88 -0
- data/lib/bundler/plugin/installer.rb +99 -0
- data/lib/bundler/plugin/installer/git.rb +38 -0
- data/lib/bundler/plugin/installer/rubygems.rb +27 -0
- data/lib/bundler/plugin/source_list.rb +24 -0
- data/lib/bundler/postit_trampoline.rb +54 -0
- data/lib/bundler/psyched_yaml.rb +1 -1
- data/lib/bundler/remote_specification.rb +5 -5
- data/lib/bundler/resolver.rb +27 -29
- data/lib/bundler/ruby_version.rb +29 -3
- data/lib/bundler/rubygems_ext.rb +3 -1
- data/lib/bundler/rubygems_integration.rb +10 -4
- data/lib/bundler/runtime.rb +1 -16
- data/lib/bundler/settings.rb +19 -15
- data/lib/bundler/setup.rb +1 -0
- data/lib/bundler/shared_helpers.rb +3 -0
- data/lib/bundler/source.rb +4 -3
- data/lib/bundler/source/gemspec.rb +13 -0
- data/lib/bundler/source/git.rb +4 -3
- data/lib/bundler/source/git/git_proxy.rb +9 -5
- data/lib/bundler/source/path.rb +11 -2
- data/lib/bundler/source/rubygems.rb +28 -15
- data/lib/bundler/source_list.rb +5 -1
- data/lib/bundler/spec_set.rb +3 -3
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
- data/lib/bundler/ssl_certs/rubygems.org/{AddTrustExternalCARoot-2048.pem → AddTrustExternalCARoot.pem} +0 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +54 -29
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +5 -2
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +3 -3
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -2
- data/lib/bundler/ui/shell.rb +4 -0
- data/lib/bundler/ui/silent.rb +3 -0
- data/lib/bundler/uri_credentials_filter.rb +36 -0
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +50 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +80 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +56 -144
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +35 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +58 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +61 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +53 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +114 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +45 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +35 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +123 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +46 -51
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +4 -2
- data/lib/bundler/vendor/postit/lib/postit.rb +15 -0
- data/lib/bundler/vendor/postit/lib/postit/environment.rb +44 -0
- data/lib/bundler/vendor/postit/lib/postit/installer.rb +28 -0
- data/lib/bundler/vendor/postit/lib/postit/parser.rb +21 -0
- data/lib/bundler/vendor/postit/lib/postit/setup.rb +12 -0
- data/lib/bundler/vendor/postit/lib/postit/version.rb +3 -0
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/yaml_serializer.rb +67 -0
- data/man/bundle-install.ronn +10 -5
- data/man/bundle-package.ronn +7 -6
- data/man/bundle-platform.ronn +1 -1
- data/man/bundle-update.ronn +5 -2
- data/man/bundle.ronn +5 -5
- data/man/gemfile.5.ronn +32 -28
- metadata +37 -12
- data/lib/bundler/ssl_certs/Fastly.pem +0 -82
- data/lib/bundler/ssl_certs/GlobalSignOrganizationValidationCA.pem +0 -26
- data/lib/bundler/ssl_certs/GlobalSignRoot.pem +0 -18
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRoot.pem +0 -18
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Bundler::Molinillo
|
3
|
+
module Delegates
|
4
|
+
# Delegates all {Bundler::Molinillo::SpecificationProvider} methods to a
|
5
|
+
# `#specification_provider` property.
|
6
|
+
module SpecificationProvider
|
7
|
+
# (see Bundler::Molinillo::SpecificationProvider#search_for)
|
8
|
+
def search_for(dependency)
|
9
|
+
with_no_such_dependency_error_handling do
|
10
|
+
specification_provider.search_for(dependency)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# (see Bundler::Molinillo::SpecificationProvider#dependencies_for)
|
15
|
+
def dependencies_for(specification)
|
16
|
+
with_no_such_dependency_error_handling do
|
17
|
+
specification_provider.dependencies_for(specification)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# (see Bundler::Molinillo::SpecificationProvider#requirement_satisfied_by?)
|
22
|
+
def requirement_satisfied_by?(requirement, activated, spec)
|
23
|
+
with_no_such_dependency_error_handling do
|
24
|
+
specification_provider.requirement_satisfied_by?(requirement, activated, spec)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# (see Bundler::Molinillo::SpecificationProvider#name_for)
|
29
|
+
def name_for(dependency)
|
30
|
+
with_no_such_dependency_error_handling do
|
31
|
+
specification_provider.name_for(dependency)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# (see Bundler::Molinillo::SpecificationProvider#name_for_explicit_dependency_source)
|
36
|
+
def name_for_explicit_dependency_source
|
37
|
+
with_no_such_dependency_error_handling do
|
38
|
+
specification_provider.name_for_explicit_dependency_source
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# (see Bundler::Molinillo::SpecificationProvider#name_for_locking_dependency_source)
|
43
|
+
def name_for_locking_dependency_source
|
44
|
+
with_no_such_dependency_error_handling do
|
45
|
+
specification_provider.name_for_locking_dependency_source
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# (see Bundler::Molinillo::SpecificationProvider#sort_dependencies)
|
50
|
+
def sort_dependencies(dependencies, activated, conflicts)
|
51
|
+
with_no_such_dependency_error_handling do
|
52
|
+
specification_provider.sort_dependencies(dependencies, activated, conflicts)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# (see Bundler::Molinillo::SpecificationProvider#allow_missing?)
|
57
|
+
def allow_missing?(dependency)
|
58
|
+
with_no_such_dependency_error_handling do
|
59
|
+
specification_provider.allow_missing?(dependency)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
# Ensures any raised {NoSuchDependencyError} has its
|
66
|
+
# {NoSuchDependencyError#required_by} set.
|
67
|
+
# @yield
|
68
|
+
def with_no_such_dependency_error_handling
|
69
|
+
yield
|
70
|
+
rescue NoSuchDependencyError => error
|
71
|
+
if state
|
72
|
+
vertex = activated.vertex_named(name_for(error.dependency))
|
73
|
+
error.required_by += vertex.incoming_edges.map { |e| e.origin.name }
|
74
|
+
error.required_by << name_for_explicit_dependency_source unless vertex.explicit_requirements.empty?
|
75
|
+
end
|
76
|
+
raise
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -2,6 +2,9 @@
|
|
2
2
|
require 'set'
|
3
3
|
require 'tsort'
|
4
4
|
|
5
|
+
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/log'
|
6
|
+
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex'
|
7
|
+
|
5
8
|
module Bundler::Molinillo
|
6
9
|
# A directed acyclic graph that is tuned to hold named dependencies
|
7
10
|
class DependencyGraph
|
@@ -10,15 +13,16 @@ module Bundler::Molinillo
|
|
10
13
|
# Enumerates through the vertices of the graph.
|
11
14
|
# @return [Array<Vertex>] The graph's vertices.
|
12
15
|
def each
|
16
|
+
return vertices.values.each unless block_given?
|
13
17
|
vertices.values.each { |v| yield v }
|
14
18
|
end
|
15
19
|
|
16
20
|
include TSort
|
17
21
|
|
18
|
-
#
|
22
|
+
# @!visibility private
|
19
23
|
alias tsort_each_node each
|
20
24
|
|
21
|
-
#
|
25
|
+
# @!visibility private
|
22
26
|
def tsort_each_child(vertex, &block)
|
23
27
|
vertex.successors.each(&block)
|
24
28
|
end
|
@@ -44,9 +48,27 @@ module Bundler::Molinillo
|
|
44
48
|
# by {Vertex#name}
|
45
49
|
attr_reader :vertices
|
46
50
|
|
51
|
+
# @return [Log] the op log for this graph
|
52
|
+
attr_reader :log
|
53
|
+
|
47
54
|
# Initializes an empty dependency graph
|
48
55
|
def initialize
|
49
56
|
@vertices = {}
|
57
|
+
@log = Log.new
|
58
|
+
end
|
59
|
+
|
60
|
+
# Tags the current state of the dependency as the given tag
|
61
|
+
# @param [Object] tag an opaque tag for the current state of the graph
|
62
|
+
# @return [Void]
|
63
|
+
def tag(tag)
|
64
|
+
log.tag(self, tag)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Rewinds the graph to the state tagged as `tag`
|
68
|
+
# @param [Object] tag the tag to rewind to
|
69
|
+
# @return [Void]
|
70
|
+
def rewind_to(tag)
|
71
|
+
log.rewind_to(self, tag)
|
50
72
|
end
|
51
73
|
|
52
74
|
# Initializes a copy of a {DependencyGraph}, ensuring that all {#vertices}
|
@@ -55,6 +77,7 @@ module Bundler::Molinillo
|
|
55
77
|
def initialize_copy(other)
|
56
78
|
super
|
57
79
|
@vertices = {}
|
80
|
+
@log = other.log.dup
|
58
81
|
traverse = lambda do |new_v, old_v|
|
59
82
|
return if new_v.outgoing_edges.size == old_v.outgoing_edges.size
|
60
83
|
old_v.outgoing_edges.each do |edge|
|
@@ -75,6 +98,22 @@ module Bundler::Molinillo
|
|
75
98
|
"#{self.class}:#{vertices.values.inspect}"
|
76
99
|
end
|
77
100
|
|
101
|
+
# @return [String] Returns a dot format representation of the graph
|
102
|
+
def to_dot
|
103
|
+
dot_vertices = []
|
104
|
+
dot_edges = []
|
105
|
+
vertices.each do |n, v|
|
106
|
+
dot_vertices << " #{n} [label=\"{#{n}|#{v.payload}}\"]"
|
107
|
+
v.outgoing_edges.each do |e|
|
108
|
+
dot_edges << " #{e.origin.name} -> #{e.destination.name} [label=\"#{e.requirement}\"]"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
dot_vertices.sort!
|
112
|
+
dot_edges.sort!
|
113
|
+
dot = dot_vertices.unshift('digraph G {').push('') + dot_edges.push('}')
|
114
|
+
dot.join("\n")
|
115
|
+
end
|
116
|
+
|
78
117
|
# @return [Boolean] whether the two dependency graphs are equal, determined
|
79
118
|
# by a recursive traversal of each {#root_vertices} and its
|
80
119
|
# {Vertex#successors}
|
@@ -93,12 +132,9 @@ module Bundler::Molinillo
|
|
93
132
|
# @param [Object] requirement the requirement that is requiring the child
|
94
133
|
# @return [void]
|
95
134
|
def add_child_vertex(name, payload, parent_names, requirement)
|
96
|
-
|
135
|
+
root = !parent_names.delete(nil) { true }
|
136
|
+
vertex = add_vertex(name, payload, root)
|
97
137
|
parent_names.each do |parent_name|
|
98
|
-
unless parent_name
|
99
|
-
vertex.root = true
|
100
|
-
next
|
101
|
-
end
|
102
138
|
parent_node = vertex_named(parent_name)
|
103
139
|
add_edge(parent_node, vertex, requirement)
|
104
140
|
end
|
@@ -110,10 +146,7 @@ module Bundler::Molinillo
|
|
110
146
|
# @param [Object] payload
|
111
147
|
# @return [Vertex] the vertex that was added to `self`
|
112
148
|
def add_vertex(name, payload, root = false)
|
113
|
-
|
114
|
-
vertex.payload ||= payload
|
115
|
-
vertex.root ||= root
|
116
|
-
vertex
|
149
|
+
log.add_vertex(self, name, payload, root)
|
117
150
|
end
|
118
151
|
|
119
152
|
# Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively
|
@@ -121,16 +154,7 @@ module Bundler::Molinillo
|
|
121
154
|
# @param [String] name
|
122
155
|
# @return [void]
|
123
156
|
def detach_vertex_named(name)
|
124
|
-
|
125
|
-
vertex.outgoing_edges.each do |e|
|
126
|
-
v = e.destination
|
127
|
-
v.incoming_edges.delete(e)
|
128
|
-
detach_vertex_named(v.name) unless v.root? || v.predecessors.any?
|
129
|
-
end
|
130
|
-
vertex.incoming_edges.each do |e|
|
131
|
-
v = e.origin
|
132
|
-
v.outgoing_edges.delete(e)
|
133
|
-
end
|
157
|
+
log.detach_vertex_named(self, name)
|
134
158
|
end
|
135
159
|
|
136
160
|
# @param [String] name
|
@@ -158,134 +182,22 @@ module Bundler::Molinillo
|
|
158
182
|
add_edge_no_circular(origin, destination, requirement)
|
159
183
|
end
|
160
184
|
|
185
|
+
# Sets the payload of the vertex with the given name
|
186
|
+
# @param [String] name the name of the vertex
|
187
|
+
# @param [Object] payload the payload
|
188
|
+
# @return [Void]
|
189
|
+
def set_payload(name, payload)
|
190
|
+
log.set_payload(self, name, payload)
|
191
|
+
end
|
192
|
+
|
161
193
|
private
|
162
194
|
|
163
195
|
# Adds a new {Edge} to the dependency graph without checking for
|
164
196
|
# circularity.
|
197
|
+
# @param (see #add_edge)
|
198
|
+
# @return (see #add_edge)
|
165
199
|
def add_edge_no_circular(origin, destination, requirement)
|
166
|
-
|
167
|
-
origin.outgoing_edges << edge
|
168
|
-
destination.incoming_edges << edge
|
169
|
-
edge
|
170
|
-
end
|
171
|
-
|
172
|
-
# A vertex in a {DependencyGraph} that encapsulates a {#name} and a
|
173
|
-
# {#payload}
|
174
|
-
class Vertex
|
175
|
-
# @return [String] the name of the vertex
|
176
|
-
attr_accessor :name
|
177
|
-
|
178
|
-
# @return [Object] the payload the vertex holds
|
179
|
-
attr_accessor :payload
|
180
|
-
|
181
|
-
# @return [Arrary<Object>] the explicit requirements that required
|
182
|
-
# this vertex
|
183
|
-
attr_reader :explicit_requirements
|
184
|
-
|
185
|
-
# @return [Boolean] whether the vertex is considered a root vertex
|
186
|
-
attr_accessor :root
|
187
|
-
alias root? root
|
188
|
-
|
189
|
-
# Initializes a vertex with the given name and payload.
|
190
|
-
# @param [String] name see {#name}
|
191
|
-
# @param [Object] payload see {#payload}
|
192
|
-
def initialize(name, payload)
|
193
|
-
@name = name
|
194
|
-
@payload = payload
|
195
|
-
@explicit_requirements = []
|
196
|
-
@outgoing_edges = []
|
197
|
-
@incoming_edges = []
|
198
|
-
end
|
199
|
-
|
200
|
-
# @return [Array<Object>] all of the requirements that required
|
201
|
-
# this vertex
|
202
|
-
def requirements
|
203
|
-
incoming_edges.map(&:requirement) + explicit_requirements
|
204
|
-
end
|
205
|
-
|
206
|
-
# @return [Array<Edge>] the edges of {#graph} that have `self` as their
|
207
|
-
# {Edge#origin}
|
208
|
-
attr_accessor :outgoing_edges
|
209
|
-
|
210
|
-
# @return [Array<Edge>] the edges of {#graph} that have `self` as their
|
211
|
-
# {Edge#destination}
|
212
|
-
attr_accessor :incoming_edges
|
213
|
-
|
214
|
-
# @return [Array<Vertex>] the vertices of {#graph} that have an edge with
|
215
|
-
# `self` as their {Edge#destination}
|
216
|
-
def predecessors
|
217
|
-
incoming_edges.map(&:origin)
|
218
|
-
end
|
219
|
-
|
220
|
-
# @return [Array<Vertex>] the vertices of {#graph} where `self` is a
|
221
|
-
# {#descendent?}
|
222
|
-
def recursive_predecessors
|
223
|
-
vertices = predecessors
|
224
|
-
vertices += vertices.map(&:recursive_predecessors).flatten(1)
|
225
|
-
vertices.uniq!
|
226
|
-
vertices
|
227
|
-
end
|
228
|
-
|
229
|
-
# @return [Array<Vertex>] the vertices of {#graph} that have an edge with
|
230
|
-
# `self` as their {Edge#origin}
|
231
|
-
def successors
|
232
|
-
outgoing_edges.map(&:destination)
|
233
|
-
end
|
234
|
-
|
235
|
-
# @return [Array<Vertex>] the vertices of {#graph} where `self` is an
|
236
|
-
# {#ancestor?}
|
237
|
-
def recursive_successors
|
238
|
-
vertices = successors
|
239
|
-
vertices += vertices.map(&:recursive_successors).flatten(1)
|
240
|
-
vertices.uniq!
|
241
|
-
vertices
|
242
|
-
end
|
243
|
-
|
244
|
-
# @return [String] a string suitable for debugging
|
245
|
-
def inspect
|
246
|
-
"#{self.class}:#{name}(#{payload.inspect})"
|
247
|
-
end
|
248
|
-
|
249
|
-
# @return [Boolean] whether the two vertices are equal, determined
|
250
|
-
# by a recursive traversal of each {Vertex#successors}
|
251
|
-
def ==(other)
|
252
|
-
shallow_eql?(other) &&
|
253
|
-
successors.to_set == other.successors.to_set
|
254
|
-
end
|
255
|
-
|
256
|
-
# @param [Vertex] other the other vertex to compare to
|
257
|
-
# @return [Boolean] whether the two vertices are equal, determined
|
258
|
-
# solely by {#name} and {#payload} equality
|
259
|
-
def shallow_eql?(other)
|
260
|
-
other &&
|
261
|
-
name == other.name &&
|
262
|
-
payload == other.payload
|
263
|
-
end
|
264
|
-
|
265
|
-
alias eql? ==
|
266
|
-
|
267
|
-
# @return [Fixnum] a hash for the vertex based upon its {#name}
|
268
|
-
def hash
|
269
|
-
name.hash
|
270
|
-
end
|
271
|
-
|
272
|
-
# Is there a path from `self` to `other` following edges in the
|
273
|
-
# dependency graph?
|
274
|
-
# @return true iff there is a path following edges within this {#graph}
|
275
|
-
def path_to?(other)
|
276
|
-
equal?(other) || successors.any? { |v| v.path_to?(other) }
|
277
|
-
end
|
278
|
-
|
279
|
-
alias descendent? path_to?
|
280
|
-
|
281
|
-
# Is there a path from `other` to `self` following edges in the
|
282
|
-
# dependency graph?
|
283
|
-
# @return true iff there is a path following edges within this {#graph}
|
284
|
-
def ancestor?(other)
|
285
|
-
other.path_to?(self)
|
286
|
-
end
|
287
|
-
|
288
|
-
alias is_reachable_from? ancestor?
|
200
|
+
log.add_edge_no_circular(self, origin.name, destination.name, requirement)
|
289
201
|
end
|
290
202
|
end
|
291
203
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Bundler::Molinillo
|
3
|
+
class DependencyGraph
|
4
|
+
# An action that modifies a {DependencyGraph} that is reversible.
|
5
|
+
# @abstract
|
6
|
+
class Action
|
7
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
8
|
+
|
9
|
+
# @return [Symbol] The name of the action.
|
10
|
+
def self.name
|
11
|
+
raise 'Abstract'
|
12
|
+
end
|
13
|
+
|
14
|
+
# Performs the action on the given graph.
|
15
|
+
# @param [DependencyGraph] graph the graph to perform the action on.
|
16
|
+
# @return [Void]
|
17
|
+
def up(graph)
|
18
|
+
raise 'Abstract'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Reverses the action on the given graph.
|
22
|
+
# @param [DependencyGraph] graph the graph to reverse the action on.
|
23
|
+
# @return [Void]
|
24
|
+
def down(graph)
|
25
|
+
raise 'Abstract'
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Action,Nil] The previous action
|
29
|
+
attr_accessor :previous
|
30
|
+
|
31
|
+
# @return [Action,Nil] The next action
|
32
|
+
attr_accessor :next
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'bundler/vendor/molinillo/lib/molinillo/dependency_graph/action'
|
3
|
+
module Bundler::Molinillo
|
4
|
+
class DependencyGraph
|
5
|
+
# @!visibility private
|
6
|
+
# (see DependencyGraph#add_edge_no_circular)
|
7
|
+
class AddEdgeNoCircular < Action
|
8
|
+
# @!group Action
|
9
|
+
|
10
|
+
# (see Action.name)
|
11
|
+
def self.name
|
12
|
+
:add_vertex
|
13
|
+
end
|
14
|
+
|
15
|
+
# (see Action#up)
|
16
|
+
def up(graph)
|
17
|
+
edge = make_edge(graph)
|
18
|
+
edge.origin.outgoing_edges << edge
|
19
|
+
edge.destination.incoming_edges << edge
|
20
|
+
edge
|
21
|
+
end
|
22
|
+
|
23
|
+
# (see Action#down)
|
24
|
+
def down(graph)
|
25
|
+
edge = make_edge(graph)
|
26
|
+
edge.origin.outgoing_edges.delete(edge)
|
27
|
+
edge.destination.incoming_edges.delete(edge)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @!group AddEdgeNoCircular
|
31
|
+
|
32
|
+
# @return [String] the name of the origin of the edge
|
33
|
+
attr_reader :origin
|
34
|
+
|
35
|
+
# @return [String] the name of the destination of the edge
|
36
|
+
attr_reader :destination
|
37
|
+
|
38
|
+
# @return [Object] the requirement that the edge represents
|
39
|
+
attr_reader :requirement
|
40
|
+
|
41
|
+
# @param [DependencyGraph] graph the graph to find vertices from
|
42
|
+
# @return [Edge] The edge this action adds
|
43
|
+
def make_edge(graph)
|
44
|
+
Edge.new(graph.vertex_named(origin), graph.vertex_named(destination), requirement)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Initialize an action to add an edge to a dependency graph
|
48
|
+
# @param [String] origin the name of the origin of the edge
|
49
|
+
# @param [String] destination the name of the destination of the edge
|
50
|
+
# @param [Object] requirement the requirement that the edge represents
|
51
|
+
def initialize(origin, destination, requirement)
|
52
|
+
@origin = origin
|
53
|
+
@destination = destination
|
54
|
+
@requirement = requirement
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|