versionaire 7.1.0 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee0ca3727b5bf31067191d7aa4be767dee8d3b7e6c2703d211aa6cc9927c4021
4
- data.tar.gz: ea9ce213190cfe550585441125de1bbb4f327fa99263b06bc20ab7736fe4fc66
3
+ metadata.gz: f5ad83ad73daa56d1e2e0b0d7048cb79e8ef234af33bb71fb09d9d6b50000d66
4
+ data.tar.gz: 64bef36a76f1590a9209356973150d288ced2811cf1e8a60ded4fd376c92782f
5
5
  SHA512:
6
- metadata.gz: 4d151a766961b4a96d136ebaf66f6ca8b44dbaf50d5037f7d648f380d217e8bb8cf5d9c72def4fa6d234465aec5eb592ca3193b0d08ab9f7645daac4301c8662
7
- data.tar.gz: 9a949b67e45eb87e856f2f256e63dfdb0ff274cd8696ea353d5b6f99f90b350c34e74407656764065533a493417b2303acb0300a762da51a209c8298cd06d064
6
+ metadata.gz: 1a6e8122fc30d451751d5f705ea2155a0476b5fa258b22a1620df9bf3fd80833dc298b515dbb4a0595eb8c15c611f69b7cedf411b8c8c4b0a8817c055c829cff
7
+ data.tar.gz: ed363f7d8b928fefdbd0127dd8397a4560b746f7404c92406fc6f906c5b8898575114fd4efa44c7ecd1c099ea1209b67d256bdc8e7f88ca832e98d23f1ea7857
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -153,16 +153,16 @@ Explicit conversion to a `String`, `Array`, or `Hash` is supported:
153
153
  All versions are comparable which means any of the operators from the `Comparable` module will work.
154
154
  Example:
155
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)
156
+ version_1 = Versionaire::Version "1.0.0"
157
+ version_2 = Versionaire::Version "2.0.0"
158
+
159
+ version_1 < version_2 # true
160
+ version_1 <= version_2 # true
161
+ version_1 == version_2 # false (see Equality section above for details)
162
+ version_1 > version_2 # false
163
+ version_1 >= version_2 # false
164
+ version_1.between? version_1, version_2 # true
165
+ version_1.clamp version_1, version_2 # version_1 (added in Ruby 2.4.0)
166
166
 
167
167
  ### Math
168
168
 
@@ -20,20 +20,20 @@ module Versionaire
20
20
 
21
21
  # Aids with converting objects into valid versions.
22
22
  class Converter
23
- def initialize value
24
- @value = value
23
+ def initialize object
24
+ @object = object
25
25
  end
26
26
 
27
27
  def from_string
28
28
  body = %(Use: "<major>.<minor>.<maintenance>" or "v<major>.<minor>.<maintenance>".)
29
- fail(Errors::Conversion, error_message(value, body)) unless Version.regex.match? value
29
+ fail(Errors::Conversion, error_message(object, body)) unless Version.regex.match? object
30
30
 
31
31
  Version.new string_to_arguments
32
32
  end
33
33
 
34
34
  def from_array
35
35
  body = "Use: [], [<major>], [<major>, <minor>], or [<major>, <minor>, <maintenance>]."
36
- fail(Errors::Conversion, error_message(value, body)) unless (0..3).cover?(value.size)
36
+ fail(Errors::Conversion, error_message(object, body)) unless (0..3).cover?(object.size)
37
37
 
38
38
  Version.new array_to_arguments
39
39
  end
@@ -42,29 +42,29 @@ module Versionaire
42
42
  body = "Use: {major: <major>}, " \
43
43
  "{major: <major>, minor: <minor>}, or " \
44
44
  "{major: <major>, minor: <minor>, maintenance: <maintenance>}."
45
- fail(Errors::Conversion, error_message(value, body)) unless required_keys?
45
+ fail(Errors::Conversion, error_message(object, body)) unless required_keys?
46
46
 
47
- Version.new value
47
+ Version.new object
48
48
  end
49
49
 
50
50
  def from_object
51
- fail Errors::Conversion, error_message(value, "Use: String, Array, Hash, or Version.")
51
+ fail Errors::Conversion, error_message(object, "Use: String, Array, Hash, or Version.")
52
52
  end
53
53
 
54
54
  private
55
55
 
56
- attr_reader :value
56
+ attr_reader :object
57
57
 
58
58
  def string_to_arguments
59
- Version.arguments(*value.tr("v", "").split(".").map(&:to_i))
59
+ Version.arguments(*object.tr("v", "").split(".").map(&:to_i))
60
60
  end
61
61
 
62
62
  def array_to_arguments
63
- Version.arguments(*value.dup.fill(0, value.size..2))
63
+ Version.arguments(*object.dup.fill(0, object.size..2))
64
64
  end
65
65
 
66
66
  def required_keys?
67
- value.keys.all? { |key| VERSION_ATTRIBUTES.include? key }
67
+ object.keys.all? { |key| VERSION_ATTRIBUTES.include? key }
68
68
  end
69
69
 
70
70
  def error_message object, body
@@ -12,7 +12,7 @@ module Versionaire
12
12
  end
13
13
 
14
14
  def self.version
15
- "7.1.0"
15
+ "7.2.0"
16
16
  end
17
17
 
18
18
  def self.version_label
@@ -7,6 +7,8 @@ module Versionaire
7
7
  # An immutable, semantic version value object.
8
8
  # rubocop:disable Metrics/BlockLength
9
9
  Version = Struct.new :major, :minor, :maintenance, keyword_init: true do
10
+ include Comparable
11
+
10
12
  def self.regex
11
13
  /
12
14
  \A # Start of string.
@@ -39,12 +41,18 @@ module Versionaire
39
41
  klass.new klass.arguments(*reduce(other, :-))
40
42
  end
41
43
 
44
+ def == other
45
+ hash == other.hash
46
+ end
47
+
48
+ alias_method :eql?, :==
49
+
42
50
  def <=> other
43
51
  to_s <=> other.to_s
44
52
  end
45
53
 
46
54
  def to_s
47
- [major, minor, maintenance].join VERSION_DELIMITER
55
+ to_a.join VERSION_DELIMITER
48
56
  end
49
57
 
50
58
  alias_method :to_str, :to_s
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: 7.1.0
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -10,26 +10,25 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDQDCCAiigAwIBAgIBATANBgkqhkiG9w0BAQsFADAlMSMwIQY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+Y1OTWw/xhk3HE2AH0GDGC9xbM75qrg3/+a4D81pM94B6zuBdA
27
- 7hxUy4kByawrii833IidV0zkI4lCombTNicc8JWXXSlL2G/sWPLndNvn5rzoyyRT
28
- pPOLYGdB4hqUam3hBgLOsYIOVp+yXMvj0gvk/Djq8IR2P1RS4NZU7HHD485xkBfL
29
- 4Zrsxi713z6sndd9JBAm4G7mJiV93MsuCM5N4ZDY7XaxIhvctNSNhX/Yn8LLdtGI
30
- b4jw5t40FKyNUvLPPXYAvQALBtk=
22
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
23
+ 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBANgfX7kPZkJvsbdWMvbe
24
+ DUUYxRTqTUzCDpLd2p3sQvgLMKjTNSKt6CFq/kh+98b6RCgO6DqiVfxvOEq02dvf
25
+ ebMN/ylQqan2FgiAs1rpP0/D4C0MlBjoDktsT+2IyLol1KmkDB20ExJ4Sf1GRNdA
26
+ hpWOtcgqHtmrc7xzgB6BuyoYufrKKUlCO3ewTM4C375D2qO7hIdKuMOO3CdPMtSk
27
+ OrWpbzCL+nbbXqeoqiHgZaUvcyyQrGj5sQRxMTzuMXzzQxtHnuTuKrcz16HMTX/O
28
+ dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
29
+ y84=
31
30
  -----END CERTIFICATE-----
32
- date: 2019-02-02 00:00:00.000000000 Z
31
+ date: 2019-02-17 00:00:00.000000000 Z
33
32
  dependencies:
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: awesome_print
metadata.gz.sig CHANGED
Binary file