molinillo 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ea85c0037f78e6763d19bf7d8144c33eccb1a28
4
- data.tar.gz: da1f09939f213f0e93bc644a8ba021000c79db9e
3
+ metadata.gz: 27a5127f777d4d2241afc7f5c7835805688f3735
4
+ data.tar.gz: 59355f73e74c7ecb33ffae6d07eebb865efa2126
5
5
  SHA512:
6
- metadata.gz: a84d8bde06c58dcf77fe69d9128c964a35077226a8cb5b9f9af6d4aa78592426491b35e62371565d2654f035302a7797deda05584c778e6d58e4575291bc5c5e
7
- data.tar.gz: 40f4b4b9282474acee27715541f6d2f3c5153b1e333c1ed84f42d04aa09f8aeb4e024f6010abae83d958c41baa7c596002a2457c69ec008573efccac9824cf93
6
+ metadata.gz: e6a5abe9e0e3b9a15e7dc26d03a77e9710cddcc58c53b3a572e93925711d52481e422dc9e8436a0629e1170bde42dabe9181831465d915e884bfbe5f807f4043
7
+ data.tar.gz: 56c23925d436aa33cb9ac8998abf464b4bb72e6c6b3b6404916ae76632e7ec347e1a9975993a21ca7d69dd85c3215a52641c688a2e14bc0452de218086230971
@@ -126,6 +126,10 @@ module Molinillo
126
126
  v.incoming_edges.delete(e)
127
127
  detach_vertex_named(v.name) unless v.root? || v.predecessors.any?
128
128
  end
129
+ vertex.incoming_edges.each do |e|
130
+ v = e.origin
131
+ v.outgoing_edges.delete(e)
132
+ end
129
133
  end
130
134
 
131
135
  # @param [String] name
@@ -1,4 +1,4 @@
1
1
  module Molinillo
2
2
  # The version of Molinillo.
3
- VERSION = '0.4.1'.freeze
3
+ VERSION = '0.4.2'.freeze
4
4
  end
@@ -57,7 +57,8 @@ module Molinillo
57
57
  #
58
58
  # @return [Boolean]
59
59
  def debug?
60
- @debug_mode ||= ENV['MOLINILLO_DEBUG']
60
+ return @debug_mode if defined?(@debug_mode)
61
+ @debug_mode = ENV['MOLINILLO_DEBUG']
61
62
  end
62
63
  end
63
64
  end
@@ -341,26 +341,36 @@ module Molinillo
341
341
  # @return [Boolean] Whether the possibility was swapped into {#activated}
342
342
  def attempt_to_swap_possibility
343
343
  swapped = activated.dup
344
- swapped.vertex_named(name).payload = possibility
345
- return unless swapped.vertex_named(name).requirements.
344
+ vertex = swapped.vertex_named(name)
345
+ vertex.payload = possibility
346
+ return unless vertex.requirements.
346
347
  all? { |r| requirement_satisfied_by?(r, swapped, possibility) }
347
- attempt_to_activate_new_spec
348
+ return unless new_spec_satisfied?
349
+ actual_vertex = activated.vertex_named(name)
350
+ actual_vertex.payload = possibility
351
+ fixup_swapped_children(actual_vertex)
352
+ activate_spec
353
+ end
354
+
355
+ # Ensures there are no orphaned successors to the given {vertex}.
356
+ # @param [DependencyGraph::Vertex] vertex the vertex to fix up.
357
+ # @return [void]
358
+ def fixup_swapped_children(vertex)
359
+ payload = vertex.payload
360
+ dep_names = dependencies_for(payload).map(&method(:name_for))
361
+ vertex.successors.each do |succ|
362
+ if !dep_names.include?(succ.name) && !succ.root? && succ.predecessors.to_a == [vertex]
363
+ debug(depth) { "Removing orphaned spec #{succ.name} after swapping #{name}" }
364
+ activated.detach_vertex_named(succ.name)
365
+ end
366
+ end
348
367
  end
349
368
 
350
369
  # Attempts to activate the current {#possibility} (given that it hasn't
351
370
  # already been activated)
352
371
  # @return [void]
353
372
  def attempt_to_activate_new_spec
354
- satisfied = begin
355
- locked_requirement = locked_requirement_named(name)
356
- requested_spec_satisfied = requirement_satisfied_by?(requirement, activated, possibility)
357
- locked_spec_satisfied = !locked_requirement ||
358
- requirement_satisfied_by?(locked_requirement, activated, possibility)
359
- debug(depth) { 'Unsatisfied by requested spec' } unless requested_spec_satisfied
360
- debug(depth) { 'Unsatisfied by locked spec' } unless locked_spec_satisfied
361
- requested_spec_satisfied && locked_spec_satisfied
362
- end
363
- if satisfied
373
+ if new_spec_satisfied?
364
374
  activate_spec
365
375
  else
366
376
  create_conflict
@@ -368,6 +378,18 @@ module Molinillo
368
378
  end
369
379
  end
370
380
 
381
+ # @return [Boolean] whether the current spec is satisfied as a new
382
+ # possibility.
383
+ def new_spec_satisfied?
384
+ locked_requirement = locked_requirement_named(name)
385
+ requested_spec_satisfied = requirement_satisfied_by?(requirement, activated, possibility)
386
+ locked_spec_satisfied = !locked_requirement ||
387
+ requirement_satisfied_by?(locked_requirement, activated, possibility)
388
+ debug(depth) { 'Unsatisfied by requested spec' } unless requested_spec_satisfied
389
+ debug(depth) { 'Unsatisfied by locked spec' } unless locked_spec_satisfied
390
+ requested_spec_satisfied && locked_spec_satisfied
391
+ end
392
+
371
393
  # @param [String] requirement_name the spec name to search for
372
394
  # @return [Object] the locked spec named `requirement_name`, if one
373
395
  # is found on {#base}
@@ -393,7 +415,7 @@ module Molinillo
393
415
  # @return [void]
394
416
  def require_nested_dependencies_for(activated_spec)
395
417
  nested_dependencies = dependencies_for(activated_spec)
396
- debug(depth) { "Requiring nested dependencies (#{nested_dependencies.map(&:to_s).join(', ')})" }
418
+ debug(depth) { "Requiring nested dependencies (#{nested_dependencies.join(', ')})" }
397
419
  nested_dependencies.each { |d| activated.add_child_vertex(name_for(d), nil, [name_for(activated_spec)], d) }
398
420
 
399
421
  push_state_for_requirements(requirements + nested_dependencies, nested_dependencies.size > 0)
@@ -59,6 +59,15 @@ module Molinillo
59
59
  expect(child.predecessors).to eq([root2])
60
60
  expect(@graph.vertices.count).to eq(2)
61
61
  end
62
+
63
+ it 'detaches a vertex with predecessors' do
64
+ parent = @graph.add_vertex('parent', 'parent', true)
65
+ child = @graph.add_child_vertex('child', 'child', %w(parent), 'child')
66
+ @graph.detach_vertex_named(child.name)
67
+ expect(@graph.vertex_named(child.name)).to be_nil
68
+ expect(@graph.vertices).to eq(parent.name => parent)
69
+ expect(parent.outgoing_edges).to be_empty
70
+ end
62
71
  end
63
72
  end
64
73
  end
@@ -4,7 +4,7 @@ require 'json'
4
4
  require 'open-uri'
5
5
  require 'set'
6
6
 
7
- GEMS = %w(rails capybara bundler).freeze
7
+ GEMS = %w(rails capybara bundler mail).freeze
8
8
 
9
9
  VERSION_PATTERN = /\A
10
10
  [0-9]+\.[0-9]+\.[0-9]+ (?# Number component)
@@ -63,7 +63,7 @@ specs = specs.group_by { |s| s['name'] }.values.map do |spec|
63
63
  {
64
64
  'name' => s['name'],
65
65
  'version' => coerce_to_semver(s['number']),
66
- 'dependencies' => coerce_dependencies_to_semver(Hash[s['dependencies']])
66
+ 'dependencies' => coerce_dependencies_to_semver(s['dependencies'].sort_by(&:first))
67
67
  }
68
68
  end.uniq { |s| s['version'] }.sort_by { |s| Gem::Version.new(s['version']) }
69
69
  ]
@@ -77,9 +77,9 @@ module Molinillo
77
77
  result = resolve.call
78
78
 
79
79
  pretty_dependencies = lambda do |dg|
80
- dg.vertices.values.map { |v| "#{v.payload.name} (#{v.payload.version})" }.sort
80
+ dg.vertices.values.map { |v| "#{v.name} (#{v.payload && v.payload.version})" }
81
81
  end
82
- expect(pretty_dependencies.call(result)).to eq(pretty_dependencies.call(test_case.result))
82
+ expect(pretty_dependencies.call(result)).to contain_exactly(*pretty_dependencies.call(test_case.result))
83
83
 
84
84
  expect(result).to eq(test_case.result)
85
85
  end
data/spec/spec_helper.rb CHANGED
@@ -29,3 +29,8 @@ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
29
29
 
30
30
  require 'version_kit'
31
31
  require 'molinillo'
32
+
33
+ RSpec.configure do |config|
34
+ # Enable flags like --only-failures and --next-failure
35
+ config.example_status_persistence_file_path = '.rspec_status'
36
+ end
@@ -18,5 +18,9 @@ module Molinillo
18
18
  def to_s
19
19
  "#{name} (#{version})"
20
20
  end
21
+
22
+ def inspect
23
+ "#<#{self.class} name=#{name} version=#{version} dependencies=[#{dependencies.join(', ')}]>"
24
+ end
21
25
  end
22
26
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: molinillo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.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: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description:
@@ -74,12 +74,12 @@ require_paths:
74
74
  - lib
75
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - '>='
77
+ - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []