molinillo 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07ba133d4a53675053e7dcd0951237049e522ea8
4
- data.tar.gz: 21ef570c95d650318652b77f24a68b46fa60b3db
3
+ metadata.gz: 201374a6119011f4e8aad27f0c594fd27a210707
4
+ data.tar.gz: d2ae554dca78b440d312ead38410706198eb2a2c
5
5
  SHA512:
6
- metadata.gz: cb2eb17979338fb368d96effa38d25aa7fc3a19e97e3c41dc4c4e36290260d00d43fe1b206481122d1b4e708963bbb43eb7833c868566e1ff4364840671b1797
7
- data.tar.gz: 2541587694311be9e41ee3f7778e996fcb01b5d5ad10b25d5a5db7cc00fbad5164b26f5b63ed4ec12534f19dcd3d18fa2ca6212c85ca7719d21094f27a139d4d
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
@@ -7,7 +7,7 @@ module Molinillo
7
7
  # rubocop:disable Lint/UnusedMethodArgument
8
8
 
9
9
  # @return [Symbol] The name of the action.
10
- def self.name
10
+ def self.action_name
11
11
  raise 'Abstract'
12
12
  end
13
13
 
@@ -7,8 +7,8 @@ module Molinillo
7
7
  class AddEdgeNoCircular < Action
8
8
  # @!group Action
9
9
 
10
- # (see Action.name)
11
- def self.name
10
+ # (see Action.action_name)
11
+ def self.action_name
12
12
  :add_vertex
13
13
  end
14
14
 
@@ -7,8 +7,8 @@ module Molinillo
7
7
  class AddVertex < Action # :nodoc:
8
8
  # @!group Action
9
9
 
10
- # (see Action.name)
11
- def self.name
10
+ # (see Action.action_name)
11
+ def self.action_name
12
12
  :add_vertex
13
13
  end
14
14
 
@@ -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
@@ -8,7 +8,7 @@ module Molinillo
8
8
  # @!group Action
9
9
 
10
10
  # (see Action#name)
11
- def self.name
11
+ def self.action_name
12
12
  :add_vertex
13
13
  end
14
14
 
@@ -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.name == :tag && action.tag == tag
106
+ break if action.class.action_name == :tag && action.tag == tag
96
107
  end
97
108
  end
98
109
 
@@ -7,8 +7,8 @@ module Molinillo
7
7
  class SetPayload < Action # :nodoc:
8
8
  # @!group Action
9
9
 
10
- # (see Action.name)
11
- def self.name
10
+ # (see Action.action_name)
11
+ def self.action_name
12
12
  :set_payload
13
13
  end
14
14
 
@@ -7,8 +7,8 @@ module Molinillo
7
7
  class Tag < Action
8
8
  # @!group Action
9
9
 
10
- # (see Action.name)
11
- def self.name
10
+ # (see Action.action_name)
11
+ def self.action_name
12
12
  :tag
13
13
  end
14
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Molinillo
3
3
  # The version of Molinillo.
4
- VERSION = '0.5.2'.freeze
4
+ VERSION = '0.5.3'.freeze
5
5
  end
@@ -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.requirement = matching_deps.first
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
 
@@ -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
@@ -32,6 +32,7 @@ module Molinillo
32
32
  dependency.satisfied_by?(spec.version)
33
33
  end
34
34
  end
35
+ @search_for[dependency].dup
35
36
  end
36
37
 
37
38
  def name_for(dependency)
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.2
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-24 00:00:00.000000000 Z
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