solve 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rbenv-version CHANGED
@@ -1 +1,2 @@
1
- 1.9.3-p194
1
+ 1.9.3-p327
2
+
data/lib/solve.rb CHANGED
@@ -21,12 +21,12 @@ module Solve
21
21
  #
22
22
  # @param [Solve::Graph] graph
23
23
  # @param [Array<Solve::Demand>, Array<String, String>] demands
24
- # @param [#say, nil] ui
24
+ # @param [#say, nil] ui (nil)
25
25
  #
26
26
  # @raise [NoSolutionError]
27
27
  #
28
28
  # @return [Hash]
29
- def it!(graph, demands, ui=nil)
29
+ def it!(graph, demands, ui = nil)
30
30
  Solver.new(graph, demands, ui).resolve
31
31
  end
32
32
  end
@@ -119,8 +119,12 @@ module Solve
119
119
  attr_reader :pre_release
120
120
  attr_reader :build
121
121
 
122
- # @param [#to_s] constraint
123
- def initialize(constraint = ">= 0.0.0")
122
+ # @param [#to_s] constraint (">= 0.0.0")
123
+ def initialize(constraint = nil)
124
+ if constraint.nil? || constraint.empty?
125
+ constraint = ">= 0.0.0"
126
+ end
127
+
124
128
  @operator, ver_str = self.class.split(constraint)
125
129
  if @operator.nil? || ver_str.nil?
126
130
  raise Errors::InvalidConstraintFormat.new(constraint)
@@ -1,3 +1,3 @@
1
1
  module Solve
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/solve/version.rb CHANGED
@@ -12,12 +12,12 @@ module Solve
12
12
  case version_string.to_s
13
13
  when /^(\d+)\.(\d+)\.(\d+)(-([0-9a-z\-\.]+))?(\+([0-9a-z\-\.]+))?$/i
14
14
  [ $1.to_i, $2.to_i, $3.to_i, $5, $7 ]
15
- when /^(\d+)\.(\d+)\.(\d+)$/
15
+ when /^(\d+)\.(\d+)\.(\d+)?$/
16
16
  [ $1.to_i, $2.to_i, $3.to_i ]
17
- when /^(\d+)\.(\d+)$/
18
- [ $1.to_i, $2.to_i, nil ]
17
+ when /^(\d+)\.(\d+)?$/
18
+ [ $1.to_i, $2.to_i, 0 ]
19
19
  when /^(\d+)$/
20
- [ $1.to_i, nil, nil ]
20
+ [ $1.to_i, 0, 0 ]
21
21
  else
22
22
  raise Errors::InvalidVersionFormat.new(version_string)
23
23
  end
@@ -33,6 +33,14 @@ describe Solve::Constraint do
33
33
  result.version.to_s.should eql("0.0.0")
34
34
  end
35
35
 
36
+ it "sets a default of '>= 0.0.0' if given a nil value" do
37
+ subject.new(nil).to_s.should eql(">= 0.0.0")
38
+ end
39
+
40
+ it "sets a default of '>= 0.0.0' if given a blank string" do
41
+ subject.new('').to_s.should eql(">= 0.0.0")
42
+ end
43
+
36
44
  context "given a string that does not match the Constraint REGEXP" do
37
45
  it "raises an InvalidConstraintFormat error" do
38
46
  lambda {
@@ -246,8 +246,12 @@ describe Solve::Version do
246
246
  subject.split("1.2").should have(3).items
247
247
  end
248
248
 
249
- it "returns nil as the third element" do
250
- subject.split("1.2")[2].should be_nil
249
+ it "returns 0 as the third element" do
250
+ subject.split("1.2")[2].should eql(0)
251
+ end
252
+
253
+ it "converts the third element to 0 if it's nil or blank" do
254
+ subject.split("1.2.")[2].should eql(0)
251
255
  end
252
256
  end
253
257
 
@@ -256,12 +260,16 @@ describe Solve::Version do
256
260
  subject.split("1").should have(3).items
257
261
  end
258
262
 
259
- it "returns nil as the second element" do
260
- subject.split("1")[2].should be_nil
263
+ it "returns 0 as the second element" do
264
+ subject.split("1")[2].should eql(0)
265
+ end
266
+
267
+ it "returns 0 as the third element" do
268
+ subject.split("1")[2].should eql(0)
261
269
  end
262
270
 
263
- it "returns nil as the third element" do
264
- subject.split("1")[2].should be_nil
271
+ it "converts the second element to 0 if it's nil or blank" do
272
+ subject.split("1.")[1].should eql(0)
265
273
  end
266
274
  end
267
275
 
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: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-12-24 00:00:00.000000000 Z
14
+ date: 2013-02-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json
@@ -94,10 +94,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: 3991493875393418852
97
+ hash: 3780464592715279943
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 1.8.23
100
+ rubygems_version: 1.8.24
101
101
  signing_key:
102
102
  specification_version: 3
103
103
  summary: A Ruby version constraint solver implementing Semantic Versioning 2.0.0-rc.1