versionaire 5.0.0 → 5.1.0

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
  SHA256:
3
- metadata.gz: 02b1d7c076c95ea2d8b508afc74e25a9b5a4389094109578be0df8162939d959
4
- data.tar.gz: 7c9d736b55ce7b28a5598b4e4e8e155ea6656becc480a1e7c221ec24bbc79640
3
+ metadata.gz: 9fa6e823016230a46cf781e162c9223d7be3b20fafe1acab1dbca5c288b0d832
4
+ data.tar.gz: 63ddf1e3e48c053e1448b58323ed7ebb4d770d6a1e21263020da341345c0da4a
5
5
  SHA512:
6
- metadata.gz: 99071439cfbbb502971c0cc8f9e8c881f087783ba8d9ae9c87769c0c4114e906ba188c102c62911d928a513a03c14327ab631e2053890f2866dc551ded2cea8d
7
- data.tar.gz: 138f40ea59c5c126020b75b873806782550473c26ec1e59b97a85cefaa5a4717b70b715c72fb51557ed039ea530ee0f1759616ac902b946e08f6013fe3e736a2
6
+ metadata.gz: c3de2b8b340c64d43f628ccf7f9645237dbe6f9f12cc744eebda52ea7dbbc1edc1e385b9fc7073f56edf033ff104d001135d34d8b4b676bd8dfaad2f4bc4daa7
7
+ data.tar.gz: 10696b37a24d7949aa456dadb48964d4d6045fdf69b420426d32c19722f26af1a07d6fd001ea2d95b06ece185ed9d9820919b59d0346aa609d15607a1009b2bc
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -26,6 +26,7 @@ Provides immutable, thread-safe, semantic versioning.
26
26
  - [Function (Casting)](#function-casting)
27
27
  - [Implicit](#implicit)
28
28
  - [Explicit](#explicit)
29
+ - [Comparisons](#comparisons)
29
30
  - [Math](#math)
30
31
  - [Addition](#addition)
31
32
  - [Subtraction](#subtraction)
@@ -147,6 +148,22 @@ Explicit conversion to a `String`, `Array`, or `Hash` is supported:
147
148
  version.to_a # [0, 0, 0]
148
149
  version.to_h # {major: 0, minor: 0, maintenance: 0}
149
150
 
151
+ ### Comparisons
152
+
153
+ All versions are comparable which means any of the operators from the `Comparable` module will work.
154
+ Example:
155
+
156
+ v1 = Versionaire::Version "1.0.0"
157
+ v2 = Versionaire::Version "2.0.0"
158
+
159
+ v1 < v2 # true
160
+ v1 <= v2 # true
161
+ v1 == v2 # false (see Equality section above for details)
162
+ v1 > v2 # false
163
+ v1 >= v2 # false
164
+ v1.between? v1, v2 # true
165
+ v1.clamp v1, v2 # v1 (added in Ruby 2.4.0)
166
+
150
167
  ### Math
151
168
 
152
169
  Versions can be added and subtracted from each other.
@@ -3,7 +3,7 @@
3
3
  # The gem namespace.
4
4
  module Versionaire
5
5
  # Conversion function (strict) for casting an object into a version.
6
- # rubocop:disable Naming/MethodName
6
+ # :reek:TooManyStatements
7
7
  def Version object
8
8
  converter = Converter.new object
9
9
 
@@ -15,7 +15,6 @@ module Versionaire
15
15
  else converter.from_object
16
16
  end
17
17
  end
18
- # rubocop:enable Naming/MethodName
19
18
 
20
19
  module_function :Version
21
20
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Versionaire
4
4
  module Errors
5
- # The base error class for all gem-related errors.
5
+ # The base error class for all gem related errors.
6
6
  class Base < StandardError
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Versionaire
4
4
  module Errors
5
- # Thrown when attempting to convert (cast) a primitive to a version.
5
+ # Thrown when attempting to convert (cast) an invalid primitive to a version.
6
6
  class Conversion < Base
7
7
  end
8
8
  end
@@ -12,7 +12,7 @@ module Versionaire
12
12
  end
13
13
 
14
14
  def self.version
15
- "5.0.0"
15
+ "5.1.0"
16
16
  end
17
17
 
18
18
  def self.version_label
@@ -39,13 +39,16 @@ module Versionaire
39
39
  end
40
40
 
41
41
  def + other
42
- self.class.new self.class.arguments(*reduce(other, :+))
42
+ klass = self.class
43
+ klass.new klass.arguments(*reduce(other, :+))
43
44
  end
44
45
 
45
46
  def - other
46
- self.class.new self.class.arguments(*reduce(other, :-))
47
+ klass = self.class
48
+ klass.new klass.arguments(*reduce(other, :-))
47
49
  end
48
50
 
51
+ # :reek:FeatureEnvy
49
52
  def == other
50
53
  other.is_a?(Version) && to_s == other.to_s
51
54
  end
@@ -59,12 +62,8 @@ module Versionaire
59
62
  [major, minor, maintenance, self.class].hash
60
63
  end
61
64
 
62
- def label
63
- "v#{self}"
64
- end
65
-
66
65
  def to_s
67
- "#{major}#{self.class.delimiter}#{minor}#{self.class.delimiter}#{maintenance}"
66
+ [major, minor, maintenance].join self.class.delimiter
68
67
  end
69
68
  alias to_str to_s
70
69
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionaire
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -29,7 +29,7 @@ cert_chain:
29
29
  4Zrsxi713z6sndd9JBAm4G7mJiV93MsuCM5N4ZDY7XaxIhvctNSNhX/Yn8LLdtGI
30
30
  b4jw5t40FKyNUvLPPXYAvQALBtk=
31
31
  -----END CERTIFICATE-----
32
- date: 2018-03-19 00:00:00.000000000 Z
32
+ date: 2018-03-22 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: awesome_print
@@ -87,20 +87,6 @@ dependencies:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.0'
90
- - !ruby/object:Gem::Dependency
91
- name: gemsmith
92
- requirement: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '11.1'
97
- type: :development
98
- prerelease: false
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '11.1'
104
90
  - !ruby/object:Gem::Dependency
105
91
  name: git-cop
106
92
  requirement: !ruby/object:Gem::Requirement
@@ -219,14 +205,14 @@ dependencies:
219
205
  requirements:
220
206
  - - "~>"
221
207
  - !ruby/object:Gem::Version
222
- version: '0.53'
208
+ version: '0.54'
223
209
  type: :development
224
210
  prerelease: false
225
211
  version_requirements: !ruby/object:Gem::Requirement
226
212
  requirements:
227
213
  - - "~>"
228
214
  - !ruby/object:Gem::Version
229
- version: '0.53'
215
+ version: '0.54'
230
216
  - !ruby/object:Gem::Dependency
231
217
  name: wirb
232
218
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file