versionaire 7.3.4 → 8.3.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{LICENSE.md → LICENSE.adoc} +29 -30
- data/README.adoc +252 -0
- data/lib/versionaire.rb +1 -0
- data/lib/versionaire/conversion.rb +24 -21
- data/lib/versionaire/errors/invalid_number.rb +2 -2
- data/lib/versionaire/errors/negative_number.rb +2 -2
- data/lib/versionaire/filler.rb +18 -0
- data/lib/versionaire/identity.rb +4 -15
- data/lib/versionaire/version.rb +17 -21
- metadata +49 -103
- metadata.gz.sig +0 -0
- data/README.md +0 -227
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb162bc916245b6782d3451663d6ae53e09eb736a6423334b87a9f6b18f4fe47
|
|
4
|
+
data.tar.gz: b57712183b4dec5ba02234b370f6e0daf69536f087bb3470956e67a5aae571ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21c38cc0d147bc20e6d0e891d9855bc9d55f4b96f5ec540d726f6ce12ac136c057fc4fc28cfd5bca4594b248aae76862159c07544230aee82d63d3b382776a04
|
|
7
|
+
data.tar.gz: 78bc75b55d216cdbf34dff6b73f435b0a7685a699db719d6f8287cf32c36e25668fb216b43e40e2a8b803b53ffde6dd7bf75be177fed4dd61738da0ccf4d2566
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/{LICENSE.md → LICENSE.adoc}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
= Apache License
|
|
2
2
|
|
|
3
3
|
Version 2.0, January 2004
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ http://www.apache.org/licenses
|
|
|
6
6
|
|
|
7
7
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
== 1. Definitions
|
|
10
10
|
|
|
11
11
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
|
|
12
12
|
Sections 1 through 9 of this document.
|
|
@@ -54,14 +54,14 @@ Contribution."
|
|
|
54
54
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
|
|
55
55
|
Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
== 2. Grant of Copyright License
|
|
58
58
|
|
|
59
59
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
|
60
60
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
61
61
|
reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
|
|
62
62
|
distribute the Work and such Derivative Works in Source or Object form.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
== 3. Grant of Patent License
|
|
65
65
|
|
|
66
66
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
|
67
67
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
|
@@ -74,39 +74,38 @@ a Contribution incorporated within the Work constitutes direct or contributory p
|
|
|
74
74
|
then any patent licenses granted to You under this License for that Work shall terminate as of the
|
|
75
75
|
date such litigation is filed.
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
== 4. Redistribution
|
|
78
78
|
|
|
79
79
|
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
|
|
80
80
|
or without modifications, and in Source or Object form, provided that You meet the following
|
|
81
81
|
conditions:
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
. You must cause any modified files to carry prominent notices stating that You changed the files;
|
|
86
|
+
and
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
|
|
89
|
+
patent, trademark, and attribution notices from the Source form of the Work, excluding those
|
|
90
|
+
notices that do not pertain to any part of the Derivative Works; and
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
construed as modifying the License.
|
|
92
|
+
. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
|
|
93
|
+
that You distribute must include a readable copy of the attribution notices contained within such
|
|
94
|
+
NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
|
|
95
|
+
at least one of the following places: within a NOTICE text file distributed as part of the
|
|
96
|
+
Derivative Works; within the Source form or documentation, if provided along with the Derivative
|
|
97
|
+
Works; or, within a display generated by the Derivative Works, if and wherever such third-party
|
|
98
|
+
notices normally appear. The contents of the NOTICE file are for informational purposes only and
|
|
99
|
+
do not modify the License. You may add Your own attribution notices within Derivative Works that
|
|
100
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
|
|
101
|
+
additional attribution notices cannot be construed as modifying the License.
|
|
103
102
|
|
|
104
103
|
You may add Your own copyright statement to Your modifications and may provide additional or
|
|
105
104
|
different license terms and conditions for use, reproduction, or distribution of Your modifications,
|
|
106
105
|
or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
|
|
107
106
|
the Work otherwise complies with the conditions stated in this License.
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
== 5. Submission of Contributions
|
|
110
109
|
|
|
111
110
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
|
|
112
111
|
Work by You to the Licensor shall be under the terms and conditions of this License, without any
|
|
@@ -114,13 +113,13 @@ additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
|
114
113
|
the terms of any separate license agreement you may have executed with Licensor regarding such
|
|
115
114
|
Contributions.
|
|
116
115
|
|
|
117
|
-
|
|
116
|
+
== 6. Trademarks
|
|
118
117
|
|
|
119
118
|
This License does not grant permission to use the trade names, trademarks, service marks, or product
|
|
120
119
|
names of the Licensor, except as required for reasonable and customary use in describing the origin
|
|
121
120
|
of the Work and reproducing the content of the NOTICE file.
|
|
122
121
|
|
|
123
|
-
|
|
122
|
+
== 7. Disclaimer of Warranty
|
|
124
123
|
|
|
125
124
|
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
|
|
126
125
|
Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
@@ -129,7 +128,7 @@ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Y
|
|
|
129
128
|
responsible for determining the appropriateness of using or redistributing the Work and assume any
|
|
130
129
|
risks associated with Your exercise of permissions under this License.
|
|
131
130
|
|
|
132
|
-
|
|
131
|
+
== 8. Limitation of Liability
|
|
133
132
|
|
|
134
133
|
In no event and under no legal theory, whether in tort (including negligence), contract, or
|
|
135
134
|
otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
|
|
@@ -139,7 +138,7 @@ License or out of the use or inability to use the Work (including but not limite
|
|
|
139
138
|
loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
|
|
140
139
|
damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
141
140
|
|
|
142
|
-
|
|
141
|
+
== 9. Accepting Warranty or Additional Liability
|
|
143
142
|
|
|
144
143
|
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
|
|
145
144
|
for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
|
|
@@ -151,11 +150,11 @@ additional liability.
|
|
|
151
150
|
|
|
152
151
|
END OF TERMS AND CONDITIONS
|
|
153
152
|
|
|
154
|
-
Copyright 2016
|
|
153
|
+
Copyright 2016 link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
|
155
154
|
|
|
156
155
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
|
157
|
-
compliance with the License. You may obtain a
|
|
158
|
-
the License.
|
|
156
|
+
compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
|
|
157
|
+
of the License.
|
|
159
158
|
|
|
160
159
|
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
161
160
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
data/README.adoc
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
:toc: macro
|
|
2
|
+
:toclevels: 5
|
|
3
|
+
:figure-caption!:
|
|
4
|
+
|
|
5
|
+
= Versionaire
|
|
6
|
+
|
|
7
|
+
[link=http://badge.fury.io/rb/versionaire]
|
|
8
|
+
image::https://badge.fury.io/rb/versionaire.svg[Gem Version]
|
|
9
|
+
[link=https://circleci.com/gh/bkuhlmann/versionaire]
|
|
10
|
+
image::https://circleci.com/gh/bkuhlmann/versionaire.svg?style=svg[Circle CI Status]
|
|
11
|
+
|
|
12
|
+
Provides an immutable, thread-safe, and semantic version type when managing versions within your
|
|
13
|
+
applications.
|
|
14
|
+
|
|
15
|
+
toc::[]
|
|
16
|
+
|
|
17
|
+
== Features
|
|
18
|
+
|
|
19
|
+
* Provides https://semver.org[Semantic Versioning].
|
|
20
|
+
* Provides immutable, thread-safe version instances.
|
|
21
|
+
* Converts (casts) from a `String`, `Array`, `Hash`, or `Version` to a `Version`.
|
|
22
|
+
|
|
23
|
+
== Screencasts
|
|
24
|
+
|
|
25
|
+
[link=https://www.alchemists.io/screencasts/versionaire]
|
|
26
|
+
image::https://www.alchemists.io/images/screencasts/versionaire/cover.svg[Screencast,600,240,role=focal_point]
|
|
27
|
+
|
|
28
|
+
== Requirements
|
|
29
|
+
|
|
30
|
+
. https://www.ruby-lang.org[Ruby].
|
|
31
|
+
|
|
32
|
+
== Setup
|
|
33
|
+
|
|
34
|
+
To install, run:
|
|
35
|
+
|
|
36
|
+
[source,bash]
|
|
37
|
+
----
|
|
38
|
+
gem install versionaire
|
|
39
|
+
----
|
|
40
|
+
|
|
41
|
+
Add the following to your Gemfile:
|
|
42
|
+
|
|
43
|
+
[source,ruby]
|
|
44
|
+
----
|
|
45
|
+
gem "versionaire"
|
|
46
|
+
----
|
|
47
|
+
|
|
48
|
+
== Usage
|
|
49
|
+
|
|
50
|
+
=== Initialization
|
|
51
|
+
|
|
52
|
+
A new version can be initialized in a variety of ways:
|
|
53
|
+
|
|
54
|
+
[source,ruby]
|
|
55
|
+
----
|
|
56
|
+
Versionaire::Version.new # "0.0.0"
|
|
57
|
+
Versionaire::Version[major: 1] # "1.0.0"
|
|
58
|
+
Versionaire::Version[major: 1, minor: 2] # "1.2.0"
|
|
59
|
+
Versionaire::Version[major: 1, minor: 2, patch: 3] # "1.2.3"
|
|
60
|
+
----
|
|
61
|
+
|
|
62
|
+
=== Equality
|
|
63
|
+
|
|
64
|
+
==== Value (`+#==+`)
|
|
65
|
+
|
|
66
|
+
Equality is deterimined by the state of the object. This means that a version is equal to another
|
|
67
|
+
version as long as all of the values (i.e. state) are equal to each other. Example:
|
|
68
|
+
|
|
69
|
+
[source,ruby]
|
|
70
|
+
----
|
|
71
|
+
version_a = Versionaire::Version[major: 1]
|
|
72
|
+
version_b = Versionaire::Version[major: 2]
|
|
73
|
+
version_c = Versionaire::Version[major: 1]
|
|
74
|
+
|
|
75
|
+
version_a == version_a # true
|
|
76
|
+
version_a == version_b # false
|
|
77
|
+
version_a == version_c # true
|
|
78
|
+
----
|
|
79
|
+
|
|
80
|
+
Knowning this, versions can be compared against one another too:
|
|
81
|
+
|
|
82
|
+
[source,ruby]
|
|
83
|
+
----
|
|
84
|
+
version_a > version_b # false
|
|
85
|
+
version_a < version_b # true
|
|
86
|
+
version_a.between? version_c, version_b # true
|
|
87
|
+
----
|
|
88
|
+
|
|
89
|
+
==== Hash (`#eql?`)
|
|
90
|
+
|
|
91
|
+
Behaves exactly as `#==`.
|
|
92
|
+
|
|
93
|
+
==== Case (`#===`)
|
|
94
|
+
|
|
95
|
+
Behaves exactly as `#==`.
|
|
96
|
+
|
|
97
|
+
==== Identity (`#equal?`)
|
|
98
|
+
|
|
99
|
+
Works like any other standard Ruby object where an object is equal only to itself.
|
|
100
|
+
|
|
101
|
+
[source,ruby]
|
|
102
|
+
----
|
|
103
|
+
version_a = Versionaire::Version[major: 1]
|
|
104
|
+
version_b = Versionaire::Version[major: 2]
|
|
105
|
+
version_c = Versionaire::Version[major: 1]
|
|
106
|
+
|
|
107
|
+
version_a.equal? version_a # true
|
|
108
|
+
version_a.equal? version_b # false
|
|
109
|
+
version_a.equal? version_c # false
|
|
110
|
+
----
|
|
111
|
+
|
|
112
|
+
=== Conversions
|
|
113
|
+
|
|
114
|
+
==== Function (Casting)
|
|
115
|
+
|
|
116
|
+
The `Versionaire::Version` function is provided for explicit casting to a version:
|
|
117
|
+
|
|
118
|
+
[source,ruby]
|
|
119
|
+
----
|
|
120
|
+
version = Versionaire::Version[major: 1]
|
|
121
|
+
|
|
122
|
+
Versionaire::Version "1.0.0"
|
|
123
|
+
Versionaire::Version [1, 0, 0]
|
|
124
|
+
Versionaire::Version major: 1, minor: 0, patch: 0
|
|
125
|
+
Versionaire::Version version
|
|
126
|
+
----
|
|
127
|
+
|
|
128
|
+
Each of these conversions will result in a version object that represents "`1.0.0`". When attempting
|
|
129
|
+
to convert an unsupported type, a `+Versionaire::Errors::Conversion+` exception will be thrown.
|
|
130
|
+
|
|
131
|
+
==== Implicit
|
|
132
|
+
|
|
133
|
+
Implicit conversion to a `+String+` is supported:
|
|
134
|
+
|
|
135
|
+
[source,ruby]
|
|
136
|
+
----
|
|
137
|
+
"1.0.0".match Versionaire::Version[major: 1] # <MatchData "1.0.0">
|
|
138
|
+
----
|
|
139
|
+
|
|
140
|
+
==== Explicit
|
|
141
|
+
|
|
142
|
+
Explicit conversion to a `String`, `Array`, or `Hash` is supported:
|
|
143
|
+
|
|
144
|
+
[source,ruby]
|
|
145
|
+
----
|
|
146
|
+
version = Versionaire::Version.new
|
|
147
|
+
|
|
148
|
+
version.to_s # "0.0.0"
|
|
149
|
+
version.to_a # [0, 0, 0]
|
|
150
|
+
version.to_h # {major: 0, minor: 0, patch: 0}
|
|
151
|
+
----
|
|
152
|
+
|
|
153
|
+
=== Comparisons
|
|
154
|
+
|
|
155
|
+
All versions are comparable which means any of the operators from the `+Comparable+` module will
|
|
156
|
+
work. Example:
|
|
157
|
+
|
|
158
|
+
[source,ruby]
|
|
159
|
+
----
|
|
160
|
+
version_1 = Versionaire::Version "1.0.0"
|
|
161
|
+
version_2 = Versionaire::Version "2.0.0"
|
|
162
|
+
|
|
163
|
+
version_1 < version_2 # true
|
|
164
|
+
version_1 <= version_2 # true
|
|
165
|
+
version_1 == version_2 # false (see Equality section above for details)
|
|
166
|
+
version_1 > version_2 # false
|
|
167
|
+
version_1 >= version_2 # false
|
|
168
|
+
version_1.between? version_1, version_2 # true
|
|
169
|
+
version_1.clamp version_1, version_2 # version_1 (added in Ruby 2.4.0)
|
|
170
|
+
----
|
|
171
|
+
|
|
172
|
+
=== Math
|
|
173
|
+
|
|
174
|
+
Versions can be added and subtracted from each other.
|
|
175
|
+
|
|
176
|
+
==== Addition
|
|
177
|
+
|
|
178
|
+
[source,ruby]
|
|
179
|
+
----
|
|
180
|
+
version_1 = Versionaire::Version[major: 1, minor: 2, patch: 3]
|
|
181
|
+
version_2 = Versionaire::Version[major: 2, minor: 5, patch: 7]
|
|
182
|
+
version_1 + version_2 # "3.7.10"
|
|
183
|
+
----
|
|
184
|
+
|
|
185
|
+
==== Subtraction
|
|
186
|
+
|
|
187
|
+
[source,ruby]
|
|
188
|
+
----
|
|
189
|
+
version_1 = Versionaire::Version[major: 1, minor: 2, patch: 3]
|
|
190
|
+
version_2 = Versionaire::Version[major: 1, minor: 1, patch: 1]
|
|
191
|
+
version_1 - version_2 # "0.1.2"
|
|
192
|
+
|
|
193
|
+
version_1 = Versionaire::Version[major: 1]
|
|
194
|
+
version_2 = Versionaire::Version[major: 5]
|
|
195
|
+
version_1 - version_2 # Fails with a Versionaire::Errors::NegativeNumber
|
|
196
|
+
----
|
|
197
|
+
|
|
198
|
+
== Development
|
|
199
|
+
|
|
200
|
+
To contribute, run:
|
|
201
|
+
|
|
202
|
+
[source,bash]
|
|
203
|
+
----
|
|
204
|
+
git clone https://github.com/bkuhlmann/versionaire.git
|
|
205
|
+
cd versionaire
|
|
206
|
+
bin/setup
|
|
207
|
+
----
|
|
208
|
+
|
|
209
|
+
You can also use the IRB console for direct access to all objects:
|
|
210
|
+
|
|
211
|
+
[source,bash]
|
|
212
|
+
----
|
|
213
|
+
bin/console
|
|
214
|
+
----
|
|
215
|
+
|
|
216
|
+
== Tests
|
|
217
|
+
|
|
218
|
+
To test, run:
|
|
219
|
+
|
|
220
|
+
[source,bash]
|
|
221
|
+
----
|
|
222
|
+
bundle exec rake
|
|
223
|
+
----
|
|
224
|
+
|
|
225
|
+
== Versioning
|
|
226
|
+
|
|
227
|
+
Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
|
|
228
|
+
|
|
229
|
+
* Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
|
230
|
+
* Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
|
231
|
+
* Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
|
232
|
+
|
|
233
|
+
== Code of Conduct
|
|
234
|
+
|
|
235
|
+
Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
|
|
236
|
+
participating in this project you agree to abide by its terms.
|
|
237
|
+
|
|
238
|
+
== Contributions
|
|
239
|
+
|
|
240
|
+
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
|
241
|
+
|
|
242
|
+
== License
|
|
243
|
+
|
|
244
|
+
Read link:LICENSE.adoc[LICENSE] for details.
|
|
245
|
+
|
|
246
|
+
== History
|
|
247
|
+
|
|
248
|
+
Read link:CHANGES.adoc[CHANGES] for details.
|
|
249
|
+
|
|
250
|
+
== Credits
|
|
251
|
+
|
|
252
|
+
Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/lib/versionaire.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "versionaire/errors/base"
|
|
|
4
4
|
require "versionaire/errors/conversion"
|
|
5
5
|
require "versionaire/errors/invalid_number"
|
|
6
6
|
require "versionaire/errors/negative_number"
|
|
7
|
+
require "versionaire/filler"
|
|
7
8
|
require "versionaire/conversion"
|
|
8
9
|
require "versionaire/identity"
|
|
9
10
|
require "versionaire/version"
|
|
@@ -7,44 +7,44 @@ module Versionaire
|
|
|
7
7
|
# Conversion function (strict) for casting an object into a version.
|
|
8
8
|
# :reek:TooManyStatements
|
|
9
9
|
def Version object
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
Converter.new(object).then do |converter|
|
|
11
|
+
case object
|
|
12
|
+
when String then converter.from_string
|
|
13
|
+
when Array then converter.from_array
|
|
14
|
+
when Hash then converter.from_hash
|
|
15
|
+
when Version then object
|
|
16
|
+
else converter.from_object
|
|
17
|
+
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Aids with converting objects into valid versions.
|
|
22
22
|
class Converter
|
|
23
|
-
def initialize object
|
|
23
|
+
def initialize object, filler: Filler.new
|
|
24
24
|
@object = object
|
|
25
|
+
@filler = filler
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def from_string
|
|
28
|
-
body =
|
|
29
|
+
body = "Use: <major>.<minor>.<patch>, <major>.<minor>, <major>, or empty string."
|
|
29
30
|
fail Errors::Conversion, error_message(object, body) unless Version.regex.match? object
|
|
30
31
|
|
|
31
|
-
Version[string_to_arguments]
|
|
32
|
+
Version[**string_to_arguments]
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def from_array
|
|
35
|
-
body = "Use: [
|
|
36
|
+
body = "Use: [<major>, <minor>, <patch>], [<major>, <minor>], [<major>], or []."
|
|
36
37
|
fail Errors::Conversion, error_message(object, body) unless (0..3).cover? object.size
|
|
37
38
|
|
|
38
|
-
Version[array_to_arguments]
|
|
39
|
+
Version[**array_to_arguments]
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def from_hash
|
|
42
|
-
body = "Use: {major: <major>}, " \
|
|
43
|
-
"{major: <major>, minor: <minor>}, or "
|
|
44
|
-
"{major: <major>, minor: <minor>, maintenance: <maintenance>}."
|
|
43
|
+
body = "Use: {major: <major>, minor: <minor>, patch: <patch>}, " \
|
|
44
|
+
"{major: <major>, minor: <minor>}, {major: <major>}, or {}."
|
|
45
45
|
fail Errors::Conversion, error_message(object, body) unless required_keys?
|
|
46
46
|
|
|
47
|
-
Version[object]
|
|
47
|
+
Version[**object]
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def from_object
|
|
@@ -53,18 +53,21 @@ module Versionaire
|
|
|
53
53
|
|
|
54
54
|
private
|
|
55
55
|
|
|
56
|
-
attr_reader :object
|
|
56
|
+
attr_reader :object, :filler
|
|
57
57
|
|
|
58
58
|
def string_to_arguments
|
|
59
|
-
|
|
59
|
+
object.split(DELIMITER)
|
|
60
|
+
.map(&:to_i)
|
|
61
|
+
.then { |numbers| filler.call numbers }
|
|
62
|
+
.then { |arguments| Version.arguments(*arguments) }
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
def array_to_arguments
|
|
63
|
-
Version.arguments(*
|
|
66
|
+
Version.arguments(*filler.call(object))
|
|
64
67
|
end
|
|
65
68
|
|
|
66
69
|
def required_keys?
|
|
67
|
-
object.keys.all? { |key|
|
|
70
|
+
object.keys.all? { |key| Version.members.include? key }
|
|
68
71
|
end
|
|
69
72
|
|
|
70
73
|
def error_message object, body
|
|
@@ -4,8 +4,8 @@ module Versionaire
|
|
|
4
4
|
module Errors
|
|
5
5
|
# Thrown when not using numbers.
|
|
6
6
|
class InvalidNumber < Base
|
|
7
|
-
def initialize message = "Major, minor, and
|
|
8
|
-
super
|
|
7
|
+
def initialize message = "Major, minor, and patch must be a number."
|
|
8
|
+
super message
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -4,8 +4,8 @@ module Versionaire
|
|
|
4
4
|
module Errors
|
|
5
5
|
# Thrown when numbers are negative.
|
|
6
6
|
class NegativeNumber < Base
|
|
7
|
-
def initialize message = "Major, minor, and
|
|
8
|
-
super
|
|
7
|
+
def initialize message = "Major, minor, and patch must be a positive number."
|
|
8
|
+
super message
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Versionaire
|
|
4
|
+
class Filler
|
|
5
|
+
def initialize pad = 0, max: 2
|
|
6
|
+
@pad = pad
|
|
7
|
+
@max = max
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call array
|
|
11
|
+
array.dup.fill pad, array.size..max
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
attr_reader :pad, :max
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/versionaire/identity.rb
CHANGED
|
@@ -3,20 +3,9 @@
|
|
|
3
3
|
module Versionaire
|
|
4
4
|
# Gem identity information.
|
|
5
5
|
module Identity
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def self.label
|
|
11
|
-
"Versionaire"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.version
|
|
15
|
-
"7.3.4"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.version_label
|
|
19
|
-
"#{label} #{version}"
|
|
20
|
-
end
|
|
6
|
+
NAME = "versionaire"
|
|
7
|
+
LABEL = "Versionaire"
|
|
8
|
+
VERSION = "8.3.0"
|
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
|
21
10
|
end
|
|
22
11
|
end
|
data/lib/versionaire/version.rb
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Versionaire
|
|
4
|
-
|
|
5
|
-
VERSION_DELIMITER = "."
|
|
4
|
+
DELIMITER = "."
|
|
6
5
|
|
|
7
6
|
# An immutable, semantic version value object.
|
|
8
|
-
|
|
9
|
-
Version = Struct.new :major, :minor, :maintenance, keyword_init: true do
|
|
7
|
+
Version = Struct.new :major, :minor, :patch, keyword_init: true do
|
|
10
8
|
include Comparable
|
|
11
9
|
|
|
12
10
|
def self.regex
|
|
13
11
|
/
|
|
14
|
-
\A
|
|
15
|
-
\d
|
|
16
|
-
#
|
|
17
|
-
\d
|
|
18
|
-
#{
|
|
19
|
-
\d
|
|
20
|
-
\
|
|
12
|
+
\A( # Start of string and OR.
|
|
13
|
+
\d* # Major only.
|
|
14
|
+
| # OR pipe.
|
|
15
|
+
\d+ # Major.
|
|
16
|
+
#{DELIMITER}? # Delimiter.
|
|
17
|
+
\d* # Minor.
|
|
18
|
+
(?:#{DELIMITER}\d+) # Passive delimiter and patch.
|
|
19
|
+
)\z # End of OR and string.
|
|
21
20
|
/x
|
|
22
21
|
end
|
|
23
22
|
|
|
24
|
-
def self.arguments major, minor,
|
|
25
|
-
Hash[
|
|
23
|
+
def self.arguments major, minor, patch
|
|
24
|
+
Hash[members.zip [major, minor, patch]]
|
|
26
25
|
end
|
|
27
26
|
|
|
28
|
-
def initialize major: 0, minor: 0,
|
|
27
|
+
def initialize major: 0, minor: 0, patch: 0
|
|
29
28
|
super
|
|
30
29
|
validate
|
|
31
30
|
freeze
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def + other
|
|
35
|
-
klass
|
|
36
|
-
klass.new klass.arguments(*reduce(other, :+))
|
|
34
|
+
self.class.then { |klass| klass.new(**klass.arguments(*reduce(other, :+))) }
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
def - other
|
|
40
|
-
klass
|
|
41
|
-
klass.new klass.arguments(*reduce(other, :-))
|
|
38
|
+
self.class.then { |klass| klass.new(**klass.arguments(*reduce(other, :-))) }
|
|
42
39
|
end
|
|
43
40
|
|
|
44
41
|
def == other
|
|
@@ -52,13 +49,13 @@ module Versionaire
|
|
|
52
49
|
end
|
|
53
50
|
|
|
54
51
|
def to_s
|
|
55
|
-
to_a.join
|
|
52
|
+
to_a.join DELIMITER
|
|
56
53
|
end
|
|
57
54
|
|
|
58
55
|
alias_method :to_str, :to_s
|
|
59
56
|
|
|
60
57
|
def to_a
|
|
61
|
-
[major, minor,
|
|
58
|
+
[major, minor, patch]
|
|
62
59
|
end
|
|
63
60
|
|
|
64
61
|
private
|
|
@@ -72,5 +69,4 @@ module Versionaire
|
|
|
72
69
|
to_a.zip(other.to_a).map { |pair| pair.reduce action }
|
|
73
70
|
end
|
|
74
71
|
end
|
|
75
|
-
# rubocop:enable Metrics/BlockLength
|
|
76
72
|
end
|
metadata
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: versionaire
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 8.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain:
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
|
-
MIIC/
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
|
|
15
|
+
NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
|
@@ -20,44 +20,16 @@ cert_chain:
|
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
|
23
|
-
2CdikiiE3fJhP/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
|
|
24
|
+
XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
|
|
25
|
+
bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
|
|
26
|
+
Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
|
|
27
|
+
7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
|
|
28
|
+
2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
|
|
29
|
+
QWc=
|
|
30
30
|
-----END CERTIFICATE-----
|
|
31
|
-
date:
|
|
31
|
+
date: 2020-10-18 00:00:00.000000000 Z
|
|
32
32
|
dependencies:
|
|
33
|
-
- !ruby/object:Gem::Dependency
|
|
34
|
-
name: awesome_print
|
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '1.8'
|
|
40
|
-
type: :development
|
|
41
|
-
prerelease: false
|
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.8'
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: bond
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0.5'
|
|
54
|
-
type: :development
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '0.5'
|
|
61
33
|
- !ruby/object:Gem::Dependency
|
|
62
34
|
name: bundler-audit
|
|
63
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -78,28 +50,28 @@ dependencies:
|
|
|
78
50
|
requirements:
|
|
79
51
|
- - "~>"
|
|
80
52
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
53
|
+
version: '14.2'
|
|
82
54
|
type: :development
|
|
83
55
|
prerelease: false
|
|
84
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
57
|
requirements:
|
|
86
58
|
- - "~>"
|
|
87
59
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
60
|
+
version: '14.2'
|
|
89
61
|
- !ruby/object:Gem::Dependency
|
|
90
|
-
name: git-
|
|
62
|
+
name: git-lint
|
|
91
63
|
requirement: !ruby/object:Gem::Requirement
|
|
92
64
|
requirements:
|
|
93
65
|
- - "~>"
|
|
94
66
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
67
|
+
version: '1.0'
|
|
96
68
|
type: :development
|
|
97
69
|
prerelease: false
|
|
98
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
71
|
requirements:
|
|
100
72
|
- - "~>"
|
|
101
73
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
74
|
+
version: '1.0'
|
|
103
75
|
- !ruby/object:Gem::Dependency
|
|
104
76
|
name: guard-rspec
|
|
105
77
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,48 +86,34 @@ dependencies:
|
|
|
114
86
|
- - "~>"
|
|
115
87
|
- !ruby/object:Gem::Version
|
|
116
88
|
version: '4.7'
|
|
117
|
-
- !ruby/object:Gem::Dependency
|
|
118
|
-
name: hirb
|
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - "~>"
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '0.7'
|
|
124
|
-
type: :development
|
|
125
|
-
prerelease: false
|
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - "~>"
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0.7'
|
|
131
89
|
- !ruby/object:Gem::Dependency
|
|
132
90
|
name: pry
|
|
133
91
|
requirement: !ruby/object:Gem::Requirement
|
|
134
92
|
requirements:
|
|
135
93
|
- - "~>"
|
|
136
94
|
- !ruby/object:Gem::Version
|
|
137
|
-
version: '0.
|
|
95
|
+
version: '0.13'
|
|
138
96
|
type: :development
|
|
139
97
|
prerelease: false
|
|
140
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
141
99
|
requirements:
|
|
142
100
|
- - "~>"
|
|
143
101
|
- !ruby/object:Gem::Version
|
|
144
|
-
version: '0.
|
|
102
|
+
version: '0.13'
|
|
145
103
|
- !ruby/object:Gem::Dependency
|
|
146
104
|
name: pry-byebug
|
|
147
105
|
requirement: !ruby/object:Gem::Requirement
|
|
148
106
|
requirements:
|
|
149
107
|
- - "~>"
|
|
150
108
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: '3.
|
|
109
|
+
version: '3.9'
|
|
152
110
|
type: :development
|
|
153
111
|
prerelease: false
|
|
154
112
|
version_requirements: !ruby/object:Gem::Requirement
|
|
155
113
|
requirements:
|
|
156
114
|
- - "~>"
|
|
157
115
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: '3.
|
|
116
|
+
version: '3.9'
|
|
159
117
|
- !ruby/object:Gem::Dependency
|
|
160
118
|
name: rake
|
|
161
119
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -176,14 +134,14 @@ dependencies:
|
|
|
176
134
|
requirements:
|
|
177
135
|
- - "~>"
|
|
178
136
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: '
|
|
137
|
+
version: '6.0'
|
|
180
138
|
type: :development
|
|
181
139
|
prerelease: false
|
|
182
140
|
version_requirements: !ruby/object:Gem::Requirement
|
|
183
141
|
requirements:
|
|
184
142
|
- - "~>"
|
|
185
143
|
- !ruby/object:Gem::Version
|
|
186
|
-
version: '
|
|
144
|
+
version: '6.0'
|
|
187
145
|
- !ruby/object:Gem::Dependency
|
|
188
146
|
name: rspec
|
|
189
147
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -204,111 +162,99 @@ dependencies:
|
|
|
204
162
|
requirements:
|
|
205
163
|
- - "~>"
|
|
206
164
|
- !ruby/object:Gem::Version
|
|
207
|
-
version: '0.
|
|
165
|
+
version: '0.89'
|
|
208
166
|
type: :development
|
|
209
167
|
prerelease: false
|
|
210
168
|
version_requirements: !ruby/object:Gem::Requirement
|
|
211
169
|
requirements:
|
|
212
170
|
- - "~>"
|
|
213
171
|
- !ruby/object:Gem::Version
|
|
214
|
-
version: '0.
|
|
172
|
+
version: '0.89'
|
|
215
173
|
- !ruby/object:Gem::Dependency
|
|
216
174
|
name: rubocop-performance
|
|
217
175
|
requirement: !ruby/object:Gem::Requirement
|
|
218
176
|
requirements:
|
|
219
177
|
- - "~>"
|
|
220
178
|
- !ruby/object:Gem::Version
|
|
221
|
-
version: '1.
|
|
179
|
+
version: '1.5'
|
|
222
180
|
type: :development
|
|
223
181
|
prerelease: false
|
|
224
182
|
version_requirements: !ruby/object:Gem::Requirement
|
|
225
183
|
requirements:
|
|
226
184
|
- - "~>"
|
|
227
185
|
- !ruby/object:Gem::Version
|
|
228
|
-
version: '1.
|
|
186
|
+
version: '1.5'
|
|
229
187
|
- !ruby/object:Gem::Dependency
|
|
230
188
|
name: rubocop-rake
|
|
231
189
|
requirement: !ruby/object:Gem::Requirement
|
|
232
190
|
requirements:
|
|
233
191
|
- - "~>"
|
|
234
192
|
- !ruby/object:Gem::Version
|
|
235
|
-
version: '0.
|
|
193
|
+
version: '0.5'
|
|
236
194
|
type: :development
|
|
237
195
|
prerelease: false
|
|
238
196
|
version_requirements: !ruby/object:Gem::Requirement
|
|
239
197
|
requirements:
|
|
240
198
|
- - "~>"
|
|
241
199
|
- !ruby/object:Gem::Version
|
|
242
|
-
version: '0.
|
|
200
|
+
version: '0.5'
|
|
243
201
|
- !ruby/object:Gem::Dependency
|
|
244
202
|
name: rubocop-rspec
|
|
245
203
|
requirement: !ruby/object:Gem::Requirement
|
|
246
204
|
requirements:
|
|
247
205
|
- - "~>"
|
|
248
206
|
- !ruby/object:Gem::Version
|
|
249
|
-
version: '1.
|
|
207
|
+
version: '1.39'
|
|
250
208
|
type: :development
|
|
251
209
|
prerelease: false
|
|
252
210
|
version_requirements: !ruby/object:Gem::Requirement
|
|
253
211
|
requirements:
|
|
254
212
|
- - "~>"
|
|
255
213
|
- !ruby/object:Gem::Version
|
|
256
|
-
version: '1.
|
|
214
|
+
version: '1.39'
|
|
257
215
|
- !ruby/object:Gem::Dependency
|
|
258
216
|
name: simplecov
|
|
259
217
|
requirement: !ruby/object:Gem::Requirement
|
|
260
218
|
requirements:
|
|
261
219
|
- - "~>"
|
|
262
220
|
- !ruby/object:Gem::Version
|
|
263
|
-
version: '0.
|
|
264
|
-
type: :development
|
|
265
|
-
prerelease: false
|
|
266
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
267
|
-
requirements:
|
|
268
|
-
- - "~>"
|
|
269
|
-
- !ruby/object:Gem::Version
|
|
270
|
-
version: '0.13'
|
|
271
|
-
- !ruby/object:Gem::Dependency
|
|
272
|
-
name: wirb
|
|
273
|
-
requirement: !ruby/object:Gem::Requirement
|
|
274
|
-
requirements:
|
|
275
|
-
- - "~>"
|
|
276
|
-
- !ruby/object:Gem::Version
|
|
277
|
-
version: '2.1'
|
|
221
|
+
version: '0.19'
|
|
278
222
|
type: :development
|
|
279
223
|
prerelease: false
|
|
280
224
|
version_requirements: !ruby/object:Gem::Requirement
|
|
281
225
|
requirements:
|
|
282
226
|
- - "~>"
|
|
283
227
|
- !ruby/object:Gem::Version
|
|
284
|
-
version: '
|
|
285
|
-
description:
|
|
228
|
+
version: '0.19'
|
|
229
|
+
description:
|
|
286
230
|
email:
|
|
287
231
|
- brooke@alchemists.io
|
|
288
232
|
executables: []
|
|
289
233
|
extensions: []
|
|
290
234
|
extra_rdoc_files:
|
|
291
|
-
- README.
|
|
292
|
-
- LICENSE.
|
|
235
|
+
- README.adoc
|
|
236
|
+
- LICENSE.adoc
|
|
293
237
|
files:
|
|
294
|
-
- LICENSE.
|
|
295
|
-
- README.
|
|
238
|
+
- LICENSE.adoc
|
|
239
|
+
- README.adoc
|
|
296
240
|
- lib/versionaire.rb
|
|
297
241
|
- lib/versionaire/conversion.rb
|
|
298
242
|
- lib/versionaire/errors/base.rb
|
|
299
243
|
- lib/versionaire/errors/conversion.rb
|
|
300
244
|
- lib/versionaire/errors/invalid_number.rb
|
|
301
245
|
- lib/versionaire/errors/negative_number.rb
|
|
246
|
+
- lib/versionaire/filler.rb
|
|
302
247
|
- lib/versionaire/identity.rb
|
|
303
248
|
- lib/versionaire/version.rb
|
|
304
|
-
homepage: https://
|
|
249
|
+
homepage: https://www.alchemists.io/projects/versionaire
|
|
305
250
|
licenses:
|
|
306
251
|
- Apache-2.0
|
|
307
252
|
metadata:
|
|
308
|
-
source_code_uri: https://github.com/bkuhlmann/versionaire
|
|
309
|
-
changelog_uri: https://github.com/bkuhlmann/versionaire/blob/master/CHANGES.md
|
|
310
253
|
bug_tracker_uri: https://github.com/bkuhlmann/versionaire/issues
|
|
311
|
-
|
|
254
|
+
changelog_uri: https://www.alchemists.io/projects/versionaire/changes.html
|
|
255
|
+
documentation_uri: https://www.alchemists.io/projects/versionaire
|
|
256
|
+
source_code_uri: https://github.com/bkuhlmann/versionaire
|
|
257
|
+
post_install_message:
|
|
312
258
|
rdoc_options: []
|
|
313
259
|
require_paths:
|
|
314
260
|
- lib
|
|
@@ -316,15 +262,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
316
262
|
requirements:
|
|
317
263
|
- - "~>"
|
|
318
264
|
- !ruby/object:Gem::Version
|
|
319
|
-
version: '2.
|
|
265
|
+
version: '2.7'
|
|
320
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
267
|
requirements:
|
|
322
268
|
- - ">="
|
|
323
269
|
- !ruby/object:Gem::Version
|
|
324
270
|
version: '0'
|
|
325
271
|
requirements: []
|
|
326
|
-
rubygems_version: 3.
|
|
327
|
-
signing_key:
|
|
272
|
+
rubygems_version: 3.1.4
|
|
273
|
+
signing_key:
|
|
328
274
|
specification_version: 4
|
|
329
|
-
summary: Provides immutable, thread-safe, semantic
|
|
275
|
+
summary: Provides an immutable, thread-safe, and semantic version type.
|
|
330
276
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|
data/README.md
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="versionaire.png" alt="Versionaire Icon"/>
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
# Versionaire
|
|
6
|
-
|
|
7
|
-
[](http://badge.fury.io/rb/versionaire)
|
|
8
|
-
[](https://codeclimate.com/github/bkuhlmann/versionaire/maintainability)
|
|
9
|
-
[](https://codeclimate.com/github/bkuhlmann/versionaire/test_coverage)
|
|
10
|
-
[](https://circleci.com/gh/bkuhlmann/versionaire)
|
|
11
|
-
|
|
12
|
-
Provides immutable, thread-safe, semantic versioning.
|
|
13
|
-
|
|
14
|
-
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
|
15
|
-
|
|
16
|
-
## Table of Contents
|
|
17
|
-
|
|
18
|
-
- [Features](#features)
|
|
19
|
-
- [Screencasts](#screencasts)
|
|
20
|
-
- [Requirements](#requirements)
|
|
21
|
-
- [Setup](#setup)
|
|
22
|
-
- [Usage](#usage)
|
|
23
|
-
- [Initialization](#initialization)
|
|
24
|
-
- [Equality](#equality)
|
|
25
|
-
- [Value (`#==`)](#value-)
|
|
26
|
-
- [Hash (`#eql?`)](#hash-eql)
|
|
27
|
-
- [Case (`#===`)](#case-)
|
|
28
|
-
- [Identity (`#equal?`)](#identity-equal)
|
|
29
|
-
- [Conversions](#conversions)
|
|
30
|
-
- [Function (Casting)](#function-casting)
|
|
31
|
-
- [Implicit](#implicit)
|
|
32
|
-
- [Explicit](#explicit)
|
|
33
|
-
- [Comparisons](#comparisons)
|
|
34
|
-
- [Math](#math)
|
|
35
|
-
- [Addition](#addition)
|
|
36
|
-
- [Subtraction](#subtraction)
|
|
37
|
-
- [Tests](#tests)
|
|
38
|
-
- [Versioning](#versioning)
|
|
39
|
-
- [Code of Conduct](#code-of-conduct)
|
|
40
|
-
- [Contributions](#contributions)
|
|
41
|
-
- [License](#license)
|
|
42
|
-
- [History](#history)
|
|
43
|
-
- [Credits](#credits)
|
|
44
|
-
|
|
45
|
-
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
|
46
|
-
|
|
47
|
-
## Features
|
|
48
|
-
|
|
49
|
-
- Provides [Semantic Versioning](https://semver.org).
|
|
50
|
-
- Provides immutable, thread-safe version instances.
|
|
51
|
-
- Provides conversions (casts) from a `String`, `Array`, `Hash`, or `Version` to a `Version`.
|
|
52
|
-
|
|
53
|
-
## Screencasts
|
|
54
|
-
|
|
55
|
-
[](https://asciinema.org/a/263062)
|
|
56
|
-
|
|
57
|
-
## Requirements
|
|
58
|
-
|
|
59
|
-
1. [Ruby 2.6.x](https://www.ruby-lang.org).
|
|
60
|
-
|
|
61
|
-
## Setup
|
|
62
|
-
|
|
63
|
-
Type the following to install:
|
|
64
|
-
|
|
65
|
-
gem install versionaire
|
|
66
|
-
|
|
67
|
-
Add the following to your Gemfile:
|
|
68
|
-
|
|
69
|
-
gem "versionaire"
|
|
70
|
-
|
|
71
|
-
## Usage
|
|
72
|
-
|
|
73
|
-
### Initialization
|
|
74
|
-
|
|
75
|
-
A new version can be initialized in a variety of ways:
|
|
76
|
-
|
|
77
|
-
Versionaire::Version.new # "0.0.0"
|
|
78
|
-
Versionaire::Version[major: 1] # "1.0.0"
|
|
79
|
-
Versionaire::Version[major: 1, minor: 2] # "1.2.0"
|
|
80
|
-
Versionaire::Version[major: 1, minor: 2, maintenance: 3] # "1.2.3"
|
|
81
|
-
|
|
82
|
-
### Equality
|
|
83
|
-
|
|
84
|
-
#### Value (`#==`)
|
|
85
|
-
|
|
86
|
-
Equality is deterimined by the state of the object. This means that a version is equal to another
|
|
87
|
-
version as long as all of the values (i.e. state) are equal to each other. Example:
|
|
88
|
-
|
|
89
|
-
version_a = Versionaire::Version[major: 1]
|
|
90
|
-
version_b = Versionaire::Version[major: 2]
|
|
91
|
-
version_c = Versionaire::Version[major: 1]
|
|
92
|
-
|
|
93
|
-
version_a == version_a # true
|
|
94
|
-
version_a == version_b # false
|
|
95
|
-
version_a == version_c # true
|
|
96
|
-
|
|
97
|
-
Knowning this, versions can be compared against one another too:
|
|
98
|
-
|
|
99
|
-
version_a > version_b # false
|
|
100
|
-
version_a < version_b # true
|
|
101
|
-
version_a.between? version_c, version_b # true
|
|
102
|
-
|
|
103
|
-
#### Hash (`#eql?`)
|
|
104
|
-
|
|
105
|
-
Behaves exactly as `#==`.
|
|
106
|
-
|
|
107
|
-
#### Case (`#===`)
|
|
108
|
-
|
|
109
|
-
Behaves exactly as `#==`.
|
|
110
|
-
|
|
111
|
-
#### Identity (`#equal?`)
|
|
112
|
-
|
|
113
|
-
Works like any other standard Ruby object where an object is equal only to itself.
|
|
114
|
-
|
|
115
|
-
version_a = Versionaire::Version[major: 1]
|
|
116
|
-
version_b = Versionaire::Version[major: 2]
|
|
117
|
-
version_c = Versionaire::Version[major: 1]
|
|
118
|
-
|
|
119
|
-
version_a.equal? version_a # true
|
|
120
|
-
version_a.equal? version_b # false
|
|
121
|
-
version_a.equal? version_c # false
|
|
122
|
-
|
|
123
|
-
### Conversions
|
|
124
|
-
|
|
125
|
-
#### Function (Casting)
|
|
126
|
-
|
|
127
|
-
The `Versionaire::Version` function is provided for explicit casting to a version:
|
|
128
|
-
|
|
129
|
-
version = Versionaire::Version[major: 1]
|
|
130
|
-
|
|
131
|
-
Versionaire::Version "1.0.0"
|
|
132
|
-
Versionaire::Version [1, 0, 0]
|
|
133
|
-
Versionaire::Version major: 1, minor: 0, maintenance: 0
|
|
134
|
-
Versionaire::Version version
|
|
135
|
-
|
|
136
|
-
Each of these conversions will result in a version object that represents "1.0.0". When attempting
|
|
137
|
-
to convert an unsupported type, a `Versionaire::Errors::Conversion` exception will be thrown.
|
|
138
|
-
|
|
139
|
-
#### Implicit
|
|
140
|
-
|
|
141
|
-
Implicit conversion to a `String` is supported:
|
|
142
|
-
|
|
143
|
-
"1.0.0".match Versionaire::Version[major: 1] # <MatchData "1.0.0">
|
|
144
|
-
|
|
145
|
-
#### Explicit
|
|
146
|
-
|
|
147
|
-
Explicit conversion to a `String`, `Array`, or `Hash` is supported:
|
|
148
|
-
|
|
149
|
-
version = Versionaire::Version.new
|
|
150
|
-
|
|
151
|
-
version.to_s # "0.0.0"
|
|
152
|
-
version.to_a # [0, 0, 0]
|
|
153
|
-
version.to_h # {major: 0, minor: 0, maintenance: 0}
|
|
154
|
-
|
|
155
|
-
### Comparisons
|
|
156
|
-
|
|
157
|
-
All versions are comparable which means any of the operators from the `Comparable` module will work.
|
|
158
|
-
Example:
|
|
159
|
-
|
|
160
|
-
version_1 = Versionaire::Version "1.0.0"
|
|
161
|
-
version_2 = Versionaire::Version "2.0.0"
|
|
162
|
-
|
|
163
|
-
version_1 < version_2 # true
|
|
164
|
-
version_1 <= version_2 # true
|
|
165
|
-
version_1 == version_2 # false (see Equality section above for details)
|
|
166
|
-
version_1 > version_2 # false
|
|
167
|
-
version_1 >= version_2 # false
|
|
168
|
-
version_1.between? version_1, version_2 # true
|
|
169
|
-
version_1.clamp version_1, version_2 # version_1 (added in Ruby 2.4.0)
|
|
170
|
-
|
|
171
|
-
### Math
|
|
172
|
-
|
|
173
|
-
Versions can be added and subtracted from each other.
|
|
174
|
-
|
|
175
|
-
#### Addition
|
|
176
|
-
|
|
177
|
-
version_1 = Versionaire::Version[major: 1, minor: 2, maintenance: 3]
|
|
178
|
-
version_2 = Versionaire::Version[major: 2, minor: 5, maintenance: 7]
|
|
179
|
-
version_1 + version_2 # "3.7.10"
|
|
180
|
-
|
|
181
|
-
#### Subtraction
|
|
182
|
-
|
|
183
|
-
version_1 = Versionaire::Version[major: 1, minor: 2, maintenance: 3]
|
|
184
|
-
version_2 = Versionaire::Version[major: 1, minor: 1, maintenance: 1]
|
|
185
|
-
version_1 - version_2 # "0.1.2"
|
|
186
|
-
|
|
187
|
-
version_1 = Versionaire::Version[major: 1]
|
|
188
|
-
version_2 = Versionaire::Version[major: 5]
|
|
189
|
-
version_1 - version_2 # Fails with a Versionaire::Errors::NegativeNumber
|
|
190
|
-
|
|
191
|
-
## Tests
|
|
192
|
-
|
|
193
|
-
To test, run:
|
|
194
|
-
|
|
195
|
-
bundle exec rake
|
|
196
|
-
|
|
197
|
-
## Versioning
|
|
198
|
-
|
|
199
|
-
Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
|
|
200
|
-
|
|
201
|
-
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
|
202
|
-
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
|
203
|
-
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
|
204
|
-
|
|
205
|
-
## Code of Conduct
|
|
206
|
-
|
|
207
|
-
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
|
|
208
|
-
participating in this project you agree to abide by its terms.
|
|
209
|
-
|
|
210
|
-
## Contributions
|
|
211
|
-
|
|
212
|
-
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
|
213
|
-
|
|
214
|
-
## License
|
|
215
|
-
|
|
216
|
-
Copyright 2016 [Alchemists](https://www.alchemists.io).
|
|
217
|
-
Read [LICENSE](LICENSE.md) for details.
|
|
218
|
-
|
|
219
|
-
## History
|
|
220
|
-
|
|
221
|
-
Read [CHANGES](CHANGES.md) for details.
|
|
222
|
-
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
|
223
|
-
|
|
224
|
-
## Credits
|
|
225
|
-
|
|
226
|
-
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
|
227
|
-
[Alchemists](https://www.alchemists.io).
|