semverse 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/semverse/constraint.rb +4 -0
- data/lib/semverse/gem_version.rb +1 -1
- data/spec/unit/semverse/constraint_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd2cf18c6c57fd6cafb42a24eb98f8b7bf10ba31
|
4
|
+
data.tar.gz: c9222204986cb821a09e73ce889369b054a66b5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 614d1b76c8616308176bf894ccdc14223b085ddad832b81fcdb082cae91b04f4ba7b6dda0d3654cace0ebf6f0aeb25fed9c2e1b144ef6c165d992d3ec5746610
|
7
|
+
data.tar.gz: 9dcb6b53997d79124c6aca69dafb60f590657d1d985ffada15e62d64ea5bfe8a95199182f7b5fb409c6b8b12d072c39e4a67de8d14331bf7140a349448816cb8
|
data/lib/semverse/constraint.rb
CHANGED
@@ -166,6 +166,10 @@ module Semverse
|
|
166
166
|
|
167
167
|
# @param [#to_s] constraint
|
168
168
|
def initialize(constraint = '>= 0.0.0')
|
169
|
+
constraint = constraint.to_s
|
170
|
+
if constraint.nil? || constraint.empty?
|
171
|
+
constraint = ">= 0.0.0"
|
172
|
+
end
|
169
173
|
@operator, @major, @minor, @patch, @pre_release, @build = self.class.split(constraint)
|
170
174
|
|
171
175
|
unless ['~>', '~'].include?(@operator)
|
data/lib/semverse/gem_version.rb
CHANGED
@@ -33,6 +33,20 @@ describe Semverse::Constraint do
|
|
33
33
|
expect(result.version.to_s).to eq("0.0.0")
|
34
34
|
end
|
35
35
|
|
36
|
+
it "falls back to a default constraint if nil is provided" do
|
37
|
+
result = subject.new(nil)
|
38
|
+
|
39
|
+
expect(result.version.to_s).to eq("0.0.0")
|
40
|
+
expect(result.operator).to eq(">=")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "fall sback to a default constraint if a blank string is provided" do
|
44
|
+
result = subject.new("")
|
45
|
+
|
46
|
+
expect(result.version.to_s).to eq("0.0.0")
|
47
|
+
expect(result.operator).to eq(">=")
|
48
|
+
end
|
49
|
+
|
36
50
|
context "given a string that does not match the Constraint REGEXP" do
|
37
51
|
it "raises an InvalidConstraintFormat error" do
|
38
52
|
expect {
|