molinillo 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/molinillo/gem_metadata.rb +1 -1
- data/lib/molinillo/modules/specification_provider.rb +9 -0
- data/lib/molinillo/resolution.rb +27 -12
- data/lib/molinillo/state.rb +8 -0
- data/spec/resolver_spec.rb +18 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69f2c3781273e6f2e5c06758ed06c441691a9bcc
|
4
|
+
data.tar.gz: e43917b29522495a4108ad810a8ddc6879585fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 534b055dd96c322231c79e6624687764ad99bf67c8c15f0293320d695465b8041e7086f27bdff79b3378a568a5998b0ec2242a31043b52e1ee6f736839b0ebf8
|
7
|
+
data.tar.gz: f9c29fb00c70d2638086404f91baa6d0fc9b0c837aa28bd0819fa6dfd44f6466d33941241438cb45b88f066ec97025cf79f611c5f6999b61fd56cd714eae215c
|
@@ -86,5 +86,14 @@ module Molinillo
|
|
86
86
|
]
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
# Returns whether this dependency, which has no possible matching
|
91
|
+
# specifications, can safely be ignored.
|
92
|
+
#
|
93
|
+
# @param [Object] dependency
|
94
|
+
# @return [Boolean] whether this dependency can safely be skipped.
|
95
|
+
def allow_missing?(dependency)
|
96
|
+
false
|
97
|
+
end
|
89
98
|
end
|
90
99
|
end
|
data/lib/molinillo/resolution.rb
CHANGED
@@ -93,7 +93,7 @@ module Molinillo
|
|
93
93
|
def start_resolution
|
94
94
|
@started_at = Time.now
|
95
95
|
|
96
|
-
|
96
|
+
handle_missing_or_push_dependency_state(initial_state)
|
97
97
|
|
98
98
|
debug { "Starting resolution (#{@started_at})" }
|
99
99
|
resolver_ui.before_resolution
|
@@ -116,7 +116,8 @@ module Molinillo
|
|
116
116
|
|
117
117
|
ResolutionState.new.members.each do |member|
|
118
118
|
define_method member do |*args, &block|
|
119
|
-
state
|
119
|
+
current_state = state || ResolutionState.empty
|
120
|
+
current_state.send(member, *args, &block)
|
120
121
|
end
|
121
122
|
end
|
122
123
|
|
@@ -397,19 +398,33 @@ module Molinillo
|
|
397
398
|
# requirements
|
398
399
|
# @param [Array] new_requirements
|
399
400
|
# @return [void]
|
400
|
-
def push_state_for_requirements(new_requirements)
|
401
|
-
new_requirements = sort_dependencies(new_requirements.uniq,
|
401
|
+
def push_state_for_requirements(new_requirements, new_activated = activated.dup)
|
402
|
+
new_requirements = sort_dependencies(new_requirements.uniq, new_activated, conflicts)
|
402
403
|
new_requirement = new_requirements.shift
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
new_requirement,
|
408
|
-
new_requirement ? search_for(new_requirement) : [],
|
409
|
-
depth,
|
410
|
-
conflicts.dup
|
404
|
+
new_name = new_requirement ? name_for(new_requirement) : ''
|
405
|
+
possibilities = new_requirement ? search_for(new_requirement) : []
|
406
|
+
handle_missing_or_push_dependency_state DependencyState.new(
|
407
|
+
new_name, new_requirements, new_activated,
|
408
|
+
new_requirement, possibilities, depth, conflicts.dup
|
411
409
|
)
|
412
410
|
end
|
411
|
+
|
412
|
+
# Pushes a new {DependencyState}.
|
413
|
+
# If the {#specification_provider} says to
|
414
|
+
# {SpecificationProvider#allow_missing?} that particular requirement, and
|
415
|
+
# there are no possibilities for that requirement, then `state` is not
|
416
|
+
# pushed, and the node in {#activated} is removed, and we continue
|
417
|
+
# resolving the remaining requirements.
|
418
|
+
# @param [DependencyState] state
|
419
|
+
# @return [void]
|
420
|
+
def handle_missing_or_push_dependency_state(state)
|
421
|
+
if state.requirement && state.possibilities.empty? && allow_missing?(state.requirement)
|
422
|
+
state.activated.detach_vertex_named(state.name)
|
423
|
+
push_state_for_requirements(state.requirements, state.activated)
|
424
|
+
else
|
425
|
+
states.push state
|
426
|
+
end
|
427
|
+
end
|
413
428
|
end
|
414
429
|
end
|
415
430
|
end
|
data/lib/molinillo/state.rb
CHANGED
@@ -17,6 +17,14 @@ module Molinillo
|
|
17
17
|
:conflicts
|
18
18
|
)
|
19
19
|
|
20
|
+
class ResolutionState
|
21
|
+
# Returns an empty resolution state
|
22
|
+
# @return [ResolutionState] an empty state
|
23
|
+
def self.empty
|
24
|
+
new(nil, [], DependencyGraph.new, nil, nil, 0, Set.new)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
20
28
|
# A state that encapsulates a set of {#requirements} with an {Array} of
|
21
29
|
# possibilities
|
22
30
|
class DependencyState < ResolutionState
|
data/spec/resolver_spec.rb
CHANGED
@@ -106,6 +106,24 @@ module Molinillo
|
|
106
106
|
@resolver.resolve([VersionKit::Dependency.new('missing', '3.0')], DependencyGraph.new)
|
107
107
|
end.message.should.match /required by `user-specified dependency`/
|
108
108
|
end
|
109
|
+
|
110
|
+
it 'can handle when allow_missing? returns true for the only requirement' do
|
111
|
+
dep = VersionKit::Dependency.new('missing', '3.0')
|
112
|
+
@resolver.specification_provider.stubs(:allow_missing?).with(dep).returns(true)
|
113
|
+
@resolver.resolve([dep], DependencyGraph.new).to_a.should == []
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'can handle when allow_missing? returns true for a nested requirement' do
|
117
|
+
index = TestIndex.new('awesome')
|
118
|
+
dep = VersionKit::Dependency.new('actionpack', '1.2.3')
|
119
|
+
@resolver.specification_provider.stubs(:allow_missing?).
|
120
|
+
with { |d| d.name == 'activesupport' }.returns(true)
|
121
|
+
@resolver.specification_provider.stubs(:search_for).
|
122
|
+
with { |d| d.name == 'activesupport' }.returns([])
|
123
|
+
@resolver.specification_provider.stubs(:search_for).
|
124
|
+
with { |d| d.name == 'actionpack' }.returns(index.search_for(dep))
|
125
|
+
@resolver.resolve([dep], DependencyGraph.new).map(&:payload).map(&:to_s).should == ['actionpack (1.2.3)']
|
126
|
+
end
|
109
127
|
end
|
110
128
|
end
|
111
129
|
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.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.4.
|
87
|
+
rubygems_version: 2.4.8
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Provides support for dependency resolution
|