molinillo 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/molinillo/dependency_graph.rb +7 -0
- data/lib/molinillo/dependency_graph/action.rb +1 -1
- data/lib/molinillo/dependency_graph/add_edge_no_circular.rb +2 -2
- data/lib/molinillo/dependency_graph/add_vertex.rb +2 -2
- data/lib/molinillo/dependency_graph/delete_edge.rb +62 -0
- data/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
- data/lib/molinillo/dependency_graph/log.rb +12 -1
- data/lib/molinillo/dependency_graph/set_payload.rb +2 -2
- data/lib/molinillo/dependency_graph/tag.rb +2 -2
- data/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/molinillo/resolution.rb +2 -2
- data/spec/resolver_spec.rb +41 -0
- data/spec/spec_helper/index.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 201374a6119011f4e8aad27f0c594fd27a210707
|
4
|
+
data.tar.gz: d2ae554dca78b440d312ead38410706198eb2a2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c5b13bda9d0865e3d0b2d836325db2548757d9e145798401cbd59737e6378c30d46378c65a683742e0db8aa903629d002a839bacad78320ccf5dfd2e81f541
|
7
|
+
data.tar.gz: bfc7c83391e307a8dbb03321c356cb300c75ad3e27c1ddda1ee207467dabe1089a8671f6c95f35de6b2a9cb4d4e5fe0d41a7bb68724254e38d3cbbc4defae685
|
@@ -182,6 +182,13 @@ module Molinillo
|
|
182
182
|
add_edge_no_circular(origin, destination, requirement)
|
183
183
|
end
|
184
184
|
|
185
|
+
# Deletes an {Edge} from the dependency graph
|
186
|
+
# @param [Edge] edge
|
187
|
+
# @return [Void]
|
188
|
+
def delete_edge(edge)
|
189
|
+
log.delete_edge(self, edge.origin.name, edge.destination.name, edge.requirement)
|
190
|
+
end
|
191
|
+
|
185
192
|
# Sets the payload of the vertex with the given name
|
186
193
|
# @param [String] name the name of the vertex
|
187
194
|
# @param [Object] payload the payload
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'molinillo/dependency_graph/action'
|
3
|
+
module Molinillo
|
4
|
+
class DependencyGraph
|
5
|
+
# @!visibility private
|
6
|
+
# (see DependencyGraph#delete_edge)
|
7
|
+
class DeleteEdge < Action
|
8
|
+
# @!group Action
|
9
|
+
|
10
|
+
# (see Action.action_name)
|
11
|
+
def self.action_name
|
12
|
+
:delete_edge
|
13
|
+
end
|
14
|
+
|
15
|
+
# (see Action#up)
|
16
|
+
def up(graph)
|
17
|
+
edge = make_edge(graph)
|
18
|
+
edge.origin.outgoing_edges.delete(edge)
|
19
|
+
edge.destination.incoming_edges.delete(edge)
|
20
|
+
end
|
21
|
+
|
22
|
+
# (see Action#down)
|
23
|
+
def down(graph)
|
24
|
+
edge = make_edge(graph)
|
25
|
+
edge.origin.outgoing_edges << edge
|
26
|
+
edge.destination.incoming_edges << edge
|
27
|
+
edge
|
28
|
+
end
|
29
|
+
|
30
|
+
# @!group DeleteEdge
|
31
|
+
|
32
|
+
# @return [String] the name of the origin of the edge
|
33
|
+
attr_reader :origin_name
|
34
|
+
|
35
|
+
# @return [String] the name of the destination of the edge
|
36
|
+
attr_reader :destination_name
|
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(
|
45
|
+
graph.vertex_named(origin_name),
|
46
|
+
graph.vertex_named(destination_name),
|
47
|
+
requirement
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Initialize an action to add an edge to a dependency graph
|
52
|
+
# @param [String] origin_name the name of the origin of the edge
|
53
|
+
# @param [String] destination_name the name of the destination of the edge
|
54
|
+
# @param [Object] requirement the requirement that the edge represents
|
55
|
+
def initialize(origin_name, destination_name, requirement)
|
56
|
+
@origin_name = origin_name
|
57
|
+
@destination_name = destination_name
|
58
|
+
@requirement = requirement
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'molinillo/dependency_graph/add_edge_no_circular'
|
3
3
|
require 'molinillo/dependency_graph/add_vertex'
|
4
|
+
require 'molinillo/dependency_graph/delete_edge'
|
4
5
|
require 'molinillo/dependency_graph/detach_vertex_named'
|
5
6
|
require 'molinillo/dependency_graph/set_payload'
|
6
7
|
require 'molinillo/dependency_graph/tag'
|
@@ -40,6 +41,16 @@ module Molinillo
|
|
40
41
|
push_action(graph, AddEdgeNoCircular.new(origin, destination, requirement))
|
41
42
|
end
|
42
43
|
|
44
|
+
# {include:DependencyGraph#delete_edge}
|
45
|
+
# @param [Graph] graph the graph to perform the action on
|
46
|
+
# @param [String] origin_name
|
47
|
+
# @param [String] destination_name
|
48
|
+
# @param [Object] requirement
|
49
|
+
# @return (see DependencyGraph#delete_edge)
|
50
|
+
def delete_edge(graph, origin_name, destination_name, requirement)
|
51
|
+
push_action(graph, DeleteEdge.new(origin_name, destination_name, requirement))
|
52
|
+
end
|
53
|
+
|
43
54
|
# @macro action
|
44
55
|
def set_payload(graph, name, payload)
|
45
56
|
push_action(graph, SetPayload.new(name, payload))
|
@@ -92,7 +103,7 @@ module Molinillo
|
|
92
103
|
loop do
|
93
104
|
action = pop!(graph)
|
94
105
|
raise "No tag #{tag.inspect} found" unless action
|
95
|
-
break if action.class.
|
106
|
+
break if action.class.action_name == :tag && action.tag == tag
|
96
107
|
end
|
97
108
|
end
|
98
109
|
|
data/lib/molinillo/resolution.rb
CHANGED
@@ -373,9 +373,9 @@ module Molinillo
|
|
373
373
|
(requirement_name == succ.name) || all_successor_names.include?(requirement_name)
|
374
374
|
end
|
375
375
|
elsif !matching_deps.include?(outgoing_edge.requirement)
|
376
|
-
outgoing_edge
|
376
|
+
activated.delete_edge(outgoing_edge)
|
377
|
+
requirements.delete(outgoing_edge.requirement)
|
377
378
|
end
|
378
|
-
matching_deps.delete(outgoing_edge.requirement)
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
data/spec/resolver_spec.rb
CHANGED
@@ -242,6 +242,47 @@ module Molinillo
|
|
242
242
|
expect(resolved.map(&:payload).map(&:to_s).sort).to eq(expected.sort)
|
243
243
|
end
|
244
244
|
|
245
|
+
it 'can resolve when swapping changes transitive dependencies' do
|
246
|
+
index = TestIndex.new('restkit')
|
247
|
+
def index.sort_dependencies(dependencies, activated, conflicts)
|
248
|
+
dependencies.sort_by do |d|
|
249
|
+
[
|
250
|
+
activated.vertex_named(d.name).payload ? 0 : 1,
|
251
|
+
dependency_pre_release?(d) ? 0 : 1,
|
252
|
+
conflicts[d.name] ? 0 : 1,
|
253
|
+
search_for(d).count,
|
254
|
+
]
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def index.requirement_satisfied_by?(requirement, activated, spec)
|
259
|
+
existing_vertices = activated.vertices.values.select do |v|
|
260
|
+
v.name.split('/').first == requirement.name.split('/').first
|
261
|
+
end
|
262
|
+
existing = existing_vertices.map(&:payload).compact.first
|
263
|
+
if existing
|
264
|
+
existing.version == spec.version && requirement.satisfied_by?(spec.version)
|
265
|
+
else
|
266
|
+
requirement.satisfied_by? spec.version
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
@resolver = described_class.new(index, TestUI.new)
|
271
|
+
demands = [
|
272
|
+
VersionKit::Dependency.new('RestKit', '~> 0.23.0'),
|
273
|
+
VersionKit::Dependency.new('RestKit', '<= 0.23.2'),
|
274
|
+
]
|
275
|
+
|
276
|
+
resolved = @resolver.resolve(demands, DependencyGraph.new)
|
277
|
+
|
278
|
+
expected = [
|
279
|
+
'RestKit (0.23.2)',
|
280
|
+
'RestKit/Core (0.23.2)',
|
281
|
+
]
|
282
|
+
|
283
|
+
expect(resolved.map(&:payload).map(&:to_s)).to match_array(expected)
|
284
|
+
end
|
285
|
+
|
245
286
|
# Regression test. See: https://github.com/CocoaPods/Molinillo/pull/38
|
246
287
|
it 'can resolve when swapping children with successors' do
|
247
288
|
swap_child_with_successors_index = Class.new(TestIndex) do
|
data/spec/spec_helper/index.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: molinillo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel E. Giddins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/molinillo/dependency_graph/action.rb
|
55
55
|
- lib/molinillo/dependency_graph/add_edge_no_circular.rb
|
56
56
|
- lib/molinillo/dependency_graph/add_vertex.rb
|
57
|
+
- lib/molinillo/dependency_graph/delete_edge.rb
|
57
58
|
- lib/molinillo/dependency_graph/detach_vertex_named.rb
|
58
59
|
- lib/molinillo/dependency_graph/log.rb
|
59
60
|
- lib/molinillo/dependency_graph/set_payload.rb
|