versionaire 7.3.3 → 8.2.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 +254 -0
- data/lib/versionaire.rb +1 -0
- data/lib/versionaire/conversion.rb +24 -21
- data/lib/versionaire/errors/invalid_number.rb +1 -1
- data/lib/versionaire/errors/negative_number.rb +1 -1
- data/lib/versionaire/filler.rb +18 -0
- data/lib/versionaire/identity.rb +4 -15
- data/lib/versionaire/version.rb +17 -19
- metadata +56 -96
- metadata.gz.sig +1 -5
- 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: c7856bdc9290014c751c767f1534b7f492ebeb33aed4838f2dc84277428f3796
|
|
4
|
+
data.tar.gz: 23d02f9d4a7fb583762ba481492f5681f2111b560c57659537aa1630412ad4b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bbd73613229106b44da7f64103b86baf799d2e3f32cc8c4e5f93bc73fae66bf52ed71e0ef52f858d60cb2e92c2da6c2b541c3b02d97d5e23319905194199bb47
|
|
7
|
+
data.tar.gz: cb202da5b41d341454c5adeea9bf7070270ad39db9ad900661285e2121191bbb7b98655650bfdfd576cacb546249e270c73b791e66672d53e5544510ee05a31f
|
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
|
|
153
|
+
Copyright link:https://www.alchemists.io[Alchemists].
|
|
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,254 @@
|
|
|
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
|
+
=== Production
|
|
35
|
+
|
|
36
|
+
To install, run:
|
|
37
|
+
|
|
38
|
+
[source,bash]
|
|
39
|
+
----
|
|
40
|
+
gem install versionaire
|
|
41
|
+
----
|
|
42
|
+
|
|
43
|
+
Add the following to your Gemfile:
|
|
44
|
+
|
|
45
|
+
[source,ruby]
|
|
46
|
+
----
|
|
47
|
+
gem "versionaire"
|
|
48
|
+
----
|
|
49
|
+
|
|
50
|
+
=== Development
|
|
51
|
+
|
|
52
|
+
To contribute, run:
|
|
53
|
+
|
|
54
|
+
[source,bash]
|
|
55
|
+
----
|
|
56
|
+
git clone https://github.com/bkuhlmann/versionaire.git
|
|
57
|
+
cd versionaire
|
|
58
|
+
bin/setup
|
|
59
|
+
----
|
|
60
|
+
|
|
61
|
+
You can also use the IRB console for direct access to all objects:
|
|
62
|
+
|
|
63
|
+
[source,bash]
|
|
64
|
+
----
|
|
65
|
+
bin/console
|
|
66
|
+
----
|
|
67
|
+
|
|
68
|
+
== Usage
|
|
69
|
+
|
|
70
|
+
=== Initialization
|
|
71
|
+
|
|
72
|
+
A new version can be initialized in a variety of ways:
|
|
73
|
+
|
|
74
|
+
[source,ruby]
|
|
75
|
+
----
|
|
76
|
+
Versionaire::Version.new # "0.0.0"
|
|
77
|
+
Versionaire::Version[major: 1] # "1.0.0"
|
|
78
|
+
Versionaire::Version[major: 1, minor: 2] # "1.2.0"
|
|
79
|
+
Versionaire::Version[major: 1, minor: 2, patch: 3] # "1.2.3"
|
|
80
|
+
----
|
|
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
|
+
[source,ruby]
|
|
90
|
+
----
|
|
91
|
+
version_a = Versionaire::Version[major: 1]
|
|
92
|
+
version_b = Versionaire::Version[major: 2]
|
|
93
|
+
version_c = Versionaire::Version[major: 1]
|
|
94
|
+
|
|
95
|
+
version_a == version_a # true
|
|
96
|
+
version_a == version_b # false
|
|
97
|
+
version_a == version_c # true
|
|
98
|
+
----
|
|
99
|
+
|
|
100
|
+
Knowning this, versions can be compared against one another too:
|
|
101
|
+
|
|
102
|
+
[source,ruby]
|
|
103
|
+
----
|
|
104
|
+
version_a > version_b # false
|
|
105
|
+
version_a < version_b # true
|
|
106
|
+
version_a.between? version_c, version_b # true
|
|
107
|
+
----
|
|
108
|
+
|
|
109
|
+
==== Hash (`#eql?`)
|
|
110
|
+
|
|
111
|
+
Behaves exactly as `#==`.
|
|
112
|
+
|
|
113
|
+
==== Case (`#===`)
|
|
114
|
+
|
|
115
|
+
Behaves exactly as `#==`.
|
|
116
|
+
|
|
117
|
+
==== Identity (`#equal?`)
|
|
118
|
+
|
|
119
|
+
Works like any other standard Ruby object where an object is equal only to itself.
|
|
120
|
+
|
|
121
|
+
[source,ruby]
|
|
122
|
+
----
|
|
123
|
+
version_a = Versionaire::Version[major: 1]
|
|
124
|
+
version_b = Versionaire::Version[major: 2]
|
|
125
|
+
version_c = Versionaire::Version[major: 1]
|
|
126
|
+
|
|
127
|
+
version_a.equal? version_a # true
|
|
128
|
+
version_a.equal? version_b # false
|
|
129
|
+
version_a.equal? version_c # false
|
|
130
|
+
----
|
|
131
|
+
|
|
132
|
+
=== Conversions
|
|
133
|
+
|
|
134
|
+
==== Function (Casting)
|
|
135
|
+
|
|
136
|
+
The `Versionaire::Version` function is provided for explicit casting to a version:
|
|
137
|
+
|
|
138
|
+
[source,ruby]
|
|
139
|
+
----
|
|
140
|
+
version = Versionaire::Version[major: 1]
|
|
141
|
+
|
|
142
|
+
Versionaire::Version "1.0.0"
|
|
143
|
+
Versionaire::Version [1, 0, 0]
|
|
144
|
+
Versionaire::Version major: 1, minor: 0, patch: 0
|
|
145
|
+
Versionaire::Version version
|
|
146
|
+
----
|
|
147
|
+
|
|
148
|
+
Each of these conversions will result in a version object that represents "`1.0.0`". When attempting
|
|
149
|
+
to convert an unsupported type, a `+Versionaire::Errors::Conversion+` exception will be thrown.
|
|
150
|
+
|
|
151
|
+
==== Implicit
|
|
152
|
+
|
|
153
|
+
Implicit conversion to a `+String+` is supported:
|
|
154
|
+
|
|
155
|
+
[source,ruby]
|
|
156
|
+
----
|
|
157
|
+
"1.0.0".match Versionaire::Version[major: 1] # <MatchData "1.0.0">
|
|
158
|
+
----
|
|
159
|
+
|
|
160
|
+
==== Explicit
|
|
161
|
+
|
|
162
|
+
Explicit conversion to a `String`, `Array`, or `Hash` is supported:
|
|
163
|
+
|
|
164
|
+
[source,ruby]
|
|
165
|
+
----
|
|
166
|
+
version = Versionaire::Version.new
|
|
167
|
+
|
|
168
|
+
version.to_s # "0.0.0"
|
|
169
|
+
version.to_a # [0, 0, 0]
|
|
170
|
+
version.to_h # {major: 0, minor: 0, patch: 0}
|
|
171
|
+
----
|
|
172
|
+
|
|
173
|
+
=== Comparisons
|
|
174
|
+
|
|
175
|
+
All versions are comparable which means any of the operators from the `+Comparable+` module will
|
|
176
|
+
work. Example:
|
|
177
|
+
|
|
178
|
+
[source,ruby]
|
|
179
|
+
----
|
|
180
|
+
version_1 = Versionaire::Version "1.0.0"
|
|
181
|
+
version_2 = Versionaire::Version "2.0.0"
|
|
182
|
+
|
|
183
|
+
version_1 < version_2 # true
|
|
184
|
+
version_1 <= version_2 # true
|
|
185
|
+
version_1 == version_2 # false (see Equality section above for details)
|
|
186
|
+
version_1 > version_2 # false
|
|
187
|
+
version_1 >= version_2 # false
|
|
188
|
+
version_1.between? version_1, version_2 # true
|
|
189
|
+
version_1.clamp version_1, version_2 # version_1 (added in Ruby 2.4.0)
|
|
190
|
+
----
|
|
191
|
+
|
|
192
|
+
=== Math
|
|
193
|
+
|
|
194
|
+
Versions can be added and subtracted from each other.
|
|
195
|
+
|
|
196
|
+
==== Addition
|
|
197
|
+
|
|
198
|
+
[source,ruby]
|
|
199
|
+
----
|
|
200
|
+
version_1 = Versionaire::Version[major: 1, minor: 2, patch: 3]
|
|
201
|
+
version_2 = Versionaire::Version[major: 2, minor: 5, patch: 7]
|
|
202
|
+
version_1 + version_2 # "3.7.10"
|
|
203
|
+
----
|
|
204
|
+
|
|
205
|
+
==== Subtraction
|
|
206
|
+
|
|
207
|
+
[source,ruby]
|
|
208
|
+
----
|
|
209
|
+
version_1 = Versionaire::Version[major: 1, minor: 2, patch: 3]
|
|
210
|
+
version_2 = Versionaire::Version[major: 1, minor: 1, patch: 1]
|
|
211
|
+
version_1 - version_2 # "0.1.2"
|
|
212
|
+
|
|
213
|
+
version_1 = Versionaire::Version[major: 1]
|
|
214
|
+
version_2 = Versionaire::Version[major: 5]
|
|
215
|
+
version_1 - version_2 # Fails with a Versionaire::Errors::NegativeNumber
|
|
216
|
+
----
|
|
217
|
+
|
|
218
|
+
== Tests
|
|
219
|
+
|
|
220
|
+
To test, run:
|
|
221
|
+
|
|
222
|
+
[source,bash]
|
|
223
|
+
----
|
|
224
|
+
bundle exec rake
|
|
225
|
+
----
|
|
226
|
+
|
|
227
|
+
== Versioning
|
|
228
|
+
|
|
229
|
+
Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
|
|
230
|
+
|
|
231
|
+
* Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
|
232
|
+
* Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
|
233
|
+
* Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
|
234
|
+
|
|
235
|
+
== Code of Conduct
|
|
236
|
+
|
|
237
|
+
Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
|
|
238
|
+
participating in this project you agree to abide by its terms.
|
|
239
|
+
|
|
240
|
+
== Contributions
|
|
241
|
+
|
|
242
|
+
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
|
243
|
+
|
|
244
|
+
== License
|
|
245
|
+
|
|
246
|
+
Read link:LICENSE.adoc[LICENSE] for details.
|
|
247
|
+
|
|
248
|
+
== History
|
|
249
|
+
|
|
250
|
+
Read link:CHANGES.adoc[CHANGES] for details.
|
|
251
|
+
|
|
252
|
+
== Credits
|
|
253
|
+
|
|
254
|
+
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,7 +4,7 @@ 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
|
|
7
|
+
def initialize message = "Major, minor, and patch must be a number."
|
|
8
8
|
super
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -4,7 +4,7 @@ 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
|
|
7
|
+
def initialize message = "Major, minor, and patch must be a positive number."
|
|
8
8
|
super
|
|
9
9
|
end
|
|
10
10
|
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.3"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def self.version_label
|
|
19
|
-
"#{label} #{version}"
|
|
20
|
-
end
|
|
6
|
+
NAME = "versionaire"
|
|
7
|
+
LABEL = "Versionaire"
|
|
8
|
+
VERSION = "8.2.0"
|
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
|
21
10
|
end
|
|
22
11
|
end
|
data/lib/versionaire/version.rb
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
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
7
|
# rubocop:disable Metrics/BlockLength
|
|
9
|
-
Version = Struct.new :major, :minor, :
|
|
8
|
+
Version = Struct.new :major, :minor, :patch, keyword_init: true do
|
|
10
9
|
include Comparable
|
|
11
10
|
|
|
12
11
|
def self.regex
|
|
13
12
|
/
|
|
14
|
-
\A
|
|
15
|
-
\d
|
|
16
|
-
#
|
|
17
|
-
\d
|
|
18
|
-
#{
|
|
19
|
-
\d
|
|
20
|
-
\
|
|
13
|
+
\A( # Start of string and OR.
|
|
14
|
+
\d* # Major only.
|
|
15
|
+
| # OR pipe.
|
|
16
|
+
\d+ # Major.
|
|
17
|
+
#{DELIMITER}? # Delimiter.
|
|
18
|
+
\d* # Minor.
|
|
19
|
+
(?:#{DELIMITER}\d+) # Passive delimiter and patch.
|
|
20
|
+
)\z # End of OR and string.
|
|
21
21
|
/x
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def self.arguments major, minor,
|
|
25
|
-
Hash[
|
|
24
|
+
def self.arguments major, minor, patch
|
|
25
|
+
Hash[members.zip [major, minor, patch]]
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def initialize major: 0, minor: 0,
|
|
28
|
+
def initialize major: 0, minor: 0, patch: 0
|
|
29
29
|
super
|
|
30
30
|
validate
|
|
31
31
|
freeze
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def + other
|
|
35
|
-
klass
|
|
36
|
-
klass.new klass.arguments(*reduce(other, :+))
|
|
35
|
+
self.class.then { |klass| klass.new(**klass.arguments(*reduce(other, :+))) }
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
def - other
|
|
40
|
-
klass
|
|
41
|
-
klass.new klass.arguments(*reduce(other, :-))
|
|
39
|
+
self.class.then { |klass| klass.new(**klass.arguments(*reduce(other, :-))) }
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
def == other
|
|
@@ -52,13 +50,13 @@ module Versionaire
|
|
|
52
50
|
end
|
|
53
51
|
|
|
54
52
|
def to_s
|
|
55
|
-
to_a.join
|
|
53
|
+
to_a.join DELIMITER
|
|
56
54
|
end
|
|
57
55
|
|
|
58
56
|
alias_method :to_str, :to_s
|
|
59
57
|
|
|
60
58
|
def to_a
|
|
61
|
-
[major, minor,
|
|
59
|
+
[major, minor, patch]
|
|
62
60
|
end
|
|
63
61
|
|
|
64
62
|
private
|
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.2.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-07-23 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,187 +86,175 @@ 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
|
|
162
120
|
requirements:
|
|
163
121
|
- - "~>"
|
|
164
122
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: '
|
|
123
|
+
version: '13.0'
|
|
166
124
|
type: :development
|
|
167
125
|
prerelease: false
|
|
168
126
|
version_requirements: !ruby/object:Gem::Requirement
|
|
169
127
|
requirements:
|
|
170
128
|
- - "~>"
|
|
171
129
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: '
|
|
130
|
+
version: '13.0'
|
|
173
131
|
- !ruby/object:Gem::Dependency
|
|
174
132
|
name: reek
|
|
175
133
|
requirement: !ruby/object:Gem::Requirement
|
|
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
|
|
190
148
|
requirements:
|
|
191
149
|
- - "~>"
|
|
192
150
|
- !ruby/object:Gem::Version
|
|
193
|
-
version: '3.
|
|
151
|
+
version: '3.9'
|
|
194
152
|
type: :development
|
|
195
153
|
prerelease: false
|
|
196
154
|
version_requirements: !ruby/object:Gem::Requirement
|
|
197
155
|
requirements:
|
|
198
156
|
- - "~>"
|
|
199
157
|
- !ruby/object:Gem::Version
|
|
200
|
-
version: '3.
|
|
158
|
+
version: '3.9'
|
|
201
159
|
- !ruby/object:Gem::Dependency
|
|
202
160
|
name: rubocop
|
|
203
161
|
requirement: !ruby/object:Gem::Requirement
|
|
204
162
|
requirements:
|
|
205
163
|
- - "~>"
|
|
206
164
|
- !ruby/object:Gem::Version
|
|
207
|
-
version: '0.
|
|
165
|
+
version: '0.83'
|
|
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.83'
|
|
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
|
-
name: rubocop-
|
|
188
|
+
name: rubocop-rake
|
|
231
189
|
requirement: !ruby/object:Gem::Requirement
|
|
232
190
|
requirements:
|
|
233
191
|
- - "~>"
|
|
234
192
|
- !ruby/object:Gem::Version
|
|
235
|
-
version: '
|
|
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: '
|
|
200
|
+
version: '0.5'
|
|
243
201
|
- !ruby/object:Gem::Dependency
|
|
244
|
-
name:
|
|
202
|
+
name: rubocop-rspec
|
|
245
203
|
requirement: !ruby/object:Gem::Requirement
|
|
246
204
|
requirements:
|
|
247
205
|
- - "~>"
|
|
248
206
|
- !ruby/object:Gem::Version
|
|
249
|
-
version: '
|
|
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: '
|
|
214
|
+
version: '1.39'
|
|
257
215
|
- !ruby/object:Gem::Dependency
|
|
258
|
-
name:
|
|
216
|
+
name: simplecov
|
|
259
217
|
requirement: !ruby/object:Gem::Requirement
|
|
260
218
|
requirements:
|
|
261
219
|
- - "~>"
|
|
262
220
|
- !ruby/object:Gem::Version
|
|
263
|
-
version: '
|
|
221
|
+
version: '0.18'
|
|
264
222
|
type: :development
|
|
265
223
|
prerelease: false
|
|
266
224
|
version_requirements: !ruby/object:Gem::Requirement
|
|
267
225
|
requirements:
|
|
268
226
|
- - "~>"
|
|
269
227
|
- !ruby/object:Gem::Version
|
|
270
|
-
version: '
|
|
271
|
-
description:
|
|
228
|
+
version: '0.18'
|
|
229
|
+
description:
|
|
272
230
|
email:
|
|
273
231
|
- brooke@alchemists.io
|
|
274
232
|
executables: []
|
|
275
233
|
extensions: []
|
|
276
234
|
extra_rdoc_files:
|
|
277
|
-
- README.
|
|
278
|
-
- LICENSE.
|
|
235
|
+
- README.adoc
|
|
236
|
+
- LICENSE.adoc
|
|
279
237
|
files:
|
|
280
|
-
- LICENSE.
|
|
281
|
-
- README.
|
|
238
|
+
- LICENSE.adoc
|
|
239
|
+
- README.adoc
|
|
282
240
|
- lib/versionaire.rb
|
|
283
241
|
- lib/versionaire/conversion.rb
|
|
284
242
|
- lib/versionaire/errors/base.rb
|
|
285
243
|
- lib/versionaire/errors/conversion.rb
|
|
286
244
|
- lib/versionaire/errors/invalid_number.rb
|
|
287
245
|
- lib/versionaire/errors/negative_number.rb
|
|
246
|
+
- lib/versionaire/filler.rb
|
|
288
247
|
- lib/versionaire/identity.rb
|
|
289
248
|
- lib/versionaire/version.rb
|
|
290
|
-
homepage: https://
|
|
249
|
+
homepage: https://www.alchemists.io/projects/versionaire
|
|
291
250
|
licenses:
|
|
292
251
|
- Apache-2.0
|
|
293
252
|
metadata:
|
|
294
|
-
source_code_uri: https://github.com/bkuhlmann/versionaire
|
|
295
|
-
changelog_uri: https://github.com/bkuhlmann/versionaire/blob/master/CHANGES.md
|
|
296
253
|
bug_tracker_uri: https://github.com/bkuhlmann/versionaire/issues
|
|
297
|
-
|
|
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:
|
|
298
258
|
rdoc_options: []
|
|
299
259
|
require_paths:
|
|
300
260
|
- lib
|
|
@@ -302,15 +262,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
302
262
|
requirements:
|
|
303
263
|
- - "~>"
|
|
304
264
|
- !ruby/object:Gem::Version
|
|
305
|
-
version: '2.
|
|
265
|
+
version: '2.7'
|
|
306
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
267
|
requirements:
|
|
308
268
|
- - ">="
|
|
309
269
|
- !ruby/object:Gem::Version
|
|
310
270
|
version: '0'
|
|
311
271
|
requirements: []
|
|
312
|
-
rubygems_version: 3.
|
|
313
|
-
signing_key:
|
|
272
|
+
rubygems_version: 3.1.4
|
|
273
|
+
signing_key:
|
|
314
274
|
specification_version: 4
|
|
315
|
-
summary: Provides immutable, thread-safe, semantic
|
|
275
|
+
summary: Provides an immutable, thread-safe, and semantic version type.
|
|
316
276
|
test_files: []
|
metadata.gz.sig
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
�)
|
|
2
|
-
���O5�o�x4ޜ4�HmB�͗��E����A���i`aD2@G�a�A@כ��ka�$�
|
|
3
|
-
r��U���B�r��1�� Jϣ�_��>�ۡ6(B�Kl|�`��2�aVw�k�W)�&�ɼy�����u��)
|
|
4
|
-
l���ϵ���[�H���.B���?�Mzg�
|
|
5
|
-
^���<�c�����<�R2�*���<��`x>�*�ũ
|
|
1
|
+
���b��͂�]�p�j�7�����&�| nG���$��X��)�I��㩠��9W8q��Zw +/���~�y����2t������� ���tӗn�K�v�
|
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).
|