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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2c8bf1750e6652a793210aa4fd698f949c5fef1
4
- data.tar.gz: 25cc4de765ed2cb8b48fa069db70c2edbccd4c1b
3
+ metadata.gz: 0e6a58fa44e65b31c0702901da1b090dca04b59a
4
+ data.tar.gz: 12508f512d12eabaaf12f2d672267256d02da0fa
5
5
  SHA512:
6
- metadata.gz: d3a7ed9ea96b5299f016b02c7d70531df7880bae9fcf9b3ae50fa19ee301c600a556a9c22a5602e35f452ea6ba2f06261b59e0071432b4e7ee8e90156ef9d0f9
7
- data.tar.gz: ac60d6f13a033e406cc2943fb5683fdb487196dea3398035b4f65ac67e7971e9a937c66461f81064d894d3dd57569106f8a19f3b6b866e2ec01acfa7cfce264b
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>)
@@ -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/gem_version'
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, options[:ui]).resolve(options)
32
+ Solver.new(graph, demands).resolve(options)
35
33
  end
36
34
  end
37
35
  end
@@ -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
- # @param [#say] ui
26
- def initialize(graph, demands, ui = nil)
27
- @ds_graph = DepSelector::DependencyGraph.new
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 = 1_000
40
+ @timeout_ms = self.class.timeout
31
41
  end
32
42
 
33
43
  # The problem demands given as Demand model objects
@@ -0,0 +1,3 @@
1
+ module Solve
2
+ VERSION = "1.2.0"
3
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/solve/gem_version', __FILE__)
2
+ require File.expand_path('../lib/solve/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.authors = ["Jamie Winsor", "Andrew Garson", "Thibaud Guillaume-Gentil"]
@@ -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.1.0
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-14 00:00:00.000000000 Z
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
@@ -1,3 +0,0 @@
1
- module Solve
2
- VERSION = "1.1.0"
3
- end