versionaire 8.7.0 → 9.0.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: b41a84e38c6e7d73b9ecc460bb8bbecc5d763aa11a05cac1021d16d8b3e17235
4
- data.tar.gz: 10e14aeb64f4ca5c92eb559a594627bef37d03abb05d1029d417ce32c7b71ea0
3
+ metadata.gz: b5bf3f6ca78ae9c031159e94ca9c756fa50b13cdec20d434695ae8a26126d7b0
4
+ data.tar.gz: b6d5c1ca4d9528e70885e9e5842d3bf32a884d3c18934c7e9d3300023fc7f583
5
5
  SHA512:
6
- metadata.gz: 5673376e2e87acee93d11e1ef4283d18bd89fea650c9fd77018263ad3a7a1e9f9041139f38d69c881540a4810eb0035dd307c5343a2dfc114d564d47c7825af1
7
- data.tar.gz: 88cc980f9c39af47d3443d3348894e8189487c378a402c537e6565d53cb1f18f753892fcec26c7f41274d6bc1a4ea2b1d902708e12c6b68eed029b8f0c6caa96
6
+ metadata.gz: 8c1334716bba3802c6adb35c8be2f0066f6020314f92736d6fa935600aadf19d47c7313d6087e3bc6d7171e0dfab3472c4509fba6ff24684a4b731140ff60569
7
+ data.tar.gz: 65ae92c897c984976c44c2efa6e101af3d7fda55e6ecc3ee7990b56f1d7d6d3f324ed667dde497b3715b9f0fa6764bfb74268b1d98d6d4d887b1330478196ef6
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -128,7 +128,7 @@ Versionaire::Version version
128
128
  ----
129
129
 
130
130
  Each of these conversions will result in a version object that represents "`1.0.0`". When attempting
131
- to convert an unsupported type, a `+Versionaire::Errors::Conversion+` exception will be thrown.
131
+ to convert an unsupported type, a `+Versionaire::Errors::Cast+` exception will be thrown.
132
132
 
133
133
  ==== Refinement
134
134
 
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "versionaire/identity"
3
4
  require "versionaire/errors/base"
4
- require "versionaire/errors/conversion"
5
+ require "versionaire/errors/cast"
5
6
  require "versionaire/errors/invalid_number"
6
7
  require "versionaire/errors/negative_number"
7
- require "versionaire/filler"
8
- require "versionaire/conversion"
9
- require "versionaire/identity"
10
8
  require "versionaire/version"
9
+ require "versionaire/function"
11
10
  require "versionaire/cast"
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Versionaire
4
+ module Errors
5
+ # Thrown when attempting to cast an invalid primitive to a version.
6
+ class Cast < Base
7
+ end
8
+ end
9
+ end
@@ -32,14 +32,14 @@ module Versionaire
32
32
 
33
33
  def from_string
34
34
  body = "Use: <major>.<minor>.<patch>, <major>.<minor>, <major>, or empty string."
35
- fail Errors::Conversion, error_message(object, body) unless Version.regex.match? object
35
+ fail Errors::Cast, error_message(object, body) unless Version.pattern.match? object
36
36
 
37
37
  string_to_version
38
38
  end
39
39
 
40
40
  def from_array
41
41
  body = "Use: [<major>, <minor>, <patch>], [<major>, <minor>], [<major>], or []."
42
- fail Errors::Conversion, error_message(object, body) unless (0..3).cover? object.size
42
+ fail Errors::Cast, error_message(object, body) unless (0..3).cover? object.size
43
43
 
44
44
  Version.with_positions(*object.pad(0, max: 3))
45
45
  end
@@ -47,13 +47,13 @@ module Versionaire
47
47
  def from_hash
48
48
  body = "Use: {major: <major>, minor: <minor>, patch: <patch>}, " \
49
49
  "{major: <major>, minor: <minor>}, {major: <major>}, or {}."
50
- fail Errors::Conversion, error_message(object, body) unless required_keys?
50
+ fail Errors::Cast, error_message(object, body) unless required_keys?
51
51
 
52
52
  Version[**object]
53
53
  end
54
54
 
55
55
  def from_object
56
- fail Errors::Conversion, error_message(object, "Use: String, Array, Hash, or Version.")
56
+ fail Errors::Cast, error_message(object, "Use: String, Array, Hash, or Version.")
57
57
  end
58
58
 
59
59
  private
@@ -61,7 +61,7 @@ module Versionaire
61
61
  attr_reader :object, :filler
62
62
 
63
63
  def string_to_version
64
- object.split(DELIMITER)
64
+ object.split(Version.delimiter)
65
65
  .map(&:to_i)
66
66
  .then { |numbers| numbers.pad 0, max: 3 }
67
67
  .then { |arguments| Version.with_positions(*arguments) }
@@ -5,7 +5,7 @@ module Versionaire
5
5
  module Identity
6
6
  NAME = "versionaire"
7
7
  LABEL = "Versionaire"
8
- VERSION = "8.7.0"
8
+ VERSION = "9.0.0"
9
9
  VERSION_LABEL = "#{LABEL} #{VERSION}"
10
10
  end
11
11
  end
@@ -3,31 +3,29 @@
3
3
  require "refinements/structs"
4
4
 
5
5
  module Versionaire
6
- DELIMITER = "."
7
-
8
6
  # An immutable, semantic version value object.
9
7
  Version = Struct.new :major, :minor, :patch, keyword_init: true do
10
8
  include Comparable
11
9
 
12
10
  using Refinements::Structs
13
11
 
14
- def self.regex
12
+ def self.delimiter
13
+ "."
14
+ end
15
+
16
+ def self.pattern
15
17
  /
16
18
  \A( # Start of string and OR.
17
19
  \d* # Major only.
18
20
  | # OR pipe.
19
21
  \d+ # Major.
20
- #{DELIMITER}? # Delimiter.
22
+ #{delimiter}? # Delimiter.
21
23
  \d* # Minor.
22
- (?:#{DELIMITER}\d+) # Passive delimiter and patch.
24
+ (?:#{delimiter}\d+) # Passive delimiter and patch.
23
25
  )\z # End of OR and string.
24
26
  /x
25
27
  end
26
28
 
27
- def self.arguments major, minor, patch
28
- Hash[members.zip [major, minor, patch]]
29
- end
30
-
31
29
  def initialize major: 0, minor: 0, patch: 0
32
30
  super
33
31
  validate
@@ -65,7 +63,7 @@ module Versionaire
65
63
  end
66
64
 
67
65
  def to_s
68
- to_a.join DELIMITER
66
+ to_a.join self.class.delimiter
69
67
  end
70
68
 
71
69
  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: 8.7.0
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
29
  QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-12-21 00:00:00.000000000 Z
31
+ date: 2020-12-29 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: refinements
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '7.18'
39
+ version: '8.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '7.18'
46
+ version: '8.0'
47
47
  description:
48
48
  email:
49
49
  - brooke@alchemists.io
@@ -57,12 +57,11 @@ files:
57
57
  - README.adoc
58
58
  - lib/versionaire.rb
59
59
  - lib/versionaire/cast.rb
60
- - lib/versionaire/conversion.rb
61
60
  - lib/versionaire/errors/base.rb
62
- - lib/versionaire/errors/conversion.rb
61
+ - lib/versionaire/errors/cast.rb
63
62
  - lib/versionaire/errors/invalid_number.rb
64
63
  - lib/versionaire/errors/negative_number.rb
65
- - lib/versionaire/filler.rb
64
+ - lib/versionaire/function.rb
66
65
  - lib/versionaire/identity.rb
67
66
  - lib/versionaire/version.rb
68
67
  homepage: https://www.alchemists.io/projects/versionaire
@@ -81,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
80
  requirements:
82
81
  - - "~>"
83
82
  - !ruby/object:Gem::Version
84
- version: '2.7'
83
+ version: '3.0'
85
84
  required_rubygems_version: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - ">="
88
87
  - !ruby/object:Gem::Version
89
88
  version: '0'
90
89
  requirements: []
91
- rubygems_version: 3.2.2
90
+ rubygems_version: 3.2.3
92
91
  signing_key:
93
92
  specification_version: 4
94
93
  summary: Provides an immutable, thread-safe, and semantic version type.
metadata.gz.sig CHANGED
Binary file
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Versionaire
4
- module Errors
5
- # Thrown when attempting to convert (cast) an invalid primitive to a version.
6
- class Conversion < Base
7
- end
8
- end
9
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Versionaire
4
- # Ensures an array can be filled to a certain size with default elements.
5
- class Filler
6
- def initialize pad = 0, max: 2
7
- @pad = pad
8
- @max = max
9
- end
10
-
11
- def call array
12
- array.dup.fill pad, array.size..max
13
- end
14
-
15
- private
16
-
17
- attr_reader :pad, :max
18
- end
19
- end