liferaft 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/liferaft/gem_version.rb +1 -1
- data/lib/liferaft/version.rb +9 -2
- data/spec/comparison_spec.rb +1 -1
- data/spec/version_spec.rb +34 -1
- 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: 4274fe00e060a7eb7285f2929c7a469056f6a7f8
|
4
|
+
data.tar.gz: 92c92bd0c3b8d04369bd470d65084818e7cc9180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 891caaf7896809d7ac4472b6a68da63fd51a375953970a287add8ef24aebb7aee75b74f639e45e1c16e10c54a0d98ac9b2908f40c9c89caaad0652fa9d081a6c
|
7
|
+
data.tar.gz: d3f1ad75f35b5aa96e704184ece768e6777fd08f87819a01f2347300d4b8e09205fc8a686401c3cd1009efc40af58f7d6c8df6dbb34c0f7ffc8a5d31e181121d
|
data/README.md
CHANGED
data/lib/liferaft/gem_version.rb
CHANGED
data/lib/liferaft/version.rb
CHANGED
@@ -10,7 +10,7 @@ module Liferaft
|
|
10
10
|
components = version_string.downcase.split(/[a-z]/)
|
11
11
|
character = version_string.downcase.gsub(/[^a-z]/, '')
|
12
12
|
|
13
|
-
if character.length
|
13
|
+
if character.length > 2 || character.length == 0
|
14
14
|
@major = @minor = @patch = @build = 0
|
15
15
|
return
|
16
16
|
end
|
@@ -18,7 +18,11 @@ module Liferaft
|
|
18
18
|
@major = components[0].to_i
|
19
19
|
@minor = character.ord - 'a'.ord
|
20
20
|
@patch = components[1].to_i / 1000
|
21
|
-
@build = components[1].to_i % 1000
|
21
|
+
@build = (character.length == 2 ? character[-1].ord : 0) + components[1].to_i % 1000
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
return "#{@major}.#{@minor}.#{@patch} Build #{@build}"
|
22
26
|
end
|
23
27
|
|
24
28
|
def >(other)
|
@@ -31,8 +35,11 @@ module Liferaft
|
|
31
35
|
|
32
36
|
def <(other)
|
33
37
|
return true if major < other.major
|
38
|
+
return false if major != other.major
|
34
39
|
return true if minor < other.minor
|
40
|
+
return false if minor != other.minor
|
35
41
|
return true if patch < other.patch
|
42
|
+
return false if patch != other.patch
|
36
43
|
build < other.build
|
37
44
|
end
|
38
45
|
|
data/spec/comparison_spec.rb
CHANGED
data/spec/version_spec.rb
CHANGED
@@ -16,6 +16,24 @@ module Liferaft
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe Version do
|
19
|
+
it 'parses 6E7 correctly' do
|
20
|
+
version = Version.new('6E7')
|
21
|
+
|
22
|
+
version.major.should == 6
|
23
|
+
version.minor.should == 4
|
24
|
+
version.patch.should == 0
|
25
|
+
version.build.should == 7
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'parses 6C131e correctly' do
|
29
|
+
version = Version.new('6C131e')
|
30
|
+
|
31
|
+
version.major.should == 6
|
32
|
+
version.minor.should == 2
|
33
|
+
version.patch.should == 0
|
34
|
+
version.build.should == 232
|
35
|
+
end
|
36
|
+
|
19
37
|
it 'parses 6D570 correctly' do
|
20
38
|
version = Version.new('6D570')
|
21
39
|
|
@@ -70,6 +88,15 @@ module Liferaft
|
|
70
88
|
version.build.should == 14
|
71
89
|
end
|
72
90
|
|
91
|
+
it 'parses 7A121l correctly' do
|
92
|
+
version = Version.new('7A121l')
|
93
|
+
|
94
|
+
version.major.should == 7
|
95
|
+
version.minor.should == 0
|
96
|
+
version.patch.should == 0
|
97
|
+
version.build.should == 229
|
98
|
+
end
|
99
|
+
|
73
100
|
it 'is resilient against empty minor versions' do
|
74
101
|
version = Version.new('614')
|
75
102
|
|
@@ -80,7 +107,7 @@ module Liferaft
|
|
80
107
|
end
|
81
108
|
|
82
109
|
it 'is resilient against multi-character minor versions' do
|
83
|
-
version = Version.new('
|
110
|
+
version = Version.new('6EEE14')
|
84
111
|
|
85
112
|
version.major.should == 0
|
86
113
|
version.minor.should == 0
|
@@ -96,5 +123,11 @@ module Liferaft
|
|
96
123
|
version.patch.should == 0
|
97
124
|
version.build.should == 0
|
98
125
|
end
|
126
|
+
|
127
|
+
it 'can convert a Version object to string' do
|
128
|
+
version = Version.new('6E14')
|
129
|
+
|
130
|
+
version.to_s.should == '6.4.0 Build 14'
|
131
|
+
end
|
99
132
|
end
|
100
133
|
end
|