versionaire 9.1.0 → 9.2.2
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/README.adoc +45 -3
- data/lib/versionaire/cast.rb +1 -3
- data/lib/versionaire/errors/invalid_number.rb +1 -3
- data/lib/versionaire/extensions/option_parser.rb +10 -0
- data/lib/versionaire/function.rb +2 -6
- data/lib/versionaire/identity.rb +2 -2
- data/lib/versionaire/version.rb +4 -12
- data.tar.gz.sig +0 -0
- metadata +14 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fc322d69d30450c7c68857bfe9976a59af4489a5651ddb30972ed4918a6b369
|
4
|
+
data.tar.gz: d222908d2a74363b6fbd4d5aac6202b6c51553eff1a175f08d66b03821b44c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5492ddd489f1f689fec8f6a263e99c28a22b4c824f604735e58910f15ffab439f49b09cb5a47d534ce3d141d14f50b95d196d0c3656633f1b76989a22221c607
|
7
|
+
data.tar.gz: ae282cecbd1dc785aa0b6be8f1e8b3807a2dedfbc13d4bca10fea484c9ce3a4cbea3dc97fcc6b6b6c8daa5a5c58938226dc593adf7a341baae59f2697902d803
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.adoc
CHANGED
@@ -11,8 +11,10 @@ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchem
|
|
11
11
|
[link=https://circleci.com/gh/bkuhlmann/versionaire]
|
12
12
|
image::https://circleci.com/gh/bkuhlmann/versionaire.svg?style=svg[Circle CI Status]
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
Ruby doesn't provide a primitive version type by default. Versionaire fills this gap by providing an
|
15
|
+
immutable, thread-safe, and link:https://semver.org[Semantic Version] in order to use versions
|
16
|
+
within your applications. This new version type behaves and feels a lot like other primitives (i.e.
|
17
|
+
`String`, `Array`, `Hash`, etc) and can even be cast/converted from other primitives.
|
16
18
|
|
17
19
|
toc::[]
|
18
20
|
|
@@ -150,7 +152,7 @@ Version version
|
|
150
152
|
By adding `using Versionaire::Cast` to your implementation, this allows Versionaire to refine
|
151
153
|
`Kernel` so you have a top-level `Version` conversion function much like Kernel's native support for
|
152
154
|
`Integer`, `String`, `Array`, `Hash`, etc. The benefit to this approach is it reduces the amount of
|
153
|
-
typing, doesn't
|
155
|
+
typing, doesn't pollute your entire object space like a monkey patch would, and provides a idiomatic
|
154
156
|
approach to casting like any other primitive.
|
155
157
|
|
156
158
|
==== Implicit
|
@@ -257,6 +259,46 @@ version.down :patch, 3 # => "5.5.2"
|
|
257
259
|
version.down :major, 6 # => Versionaire::Errors::NegativeNumber
|
258
260
|
----
|
259
261
|
|
262
|
+
=== Extensions
|
263
|
+
|
264
|
+
This project supports libraries which might desire native `Version` types. Each extension _must be
|
265
|
+
explicitly required_ in order to be used since they are _optional_ by default. See below for
|
266
|
+
details.
|
267
|
+
|
268
|
+
==== OptionParser
|
269
|
+
|
270
|
+
link:https://github.com/ruby/optparse[OptionParser] is one of Ruby's
|
271
|
+
link:https://stdgems.org[default gems] which can accept additional types not native to Ruby by
|
272
|
+
default. To extend `OptionParser` with the `Version` type, all you need to do is add these two lines
|
273
|
+
to your implementation:
|
274
|
+
|
275
|
+
. `require "versionaire/extensions/option_parser"` - This will load dependencies and register the
|
276
|
+
`Version` type with `OptionParser`.
|
277
|
+
. `instance.on "--tag VERSION", Versionaire::Version` - Specifying `Versionaire::Version` as the
|
278
|
+
second argument will ensure `OptionParser` properly casts command line input as a `Version` type.
|
279
|
+
|
280
|
+
Here's an example implementation that demonstrates full usage:
|
281
|
+
|
282
|
+
[source,ruby]
|
283
|
+
----
|
284
|
+
require "versionaire/extensions/option_parser"
|
285
|
+
|
286
|
+
options = {}
|
287
|
+
|
288
|
+
parser = OptionParser.new do |instance|
|
289
|
+
instance.on "--tag VERSION", Versionaire::Version, "Casts to version." do |value|
|
290
|
+
options[:version] = value
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
parser.parse! %w[--tag 1.2.3]
|
295
|
+
puts options
|
296
|
+
----
|
297
|
+
|
298
|
+
The above will ensure `--tag 1.2.3` is parsed as `{:version=>#<struct Versionaire::Version major=1,
|
299
|
+
minor=2, patch=3>}` within your `options` variable. Should `OptionParser` parse an invalid version,
|
300
|
+
you'll get a `OptionParser::InvalidArgument` instead.
|
301
|
+
|
260
302
|
== Development
|
261
303
|
|
262
304
|
To contribute, run:
|
data/lib/versionaire/cast.rb
CHANGED
@@ -4,9 +4,7 @@ module Versionaire
|
|
4
4
|
module Errors
|
5
5
|
# Thrown when not using numbers.
|
6
6
|
class InvalidNumber < Base
|
7
|
-
def initialize
|
8
|
-
super message
|
9
|
-
end
|
7
|
+
def initialize(message = "Major, minor, and patch must be a number.") = super(message)
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
data/lib/versionaire/function.rb
CHANGED
@@ -67,13 +67,9 @@ module Versionaire
|
|
67
67
|
.then { |arguments| Version.with_positions(*arguments) }
|
68
68
|
end
|
69
69
|
|
70
|
-
def required_keys?
|
71
|
-
object.keys.all? { |key| Version.members.include? key }
|
72
|
-
end
|
70
|
+
def required_keys? = object.keys.all? { |key| Version.members.include? key }
|
73
71
|
|
74
|
-
def error_message
|
75
|
-
"Invalid version conversion: #{object}. #{body}"
|
76
|
-
end
|
72
|
+
def error_message(object, body) = "Invalid version conversion: #{object}. #{body}"
|
77
73
|
end
|
78
74
|
|
79
75
|
private_constant :Converter
|
data/lib/versionaire/identity.rb
CHANGED
data/lib/versionaire/version.rb
CHANGED
@@ -9,9 +9,7 @@ module Versionaire
|
|
9
9
|
|
10
10
|
using Refinements::Structs
|
11
11
|
|
12
|
-
def self.delimiter
|
13
|
-
"."
|
14
|
-
end
|
12
|
+
def self.delimiter = "."
|
15
13
|
|
16
14
|
def self.pattern
|
17
15
|
/
|
@@ -54,17 +52,11 @@ module Versionaire
|
|
54
52
|
to_s <=> other.to_s
|
55
53
|
end
|
56
54
|
|
57
|
-
def down
|
58
|
-
revalue(key => value) { |previous, current| previous - current }
|
59
|
-
end
|
55
|
+
def down(key, value = 1) = revalue(key => value) { |previous, current| previous - current }
|
60
56
|
|
61
|
-
def up
|
62
|
-
revalue(key => value) { |previous, current| previous + current }
|
63
|
-
end
|
57
|
+
def up(key, value = 1) = revalue(key => value) { |previous, current| previous + current }
|
64
58
|
|
65
|
-
def to_s
|
66
|
-
to_a.join self.class.delimiter
|
67
|
-
end
|
59
|
+
def to_s = to_a.join(self.class.delimiter)
|
68
60
|
|
69
61
|
alias_method :to_str, :to_s
|
70
62
|
alias_method :values, :to_a
|
data.tar.gz.sig
CHANGED
Binary file
|
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: 9.
|
4
|
+
version: 9.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIC/
|
14
|
-
|
15
|
-
|
13
|
+
MIIC/jCCAeagAwIBAgIBBDANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMTAzMTkxMjQ4MDZaFw0yMjAzMTkx
|
15
|
+
MjQ4MDZaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
@@ -20,15 +20,15 @@ cert_chain:
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
23
|
-
2CdikiiE3fJhP/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAEjpaOXHHp8s/7GL2qCb
|
24
|
+
YAs7urOLv9VHSPfQWAwaTMVnSsIf3Sw4xzISOP/mmfEPBPXtz61K5esrE/uTFtgb
|
25
|
+
FyjxQk2H0sEWgrRXGGNHBWQRhhEs7LP/TByoC15A0br++xLxRz4r7HBLGAWQQDpg
|
26
|
+
66BJ2TBVjxS6K64tKbq7+ACyrOZGgTfNHACh4M076y0x0oRf/rwBrU39/KRfuhbb
|
27
|
+
cm+nNCEtO35gTmZ2bVDHLGvWazi3gJt6+huQjfXTCUUG2YYBxwhu+GPdAGQPxpf9
|
28
|
+
lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
|
29
|
+
W2A=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2021-
|
31
|
+
date: 2021-09-06 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: refinements
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/versionaire/errors/cast.rb
|
62
62
|
- lib/versionaire/errors/invalid_number.rb
|
63
63
|
- lib/versionaire/errors/negative_number.rb
|
64
|
+
- lib/versionaire/extensions/option_parser.rb
|
64
65
|
- lib/versionaire/function.rb
|
65
66
|
- lib/versionaire/identity.rb
|
66
67
|
- lib/versionaire/version.rb
|
@@ -87,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
89
90
|
requirements: []
|
90
|
-
rubygems_version: 3.2.
|
91
|
+
rubygems_version: 3.2.27
|
91
92
|
signing_key:
|
92
93
|
specification_version: 4
|
93
94
|
summary: Provides an immutable, thread-safe, and semantic version type.
|
metadata.gz.sig
CHANGED
Binary file
|