solve 3.1.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe "Solutions when using the ruby solver" do
4
4
 
@@ -12,7 +12,7 @@ describe "Solutions when using the ruby solver" do
12
12
  graph.artifact("mysql", "1.2.0")
13
13
  graph.artifact("nginx", "1.0.0").depends("mysql", "= 1.2.0")
14
14
 
15
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
15
+ result = Solve.it!(graph, [["nginx", "= 1.0.0"], ["mysql"]])
16
16
 
17
17
  result.should eql("nginx" => "1.0.0", "mysql" => "1.2.0")
18
18
  end
@@ -23,7 +23,7 @@ describe "Solutions when using the ruby solver" do
23
23
  graph.artifact("mysql", "1.2.0")
24
24
  graph.artifact("nginx", "1.0.0").depends("mysql", ">= 1.2.0")
25
25
 
26
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
26
+ result = Solve.it!(graph, [["nginx", "= 1.0.0"], ["mysql"]])
27
27
 
28
28
  result.should eql("nginx" => "1.0.0", "mysql" => "2.0.0")
29
29
  end
@@ -33,7 +33,7 @@ describe "Solutions when using the ruby solver" do
33
33
  graph.artifact("mysql", "1.2.0")
34
34
 
35
35
  lambda {
36
- Solve.it!(graph, ['mysql', '>= 2.0.0'])
36
+ Solve.it!(graph, ["mysql", ">= 2.0.0"])
37
37
  }.should raise_error(Solve::Errors::NoSolutionError)
38
38
  end
39
39
 
@@ -62,8 +62,7 @@ describe "Solutions when using the ruby solver" do
62
62
  graph.artifact("A", "1.0.2").depends("B", "> 1.0.0")
63
63
  graph.artifact("A", "1.0.2").depends("C", "= 2.0.0")
64
64
 
65
- result = Solve.it!(graph, [['A', '~> 1.0.0'], ['D', ">= 2.0.0"]])
66
-
65
+ result = Solve.it!(graph, [["A", "~> 1.0.0"], ["D", ">= 2.0.0"]])
67
66
 
68
67
  result.should eql("A" => "1.0.1",
69
68
  "B" => "2.1.0",
@@ -151,9 +150,9 @@ describe "Solutions when using the ruby solver" do
151
150
  graph.artifact("bottom", "1.0.0")
152
151
  graph.artifact("middle", "1.0.0").depends("top", "= 1.0.0").depends("middle")
153
152
 
154
- demands = [["bottom", "1.0.0"],["middle", "1.0.0"]]
153
+ demands = [["bottom", "1.0.0"], ["middle", "1.0.0"]]
155
154
 
156
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
155
+ expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
157
156
  error.should be_a(Solve::Errors::NoSolutionError)
158
157
  }
159
158
  end
@@ -203,7 +202,7 @@ describe "Solutions when using the ruby solver" do
203
202
  result.should eql({ "A" => "0.0.0",
204
203
  "B" => "0.0.0",
205
204
  "C" => "0.0.0",
206
- "D" => "0.0.0"})
205
+ "D" => "0.0.0" })
207
206
 
208
207
  end
209
208
 
@@ -243,7 +242,7 @@ describe "Solutions when using the ruby solver" do
243
242
  "get-the-old-one" => "1.0.0",
244
243
  "locked-mid-1" => "2.0.0",
245
244
  "locked-mid-2" => "1.0.0",
246
- "old-bottom" => "2.0.0"
245
+ "old-bottom" => "2.0.0",
247
246
  })
248
247
  end
249
248
 
@@ -263,7 +262,7 @@ describe "Solutions when using the ruby solver" do
263
262
  result.should eql([
264
263
  ["C", "1.0.0"],
265
264
  ["B", "1.0.0"],
266
- ["A", "1.0.0"]
265
+ ["A", "1.0.0"],
267
266
  ])
268
267
  end
269
268
  end
@@ -278,14 +277,14 @@ describe "Solutions when using the ruby solver" do
278
277
  graph.artifact("A", "1.0.0").depends("C", "= 1.0.0")
279
278
  graph.artifact("C", "1.0.0")
280
279
 
281
- demands = [["A"],["B"]]
280
+ demands = [["A"], ["B"]]
282
281
 
283
- result = Solve.it!(graph, demands, { :sorted => true } )
282
+ result = Solve.it!(graph, demands, { :sorted => true } )
284
283
 
285
284
  result.should eql([
286
285
  ["C", "1.0.0"],
287
286
  ["A", "1.0.0"],
288
- ["B", "1.0.0"]
287
+ ["B", "1.0.0"],
289
288
  ])
290
289
  end
291
290
  end
@@ -300,7 +299,7 @@ describe "Solutions when using the ruby solver" do
300
299
 
301
300
  demands = [["A"]]
302
301
 
303
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error(Solve::Errors::NoSolutionError)
302
+ expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error(Solve::Errors::NoSolutionError)
304
303
  end
305
304
  end
306
305
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe "Solutions", :gecode do
4
4
 
@@ -12,7 +12,7 @@ describe "Solutions", :gecode do
12
12
  graph.artifact("mysql", "1.2.0")
13
13
  graph.artifact("nginx", "1.0.0").depends("mysql", "= 1.2.0")
14
14
 
15
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
15
+ result = Solve.it!(graph, [["nginx", "= 1.0.0"], ["mysql"]])
16
16
 
17
17
  result.should eql("nginx" => "1.0.0", "mysql" => "1.2.0")
18
18
  end
@@ -23,7 +23,7 @@ describe "Solutions", :gecode do
23
23
  graph.artifact("mysql", "1.2.0")
24
24
  graph.artifact("nginx", "1.0.0").depends("mysql", ">= 1.2.0")
25
25
 
26
- result = Solve.it!(graph, [['nginx', '= 1.0.0'], ['mysql']])
26
+ result = Solve.it!(graph, [["nginx", "= 1.0.0"], ["mysql"]])
27
27
 
28
28
  result.should eql("nginx" => "1.0.0", "mysql" => "2.0.0")
29
29
  end
@@ -33,7 +33,7 @@ describe "Solutions", :gecode do
33
33
  graph.artifact("mysql", "1.2.0")
34
34
 
35
35
  lambda {
36
- Solve.it!(graph, ['mysql', '>= 2.0.0'])
36
+ Solve.it!(graph, ["mysql", ">= 2.0.0"])
37
37
  }.should raise_error(Solve::Errors::NoSolutionError)
38
38
  end
39
39
 
@@ -62,8 +62,7 @@ describe "Solutions", :gecode do
62
62
  graph.artifact("A", "1.0.2").depends("B", "> 1.0.0")
63
63
  graph.artifact("A", "1.0.2").depends("C", "= 2.0.0")
64
64
 
65
- result = Solve.it!(graph, [['A', '~> 1.0.0'], ['D', ">= 2.0.0"]])
66
-
65
+ result = Solve.it!(graph, [["A", "~> 1.0.0"], ["D", ">= 2.0.0"]])
67
66
 
68
67
  result.should eql("A" => "1.0.1",
69
68
  "B" => "2.1.0",
@@ -159,9 +158,9 @@ describe "Solutions", :gecode do
159
158
  graph.artifact("bottom", "1.0.0")
160
159
  graph.artifact("middle", "1.0.0").depends("top", "= 1.0.0").depends("middle")
161
160
 
162
- demands = [["bottom", "1.0.0"],["middle", "1.0.0"]]
161
+ demands = [["bottom", "1.0.0"], ["middle", "1.0.0"]]
163
162
 
164
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
163
+ expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
165
164
  error.should be_a(Solve::Errors::NoSolutionError)
166
165
  }
167
166
  end
@@ -206,7 +205,7 @@ describe "Solutions", :gecode do
206
205
  result.should eql({ "A" => "0.0.0",
207
206
  "B" => "0.0.0",
208
207
  "C" => "0.0.0",
209
- "D" => "0.0.0"})
208
+ "D" => "0.0.0" })
210
209
 
211
210
  end
212
211
 
@@ -246,7 +245,7 @@ describe "Solutions", :gecode do
246
245
  "get-the-old-one" => "1.0.0",
247
246
  "locked-mid-1" => "1.0.0",
248
247
  "locked-mid-2" => "2.0.0",
249
- "old-bottom" => "2.1.0"
248
+ "old-bottom" => "2.1.0",
250
249
  })
251
250
  end
252
251
 
@@ -266,7 +265,7 @@ describe "Solutions", :gecode do
266
265
  result.should eql([
267
266
  ["C", "1.0.0"],
268
267
  ["B", "1.0.0"],
269
- ["A", "1.0.0"]
268
+ ["A", "1.0.0"],
270
269
  ])
271
270
  end
272
271
  end
@@ -281,14 +280,14 @@ describe "Solutions", :gecode do
281
280
  graph.artifact("A", "1.0.0").depends("C", "= 1.0.0")
282
281
  graph.artifact("C", "1.0.0")
283
282
 
284
- demands = [["A"],["B"]]
283
+ demands = [["A"], ["B"]]
285
284
 
286
- result = Solve.it!(graph, demands, { :sorted => true } )
285
+ result = Solve.it!(graph, demands, { :sorted => true } )
287
286
 
288
287
  result.should eql([
289
288
  ["C", "1.0.0"],
290
289
  ["A", "1.0.0"],
291
- ["B", "1.0.0"]
290
+ ["B", "1.0.0"],
292
291
  ])
293
292
  end
294
293
  end
@@ -303,7 +302,7 @@ describe "Solutions", :gecode do
303
302
 
304
303
  demands = [["A"]]
305
304
 
306
- expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
305
+ expect { Solve.it!(graph, demands, { :sorted => true } ) }.to raise_error { |error|
307
306
  error.should be_a(Solve::Errors::UnsortableSolutionError)
308
307
  error.unsorted_solution.should eql({
309
308
  "A" => "1.0.0",
@@ -1,17 +1,16 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- require 'spork'
1
+ require "rubygems"
2
+ require "bundler"
3
+ require "spork"
4
4
 
5
5
  Spork.prefork do
6
- require 'rspec'
6
+ require "rspec"
7
7
 
8
- APP_ROOT = File.expand_path('../../', __FILE__)
8
+ APP_ROOT = File.expand_path("../../", __FILE__)
9
9
 
10
- Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each {|f| require f}
10
+ Dir[File.join(APP_ROOT, "spec/support/**/*.rb")].each { |f| require f }
11
11
 
12
12
  RSpec.configure do |config|
13
13
  config.mock_with :rspec
14
- config.treat_symbols_as_metadata_keys_with_true_values = true
15
14
  config.filter_run focus: true
16
15
  config.run_all_when_everything_filtered = true
17
16
 
@@ -21,5 +20,13 @@ Spork.prefork do
21
20
  end
22
21
 
23
22
  Spork.each_run do
24
- require 'solve'
23
+ require "solve"
24
+ end
25
+
26
+ # Useful for debugging the solver - simply add `ui: TestUI` to a resolver call
27
+ class TestUI
28
+ def self.say(message = "")
29
+ $stdout.print(message + "\n")
30
+ $stdout.flush
31
+ end
25
32
  end
@@ -1,12 +1,12 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Solve::Artifact do
4
4
  let(:graph) do
5
- package = double('package')
6
- package_version = double('package_version')
5
+ package = double("package")
6
+ package_version = double("package_version")
7
7
  package_version.stub(:dependencies).and_return([])
8
8
  package.stub(:add_version).and_return(package_version)
9
- double('graph', dep_graph: double('dep_graph', package: package))
9
+ double("graph", dep_graph: double("dep_graph", package: package))
10
10
  end
11
11
 
12
12
  let(:name) { "league" }
@@ -51,7 +51,7 @@ describe Solve::Artifact do
51
51
  [
52
52
  one,
53
53
  two,
54
- three
54
+ three,
55
55
  ].shuffle
56
56
  end
57
57
 
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Solve::Demand do
4
- let(:solver) { double('solver') }
4
+ let(:solver) { double("solver") }
5
5
  let(:name) { "league" }
6
6
 
7
7
  describe "#initialize" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Solve::Dependency do
4
4
  describe "#initialize" do
@@ -10,8 +10,8 @@ describe Solve::Dependency do
10
10
  end
11
11
  end
12
12
 
13
- let(:artifact) { double('artifact') }
14
- let(:name) { 'nginx' }
13
+ let(:artifact) { double("artifact") }
14
+ let(:name) { "nginx" }
15
15
  let(:constraint) { "~> 0.0.1" }
16
16
 
17
17
  subject { Solve::Dependency.new(artifact, name, constraint) }
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- require 'solve/gecode_solver'
3
+ require "solve/gecode_solver"
4
4
 
5
5
  describe Solve::GecodeSolver, :gecode do
6
6
 
@@ -59,7 +59,7 @@ describe Solve::GecodeSolver, :gecode do
59
59
  it "has a list of demands as model objects" do
60
60
  expected = [
61
61
  Solve::Demand.new(solver, "mysql"),
62
- Solve::Demand.new(solver, "nginx")
62
+ Solve::Demand.new(solver, "nginx"),
63
63
  ]
64
64
  solver.demands.should == expected
65
65
  end
@@ -79,7 +79,7 @@ describe Solve::GecodeSolver, :gecode do
79
79
  let(:demands) { [["A"], ["B"]] }
80
80
 
81
81
  it "gives the solution as a Hash" do
82
- solver.resolve.should == {"A"=>"1.0.0", "B"=>"1.0.0"}
82
+ solver.resolve.should == { "A" => "1.0.0", "B" => "1.0.0" }
83
83
  end
84
84
 
85
85
  it "gives the solution in sorted form" do
@@ -195,12 +195,11 @@ describe Solve::GecodeSolver, :gecode do
195
195
  json_string = serializer.serialize(problem)
196
196
  problem_data = JSON.parse(json_string)
197
197
  expected_demands = [
198
- {"name" => "mysql", "constraint" => ">= 0.0.0"},
199
- {"name" => "nginx", "constraint" => ">= 0.0.0"}
198
+ { "name" => "mysql", "constraint" => ">= 0.0.0" },
199
+ { "name" => "nginx", "constraint" => ">= 0.0.0" },
200
200
  ]
201
201
 
202
202
  problem_data["demands"].should =~ expected_demands
203
203
  end
204
204
  end
205
205
  end
206
-
@@ -72,12 +72,12 @@ describe Solve::Graph do
72
72
 
73
73
  describe "#versions" do
74
74
  before do
75
- subject.artifact('nginx', '1.0.0')
76
- subject.artifact('nginx', '2.0.0')
77
- subject.artifact('nginx', '3.0.0')
78
- subject.artifact('nginx', '4.0.0')
75
+ subject.artifact("nginx", "1.0.0")
76
+ subject.artifact("nginx", "2.0.0")
77
+ subject.artifact("nginx", "3.0.0")
78
+ subject.artifact("nginx", "4.0.0")
79
79
 
80
- subject.artifact('other', '1.0.0')
80
+ subject.artifact("other", "1.0.0")
81
81
  end
82
82
 
83
83
  it "returns all the artifacts matching the given name" do
@@ -98,8 +98,8 @@ describe Solve::Graph do
98
98
  describe "==" do
99
99
  def make_graph
100
100
  graph = Solve::Graph.new
101
- graph.artifact("A" ,"1.0.0").depends("B", "1.0.0")
102
- graph.artifact("A" ,"2.0.0").depends("C", "1.0.0")
101
+ graph.artifact("A" , "1.0.0").depends("B", "1.0.0")
102
+ graph.artifact("A" , "2.0.0").depends("C", "1.0.0")
103
103
  graph
104
104
  end
105
105
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Solve::RubySolver do
4
4
  describe "ClassMethods" do
@@ -38,7 +38,7 @@ describe Solve::RubySolver do
38
38
  it "has a list of demands as model objects" do
39
39
  expected = [
40
40
  Solve::Demand.new(solver, "mysql"),
41
- Solve::Demand.new(solver, "nginx")
41
+ Solve::Demand.new(solver, "nginx"),
42
42
  ]
43
43
  solver.demands.should == expected
44
44
  end
@@ -58,7 +58,7 @@ describe Solve::RubySolver do
58
58
  let(:demands) { [["A"], ["B"]] }
59
59
 
60
60
  it "gives the solution as a Hash" do
61
- solver.resolve.should == {"A"=>"1.0.0", "B"=>"1.0.0"}
61
+ solver.resolve.should == { "A" => "1.0.0", "B" => "1.0.0" }
62
62
  end
63
63
 
64
64
  it "gives the solution in sorted form" do
@@ -155,12 +155,11 @@ ERROR_MESSAGE
155
155
  json_string = serializer.serialize(problem)
156
156
  problem_data = JSON.parse(json_string)
157
157
  expected_demands = [
158
- {"name" => "mysql", "constraint" => ">= 0.0.0"},
159
- {"name" => "nginx", "constraint" => ">= 0.0.0"}
158
+ { "name" => "mysql", "constraint" => ">= 0.0.0" },
159
+ { "name" => "nginx", "constraint" => ">= 0.0.0" },
160
160
  ]
161
161
 
162
162
  problem_data["demands"].should =~ expected_demands
163
163
  end
164
164
  end
165
165
  end
166
-
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- require 'solve/ruby_solver'
1
+ require "spec_helper"
2
+ require "solve/ruby_solver"
3
3
 
4
4
  describe Solve::Solver::Serializer do
5
5
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Solve do
4
4
  describe "ClassMethods" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solve
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-01 00:00:00.000000000 Z
13
+ date: 2017-08-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: semverse
@@ -36,16 +36,16 @@ dependencies:
36
36
  name: molinillo
37
37
  requirement: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0.5'
41
+ version: '0.6'
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0.5'
48
+ version: '0.6'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: thor
51
51
  requirement: !ruby/object:Gem::Requirement