solve 0.4.0.rc1 → 0.4.0
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.
- data/Gemfile +1 -1
- data/lib/solve/gem_version.rb +1 -1
- data/lib/solve/solver.rb +22 -4
- data/spec/acceptance/solutions_spec.rb +33 -0
- metadata +8 -5
data/Gemfile
CHANGED
@@ -27,7 +27,7 @@ group :development do
|
|
27
27
|
end rescue Errno::ENOENT
|
28
28
|
|
29
29
|
elsif RbConfig::CONFIG['target_os'] =~ /linux/i
|
30
|
-
gem 'libnotify', '~> 0.
|
30
|
+
gem 'libnotify', '~> 0.8.0', require: false
|
31
31
|
gem 'rb-inotify', require: false
|
32
32
|
|
33
33
|
elsif RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
data/lib/solve/gem_version.rb
CHANGED
data/lib/solve/solver.rb
CHANGED
@@ -96,6 +96,10 @@ module Solve
|
|
96
96
|
while unbound_variable = variable_table.first_unbound
|
97
97
|
possible_values_for_unbound = possible_values_for(unbound_variable)
|
98
98
|
trace("Searching for a value for #{unbound_variable.artifact}")
|
99
|
+
trace("Constraints are")
|
100
|
+
constraint_table.constraints_on_artifact(unbound_variable.artifact).each do |constraint|
|
101
|
+
trace("\t#{constraint}")
|
102
|
+
end
|
99
103
|
trace("Possible values are #{possible_values_for_unbound}")
|
100
104
|
|
101
105
|
while possible_value = possible_values_for_unbound.shift
|
@@ -233,15 +237,29 @@ module Solve
|
|
233
237
|
constraint_table.add(dependency, source)
|
234
238
|
dependency_domain = graph.versions(dependency.name, dependency.constraint)
|
235
239
|
domain[dependency.name] = [(domain[dependency.name] || []), dependency_domain]
|
236
|
-
|
237
|
-
|
238
|
-
|
240
|
+
.flatten
|
241
|
+
.uniq
|
242
|
+
.sort { |left, right| right.version <=> left.version }
|
243
|
+
|
244
|
+
#if the variable we are constraining is still unbound, we want to filter
|
245
|
+
#its possible values, if its already bound, we know its ok to add this constraint because
|
246
|
+
#we can never change a previously bound value without removing this constraint and we check above
|
247
|
+
#whether or not its ok to add this constraint given the current value
|
248
|
+
|
249
|
+
variable = variable_table.find_artifact(dependency.name)
|
250
|
+
if variable.value.nil?
|
251
|
+
reset_possible_values_for(variable)
|
252
|
+
end
|
253
|
+
|
239
254
|
end
|
240
255
|
end
|
241
256
|
|
242
257
|
def reset_possible_values_for(variable)
|
258
|
+
trace("Resetting possible values for #{variable.artifact}")
|
243
259
|
possible_values[variable.artifact] = nil
|
244
|
-
possible_values_for(variable)
|
260
|
+
x = possible_values_for(variable)
|
261
|
+
trace("Possible values are #{x}")
|
262
|
+
x
|
245
263
|
end
|
246
264
|
|
247
265
|
def backtrack(unbound_variable)
|
@@ -158,4 +158,37 @@ describe "Solutions" do
|
|
158
158
|
"D" => "0.0.0"})
|
159
159
|
|
160
160
|
end
|
161
|
+
|
162
|
+
it "correctly resolves when a resolution exists but it is not the latest" do
|
163
|
+
graph = Solve::Graph.new
|
164
|
+
|
165
|
+
graph.artifacts("get-the-old-one", "1.0.0")
|
166
|
+
.depends("locked-mid-1", ">= 0.0.0")
|
167
|
+
.depends("locked-mid-2", ">= 0.0.0")
|
168
|
+
graph.artifacts("get-the-old-one", "0.5.0")
|
169
|
+
|
170
|
+
graph.artifacts("locked-mid-1", "2.0.0").depends("old-bottom", "= 2.0.0")
|
171
|
+
graph.artifacts("locked-mid-1", "1.3.0").depends("old-bottom", "= 0.5.0")
|
172
|
+
graph.artifacts("locked-mid-1", "1.0.0")
|
173
|
+
|
174
|
+
graph.artifacts("locked-mid-2", "2.0.0").depends("old-bottom", "= 2.1.0")
|
175
|
+
graph.artifacts("locked-mid-2", "1.4.0").depends("old-bottom", "= 0.5.0")
|
176
|
+
graph.artifacts("locked-mid-2", "1.0.0")
|
177
|
+
|
178
|
+
graph.artifacts("old-bottom", "2.1.0")
|
179
|
+
graph.artifacts("old-bottom", "2.0.0")
|
180
|
+
graph.artifacts("old-bottom", "1.0.0")
|
181
|
+
graph.artifacts("old-bottom", "0.5.0")
|
182
|
+
|
183
|
+
demands = [["get-the-old-one"]]
|
184
|
+
|
185
|
+
result = Solve.it!(graph, demands)
|
186
|
+
|
187
|
+
result.should eql({
|
188
|
+
"get-the-old-one" => "1.0.0",
|
189
|
+
"locked-mid-1" => "2.0.0",
|
190
|
+
"locked-mid-2" => "1.0.0",
|
191
|
+
"old-bottom" => "2.0.0"
|
192
|
+
})
|
193
|
+
end
|
161
194
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jamie Winsor
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-10-
|
14
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
@@ -88,9 +88,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- - ! '
|
91
|
+
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: '0'
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
hash: 1956860020299401788
|
94
97
|
requirements: []
|
95
98
|
rubyforge_project:
|
96
99
|
rubygems_version: 1.8.23
|