molinillo 0.1.1 → 0.1.2

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: 5ca54c31b0225c0a70bd08056c807459893d8b05
4
- data.tar.gz: d044395b17ede295d35e8663bbeba8c5f0ab91c5
3
+ metadata.gz: 3c0e6948c750e17cfaf091e5cd1f94ac58e4bffe
4
+ data.tar.gz: 64427be3edf97f492aef46c7c6eb69f1e262e25e
5
5
  SHA512:
6
- metadata.gz: cbb0cc34b7ec121f29199e73115e1e1b6231662325c36852ca552c894e031e533adc996c56642a61e60f6410234006dcc42de20068c15bc8c49cd15629c3abdc
7
- data.tar.gz: 30e5ffb3e3bd50da99a14cccdf3d3eecc34c8c5887f3c1503913e97c4f311303cd0d0e982ccfd6e1853173ba0b3a5b28216b84e00fb3e008937283c619a834b9
6
+ metadata.gz: 2e11fb6bebe0f6797d7c855cfe92aef39054a7d82cccb9e6b78b080bb69bdb9455aa4e8b13fc613a4acd3c430fb3a6faf96ae5d63663404f377a95bbc417136e
7
+ data.tar.gz: e4d395af07f86d361e5fa47c13e098f3ee77f4f878311a93c9a64bcbc87d1775837233f2096ccc84196a2b13c68586852097ad1e866e9814e09212a8d82c5dda
@@ -102,6 +102,7 @@ module Molinillo
102
102
  # @return [void]
103
103
  def detach_vertex_named(name)
104
104
  vertex = vertex_named(name)
105
+ return unless vertex
105
106
  successors = vertex.successors
106
107
  vertices.delete(name)
107
108
  edges.reject! { |e| e.origin == vertex || e.destination == vertex }
@@ -1,3 +1,3 @@
1
1
  module Molinillo
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -3,12 +3,14 @@ module Molinillo
3
3
  # A specific resolution from a given {Resolver}
4
4
  class Resolution
5
5
  # A conflict that the resolution process encountered
6
+ # @attr [Object] requirement the requirement that immediately led to the conflict
6
7
  # @attr [{String,Nil=>[Object]}] requirements the requirements that caused the conflict
7
8
  # @attr [Object, nil] existing the existing spec that was in conflict with
8
9
  # the {#possibility}
9
10
  # @attr [Object] possibility the spec that was unable to be activated due
10
11
  # to a conflict
11
12
  Conflict = Struct.new(
13
+ :requirement,
12
14
  :requirements,
13
15
  :existing,
14
16
  :possibility
@@ -55,7 +57,7 @@ module Molinillo
55
57
  break unless state.requirements.any? || state.requirement
56
58
  indicate_progress
57
59
  if state.respond_to?(:pop_possibility_state) # DependencyState
58
- debug(depth) { "Creating possibility state (#{possibilities.count} remaining)" }
60
+ debug(depth) { "Creating possibility state for #{requirement} (#{possibilities.count} remaining)" }
59
61
  state.pop_possibility_state.tap { |s| states.push(s) if s }
60
62
  end
61
63
  process_topmost_state
@@ -172,15 +174,27 @@ module Molinillo
172
174
  # Unwinds the states stack because a conflict has been encountered
173
175
  # @return [void]
174
176
  def unwind_for_conflict
175
- if depth > 0
176
- debug(depth) { 'Unwinding from level ' + state.depth.to_s }
177
- conflicts.tap do |c|
178
- states.pop
179
- state.conflicts = c
180
- end
181
- else
182
- raise VersionConflict.new(conflicts)
177
+ debug(depth) { "Unwinding for conflict: #{requirement}" }
178
+ conflicts.tap do |c|
179
+ states.slice!(state_index_for_unwind..-1)
180
+ states.pop if state
181
+ raise VersionConflict.new(c) unless state
182
+ state.conflicts = c
183
+ end
184
+ end
185
+
186
+ # @return [Integer] The index to which the resolution should unwind in the
187
+ # case of conflict.
188
+ def state_index_for_unwind
189
+ index = states.rindex do |state|
190
+ return nil unless vertex = state.activated.vertex_named(name)
191
+ state.is_a?(DependencyState) &&
192
+ (
193
+ !vertex.payload ||
194
+ (!state.requirements.include?(requirement) && state.requirement != requirement)
195
+ )
183
196
  end
197
+ index + 2
184
198
  end
185
199
 
186
200
  # @return [Conflict] a {Conflict} that reflects the failure to activate
@@ -194,7 +208,8 @@ module Molinillo
194
208
  }
195
209
  vertex.incoming_edges.each { |edge| (requirements[edge.origin.payload] ||= []).unshift(*edge.requirements) }
196
210
  conflicts[name] = Conflict.new(
197
- requirements,
211
+ requirement,
212
+ Hash[requirements.select { |_, r| !r.empty? }],
198
213
  existing,
199
214
  possibility
200
215
  )
@@ -229,7 +244,8 @@ module Molinillo
229
244
  def attempt_to_activate
230
245
  debug(depth) { 'Attempting to activate ' + possibility.to_s }
231
246
  existing_node = activated.vertex_named(name)
232
- if existing_node && existing_node.payload
247
+ if existing_node.payload
248
+ debug(depth) { "Found existing spec (#{existing_node.payload})" }
233
249
  attempt_to_activate_existing_spec(existing_node)
234
250
  else
235
251
  attempt_to_activate_new_spec
@@ -246,7 +262,7 @@ module Molinillo
246
262
  push_state_for_requirements(new_requirements)
247
263
  else
248
264
  create_conflict
249
- debug(depth) { 'Unsatisfied by existing spec' }
265
+ debug(depth) { "Unsatisfied by existing spec (#{existing_node.payload})" }
250
266
  unwind_for_conflict
251
267
  end
252
268
  end
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.1.1
4
+ version: 0.1.2
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: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler