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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.adoc +1 -1
- data/lib/versionaire.rb +3 -4
- data/lib/versionaire/errors/cast.rb +9 -0
- data/lib/versionaire/{conversion.rb → function.rb} +5 -5
- data/lib/versionaire/identity.rb +1 -1
- data/lib/versionaire/version.rb +8 -10
- metadata +8 -9
- metadata.gz.sig +0 -0
- data/lib/versionaire/errors/conversion.rb +0 -9
- data/lib/versionaire/filler.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5bf3f6ca78ae9c031159e94ca9c756fa50b13cdec20d434695ae8a26126d7b0
|
4
|
+
data.tar.gz: b6d5c1ca4d9528e70885e9e5842d3bf32a884d3c18934c7e9d3300023fc7f583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c1334716bba3802c6adb35c8be2f0066f6020314f92736d6fa935600aadf19d47c7313d6087e3bc6d7171e0dfab3472c4509fba6ff24684a4b731140ff60569
|
7
|
+
data.tar.gz: 65ae92c897c984976c44c2efa6e101af3d7fda55e6ecc3ee7990b56f1d7d6d3f324ed667dde497b3715b9f0fa6764bfb74268b1d98d6d4d887b1330478196ef6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -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::
|
131
|
+
to convert an unsupported type, a `+Versionaire::Errors::Cast+` exception will be thrown.
|
132
132
|
|
133
133
|
==== Refinement
|
134
134
|
|
data/lib/versionaire.rb
CHANGED
@@ -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/
|
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"
|
@@ -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::
|
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::
|
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::
|
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::
|
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(
|
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) }
|
data/lib/versionaire/identity.rb
CHANGED
data/lib/versionaire/version.rb
CHANGED
@@ -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.
|
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
|
-
#{
|
22
|
+
#{delimiter}? # Delimiter.
|
21
23
|
\d* # Minor.
|
22
|
-
(?:#{
|
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
|
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:
|
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-
|
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: '
|
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: '
|
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/
|
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/
|
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: '
|
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.
|
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
|
data/lib/versionaire/filler.rb
DELETED
@@ -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
|