liferaft 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e855e2a34754fbe9ff001abf1acd49a035bbd38e
4
- data.tar.gz: 9f4f6477edd83b553046279313ed365275133dd2
3
+ metadata.gz: 4274fe00e060a7eb7285f2929c7a469056f6a7f8
4
+ data.tar.gz: 92c92bd0c3b8d04369bd470d65084818e7cc9180
5
5
  SHA512:
6
- metadata.gz: 529a56052774df97faf327ae1c637f6cd58dd9001c4a650c4c38445015eba49716e8156f5300716ed12ce06ec8f10622916825aecc4d7612f39eb48fd6afc8cc
7
- data.tar.gz: 84c1ab2c187108565a5411dd0a4559c789de0e411652c132e7919b6ec5616e2fff3591d2a4dcd97e21ad9116c1c3f92fad59288a53c311b6d47fa04e8ca1b910
6
+ metadata.gz: 891caaf7896809d7ac4472b6a68da63fd51a375953970a287add8ef24aebb7aee75b74f639e45e1c16e10c54a0d98ac9b2908f40c9c89caaad0652fa9d081a6c
7
+ data.tar.gz: d3f1ad75f35b5aa96e704184ece768e6777fd08f87819a01f2347300d4b8e09205fc8a686401c3cd1009efc40af58f7d6c8df6dbb34c0f7ffc8a5d31e181121d
data/README.md CHANGED
@@ -12,7 +12,7 @@ Liferaft parses Apple build numbers, like `6D1002`.
12
12
  ```ruby
13
13
  v = Version.new('6D1002')
14
14
 
15
- puts '#{v.major}.#{v.minor}.#{v.patch} Build #{v.build}'
15
+ puts "#{v.major}.#{v.minor}.#{v.patch} Build #{v.build}"
16
16
  ## => '6.3.1 Build 2'
17
17
  ```
18
18
 
@@ -1,3 +1,3 @@
1
1
  module Liferaft
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -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 != 1
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
 
@@ -20,7 +20,7 @@ module Liferaft
20
20
  it 'implements greater-than-or-equals operator' do
21
21
  v1 = Version.new('6D570')
22
22
  v2 = Version.new('6D570')
23
- v3 = Version.new('6D1002')
23
+ v3 = Version.new('6D002')
24
24
 
25
25
  v2.should >= v1
26
26
  v2.should >= v3
@@ -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('6EE14')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liferaft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Bügling