solve 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/solve.rb +2 -4
- data/lib/solve/solver.rb +15 -5
- data/lib/solve/version.rb +3 -0
- data/solve.gemspec +1 -1
- data/spec/unit/solve/solver_spec.rb +18 -0
- metadata +3 -3
- data/lib/solve/gem_version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e6a58fa44e65b31c0702901da1b090dca04b59a
|
4
|
+
data.tar.gz: 12508f512d12eabaaf12f2d672267256d02da0fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4758cf9a12c21aab78f46cfdf6f5e3fadedca7a4317036fea6243b192a51c28b85369d89b0d3f0358535eb5dc2cbb9345f28682137ab80353486f0f445c2348a
|
7
|
+
data.tar.gz: 49cf75e3e9f95b168bdc7911229567543093b3efff4c7030ce43f5dab0af2882c4f5a43802de46f7e3adbfa133042a4003e5ee531741a194fdd6e1962053e2b6
|
data/README.md
CHANGED
@@ -38,6 +38,14 @@ NOTE: This will raise Solve::Errors::UnsortableSolutionError if the solution con
|
|
38
38
|
|
39
39
|
Solve.it!(graph, ['nginx', '>= 0.100.0'], sorted: true)
|
40
40
|
|
41
|
+
### Increasing the solver's timeout
|
42
|
+
|
43
|
+
By default the solver will wait 10 seconds before giving up on finding a solution. Under certain conditions a graph may be too complicated to solve within the alotted time. To increase the timeout you can set the "SOLVE_TIMEOUT" environment variable to the amount of seconds desired.
|
44
|
+
|
45
|
+
$ export SOLVE_TIMEOUT=30
|
46
|
+
|
47
|
+
This will set the timeout to 30 seconds instead of 10 seconds.
|
48
|
+
|
41
49
|
## Authors
|
42
50
|
|
43
51
|
* [Jamie Winsor](https://github.com/reset) (<jamie@vialstudios.com>)
|
data/lib/solve.rb
CHANGED
@@ -4,7 +4,7 @@ module Solve
|
|
4
4
|
require_relative 'solve/artifact'
|
5
5
|
require_relative 'solve/demand'
|
6
6
|
require_relative 'solve/dependency'
|
7
|
-
require_relative 'solve/
|
7
|
+
require_relative 'solve/version'
|
8
8
|
require_relative 'solve/errors'
|
9
9
|
require_relative 'solve/graph'
|
10
10
|
require_relative 'solve/solver'
|
@@ -22,8 +22,6 @@ module Solve
|
|
22
22
|
# @param [Solve::Graph] graph
|
23
23
|
# @param [Array<Solve::Demand>, Array<String, String>] demands
|
24
24
|
#
|
25
|
-
# @option options [#say] :ui (nil)
|
26
|
-
# a ui object for output
|
27
25
|
# @option options [Boolean] :sorted (false)
|
28
26
|
# should the output be a sorted list rather than a Hash
|
29
27
|
#
|
@@ -31,7 +29,7 @@ module Solve
|
|
31
29
|
#
|
32
30
|
# @return [Hash]
|
33
31
|
def it!(graph, demands, options = {})
|
34
|
-
Solver.new(graph, demands
|
32
|
+
Solver.new(graph, demands).resolve(options)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
data/lib/solve/solver.rb
CHANGED
@@ -4,6 +4,17 @@ require_relative 'solver/serializer'
|
|
4
4
|
|
5
5
|
module Solve
|
6
6
|
class Solver
|
7
|
+
class << self
|
8
|
+
# The timeout (in seconds) to use when resolving graphs. Default is 10. This can be
|
9
|
+
# configured by setting the SOLVE_TIMEOUT environment variable.
|
10
|
+
#
|
11
|
+
# @return [Integer]
|
12
|
+
def timeout
|
13
|
+
seconds = 10 unless seconds = ENV["SOLVE_TIMEOUT"]
|
14
|
+
seconds.to_i * 1_000
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
7
18
|
# Graph object with references to all known artifacts and dependency
|
8
19
|
# constraints.
|
9
20
|
#
|
@@ -22,12 +33,11 @@ module Solve
|
|
22
33
|
# Solver.new(graph, demands)
|
23
34
|
# @param [Solve::Graph] graph
|
24
35
|
# @param [Array<String>, Array<Array<String, String>>] demands
|
25
|
-
|
26
|
-
|
27
|
-
@
|
28
|
-
@graph = graph
|
36
|
+
def initialize(graph, demands)
|
37
|
+
@ds_graph = DepSelector::DependencyGraph.new
|
38
|
+
@graph = graph
|
29
39
|
@demands_array = demands
|
30
|
-
@timeout_ms
|
40
|
+
@timeout_ms = self.class.timeout
|
31
41
|
end
|
32
42
|
|
33
43
|
# The problem demands given as Demand model objects
|
data/solve.gemspec
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Solve::Solver do
|
4
|
+
describe "ClassMethods" do
|
5
|
+
describe "::timeout" do
|
6
|
+
subject { described_class.timeout }
|
7
|
+
|
8
|
+
it "returns 10,000 by default" do
|
9
|
+
expect(subject).to eql(10_000)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when the SOLVE_TIMEOUT env variable is set" do
|
13
|
+
before { ENV.stub(:[]).with("SOLVE_TIMEOUT") { "30" } }
|
14
|
+
|
15
|
+
it "returns the value multiplied by a thousand" do
|
16
|
+
expect(subject).to eql(30_000)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
4
22
|
let(:graph) { double(Solve::Graph) }
|
5
23
|
let(:demands) { [["mysql"], ["nginx"]] }
|
6
24
|
subject(:solver) { described_class.new(graph, demands) }
|
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: 1.
|
4
|
+
version: 1.2.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: 2014-04-
|
13
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: semverse
|
@@ -62,10 +62,10 @@ files:
|
|
62
62
|
- lib/solve/demand.rb
|
63
63
|
- lib/solve/dependency.rb
|
64
64
|
- lib/solve/errors.rb
|
65
|
-
- lib/solve/gem_version.rb
|
66
65
|
- lib/solve/graph.rb
|
67
66
|
- lib/solve/solver.rb
|
68
67
|
- lib/solve/solver/serializer.rb
|
68
|
+
- lib/solve/version.rb
|
69
69
|
- solve.gemspec
|
70
70
|
- spec/acceptance/benchmark.rb
|
71
71
|
- spec/acceptance/large_graph_no_solution.rb
|
data/lib/solve/gem_version.rb
DELETED