versionaire 7.3.4 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e231ad66954a0d85ea1aed69133b2201ae4438ba14f20220c1eeb49f04821bbf
4
- data.tar.gz: 26de9426d482dfc0231ecd6abdbb05e6d55fb52b0886206cd020ab0631c9989b
3
+ metadata.gz: 6dc5f90be8b452ad0343851d2694d4395bd788c8a41ab56f816f678d437d1f9b
4
+ data.tar.gz: 40642a094aa8f0cdab7d21fd9b90dd047b69d189bf455c24260d44c729c937c5
5
5
  SHA512:
6
- metadata.gz: a64e7f0055d5856febf856ccce1759d0468c231f42d6fdd5ee7ffaea8685b1ab55471f4ad45c809b021148dbb5945ae57db15496e28ea50c8c1117db23705353
7
- data.tar.gz: 64ac13585e2f1e95238d7b57d371be5ba8fa57bce5d6139ca1bc7b07cf33211f94ed0f6403dfe0659a63b2015e8277434b27164d18df6989fcba5613b20a8df4
6
+ metadata.gz: 80d314bbaf716a057bd75d0896c1cc0d44435cbd6c76d529e5639bd88a942a5c575e7307aa5497a2668c1fca679117c27c6e15f07c43280bfb727821dd86d5a6
7
+ data.tar.gz: 22b19780daed16074834b5668e30f353948392e8f3b5d2021ed19b766d051a27b074df0118cb86f5c755a7ab3fee3cad4b518cc25fd5cb52447de9f111db6ef1
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -9,7 +9,8 @@
9
9
  [![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/e61fa9230ecc0bfa6f07/test_coverage)](https://codeclimate.com/github/bkuhlmann/versionaire/test_coverage)
10
10
  [![Circle CI Status](https://circleci.com/gh/bkuhlmann/versionaire.svg?style=svg)](https://circleci.com/gh/bkuhlmann/versionaire)
11
11
 
12
- Provides immutable, thread-safe, semantic versioning.
12
+ Provides an immutable, thread-safe, and semantic version type when managing versions within your
13
+ applications.
13
14
 
14
15
  <!-- Tocer[start]: Auto-generated, don't remove. -->
15
16
 
@@ -48,11 +49,11 @@ Provides immutable, thread-safe, semantic versioning.
48
49
 
49
50
  - Provides [Semantic Versioning](https://semver.org).
50
51
  - Provides immutable, thread-safe version instances.
51
- - Provides conversions (casts) from a `String`, `Array`, `Hash`, or `Version` to a `Version`.
52
+ - Converts (casts) from a `String`, `Array`, `Hash`, or `Version` to a `Version`.
52
53
 
53
54
  ## Screencasts
54
55
 
55
- [![asciicast](https://asciinema.org/a/263062.svg)](https://asciinema.org/a/263062)
56
+ [![asciicast](https://asciinema.org/a/278658.svg)](https://asciinema.org/a/278658)
56
57
 
57
58
  ## Requirements
58
59
 
@@ -77,7 +78,7 @@ A new version can be initialized in a variety of ways:
77
78
  Versionaire::Version.new # "0.0.0"
78
79
  Versionaire::Version[major: 1] # "1.0.0"
79
80
  Versionaire::Version[major: 1, minor: 2] # "1.2.0"
80
- Versionaire::Version[major: 1, minor: 2, maintenance: 3] # "1.2.3"
81
+ Versionaire::Version[major: 1, minor: 2, patch: 3] # "1.2.3"
81
82
 
82
83
  ### Equality
83
84
 
@@ -130,7 +131,7 @@ The `Versionaire::Version` function is provided for explicit casting to a versio
130
131
 
131
132
  Versionaire::Version "1.0.0"
132
133
  Versionaire::Version [1, 0, 0]
133
- Versionaire::Version major: 1, minor: 0, maintenance: 0
134
+ Versionaire::Version major: 1, minor: 0, patch: 0
134
135
  Versionaire::Version version
135
136
 
136
137
  Each of these conversions will result in a version object that represents "1.0.0". When attempting
@@ -150,7 +151,7 @@ Explicit conversion to a `String`, `Array`, or `Hash` is supported:
150
151
 
151
152
  version.to_s # "0.0.0"
152
153
  version.to_a # [0, 0, 0]
153
- version.to_h # {major: 0, minor: 0, maintenance: 0}
154
+ version.to_h # {major: 0, minor: 0, patch: 0}
154
155
 
155
156
  ### Comparisons
156
157
 
@@ -174,14 +175,14 @@ Versions can be added and subtracted from each other.
174
175
 
175
176
  #### Addition
176
177
 
177
- version_1 = Versionaire::Version[major: 1, minor: 2, maintenance: 3]
178
- version_2 = Versionaire::Version[major: 2, minor: 5, maintenance: 7]
178
+ version_1 = Versionaire::Version[major: 1, minor: 2, patch: 3]
179
+ version_2 = Versionaire::Version[major: 2, minor: 5, patch: 7]
179
180
  version_1 + version_2 # "3.7.10"
180
181
 
181
182
  #### Subtraction
182
183
 
183
- version_1 = Versionaire::Version[major: 1, minor: 2, maintenance: 3]
184
- version_2 = Versionaire::Version[major: 1, minor: 1, maintenance: 1]
184
+ version_1 = Versionaire::Version[major: 1, minor: 2, patch: 3]
185
+ version_2 = Versionaire::Version[major: 1, minor: 1, patch: 1]
185
186
  version_1 - version_2 # "0.1.2"
186
187
 
187
188
  version_1 = Versionaire::Version[major: 1]
@@ -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
- converter = Converter.new object
11
-
12
- case object
13
- when String then converter.from_string
14
- when Array then converter.from_array
15
- when Hash then converter.from_hash
16
- when Version then object
17
- else converter.from_object
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 = %(Use: "<major>.<minor>.<maintenance>" or "v<major>.<minor>.<maintenance>".)
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: [], [<major>], [<major>, <minor>], or [<major>, <minor>, <maintenance>]."
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
- Version.arguments(*object.tr("v", "").split(".").map(&:to_i))
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(*object.dup.fill(0, object.size..2))
66
+ Version.arguments(*filler.call(object))
64
67
  end
65
68
 
66
69
  def required_keys?
67
- object.keys.all? { |key| VERSION_ATTRIBUTES.include? 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 maintenance must be a number."
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 maintenance must be a positive number."
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
@@ -12,7 +12,7 @@ module Versionaire
12
12
  end
13
13
 
14
14
  def self.version
15
- "7.3.4"
15
+ "8.0.0"
16
16
  end
17
17
 
18
18
  def self.version_label
@@ -1,44 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Versionaire
4
- VERSION_ATTRIBUTES = %i[major minor maintenance].freeze
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, :maintenance, keyword_init: true do
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 # Start of string.
15
- \d{1,} # Major version.
16
- #{VERSION_DELIMITER} # Delimiter.
17
- \d{1,} # Minor version.
18
- #{VERSION_DELIMITER} # Delimiter.
19
- \d{1,} # Maintenance version.
20
- \z # End of string.
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, maintenance
25
- Hash[VERSION_ATTRIBUTES.zip [major, minor, maintenance]]
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, maintenance: 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 = self.class
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 = self.class
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 VERSION_DELIMITER
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, maintenance]
59
+ [major, minor, patch]
62
60
  end
63
61
 
64
62
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionaire
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.4
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,36 +28,8 @@ cert_chain:
28
28
  dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
29
29
  y84=
30
30
  -----END CERTIFICATE-----
31
- date: 2019-11-01 00:00:00.000000000 Z
31
+ date: 2020-01-01 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
@@ -72,34 +44,6 @@ dependencies:
72
44
  - - "~>"
73
45
  - !ruby/object:Gem::Version
74
46
  version: '0.6'
75
- - !ruby/object:Gem::Dependency
76
- name: gemsmith
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '13.5'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '13.5'
89
- - !ruby/object:Gem::Dependency
90
- name: git-cop
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '3.5'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '3.5'
103
47
  - !ruby/object:Gem::Dependency
104
48
  name: guard-rspec
105
49
  requirement: !ruby/object:Gem::Requirement
@@ -114,48 +58,34 @@ dependencies:
114
58
  - - "~>"
115
59
  - !ruby/object:Gem::Version
116
60
  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
61
  - !ruby/object:Gem::Dependency
132
62
  name: pry
133
63
  requirement: !ruby/object:Gem::Requirement
134
64
  requirements:
135
65
  - - "~>"
136
66
  - !ruby/object:Gem::Version
137
- version: '0.10'
67
+ version: '0.12'
138
68
  type: :development
139
69
  prerelease: false
140
70
  version_requirements: !ruby/object:Gem::Requirement
141
71
  requirements:
142
72
  - - "~>"
143
73
  - !ruby/object:Gem::Version
144
- version: '0.10'
74
+ version: '0.12'
145
75
  - !ruby/object:Gem::Dependency
146
76
  name: pry-byebug
147
77
  requirement: !ruby/object:Gem::Requirement
148
78
  requirements:
149
79
  - - "~>"
150
80
  - !ruby/object:Gem::Version
151
- version: '3.5'
81
+ version: '3.7'
152
82
  type: :development
153
83
  prerelease: false
154
84
  version_requirements: !ruby/object:Gem::Requirement
155
85
  requirements:
156
86
  - - "~>"
157
87
  - !ruby/object:Gem::Version
158
- version: '3.5'
88
+ version: '3.7'
159
89
  - !ruby/object:Gem::Dependency
160
90
  name: rake
161
91
  requirement: !ruby/object:Gem::Requirement
@@ -204,84 +134,70 @@ dependencies:
204
134
  requirements:
205
135
  - - "~>"
206
136
  - !ruby/object:Gem::Version
207
- version: '0.76'
137
+ version: '0.78'
208
138
  type: :development
209
139
  prerelease: false
210
140
  version_requirements: !ruby/object:Gem::Requirement
211
141
  requirements:
212
142
  - - "~>"
213
143
  - !ruby/object:Gem::Version
214
- version: '0.76'
144
+ version: '0.78'
215
145
  - !ruby/object:Gem::Dependency
216
146
  name: rubocop-performance
217
147
  requirement: !ruby/object:Gem::Requirement
218
148
  requirements:
219
149
  - - "~>"
220
150
  - !ruby/object:Gem::Version
221
- version: '1.4'
151
+ version: '1.5'
222
152
  type: :development
223
153
  prerelease: false
224
154
  version_requirements: !ruby/object:Gem::Requirement
225
155
  requirements:
226
156
  - - "~>"
227
157
  - !ruby/object:Gem::Version
228
- version: '1.4'
158
+ version: '1.5'
229
159
  - !ruby/object:Gem::Dependency
230
160
  name: rubocop-rake
231
161
  requirement: !ruby/object:Gem::Requirement
232
162
  requirements:
233
163
  - - "~>"
234
164
  - !ruby/object:Gem::Version
235
- version: '0.3'
165
+ version: '0.5'
236
166
  type: :development
237
167
  prerelease: false
238
168
  version_requirements: !ruby/object:Gem::Requirement
239
169
  requirements:
240
170
  - - "~>"
241
171
  - !ruby/object:Gem::Version
242
- version: '0.3'
172
+ version: '0.5'
243
173
  - !ruby/object:Gem::Dependency
244
174
  name: rubocop-rspec
245
175
  requirement: !ruby/object:Gem::Requirement
246
176
  requirements:
247
177
  - - "~>"
248
178
  - !ruby/object:Gem::Version
249
- version: '1.33'
179
+ version: '1.37'
250
180
  type: :development
251
181
  prerelease: false
252
182
  version_requirements: !ruby/object:Gem::Requirement
253
183
  requirements:
254
184
  - - "~>"
255
185
  - !ruby/object:Gem::Version
256
- version: '1.33'
186
+ version: '1.37'
257
187
  - !ruby/object:Gem::Dependency
258
188
  name: simplecov
259
189
  requirement: !ruby/object:Gem::Requirement
260
190
  requirements:
261
191
  - - "~>"
262
192
  - !ruby/object:Gem::Version
263
- version: '0.13'
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'
193
+ version: '0.17'
278
194
  type: :development
279
195
  prerelease: false
280
196
  version_requirements: !ruby/object:Gem::Requirement
281
197
  requirements:
282
198
  - - "~>"
283
199
  - !ruby/object:Gem::Version
284
- version: '2.1'
200
+ version: '0.17'
285
201
  description:
286
202
  email:
287
203
  - brooke@alchemists.io
@@ -299,6 +215,7 @@ files:
299
215
  - lib/versionaire/errors/conversion.rb
300
216
  - lib/versionaire/errors/invalid_number.rb
301
217
  - lib/versionaire/errors/negative_number.rb
218
+ - lib/versionaire/filler.rb
302
219
  - lib/versionaire/identity.rb
303
220
  - lib/versionaire/version.rb
304
221
  homepage: https://github.com/bkuhlmann/versionaire
@@ -316,15 +233,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
316
233
  requirements:
317
234
  - - "~>"
318
235
  - !ruby/object:Gem::Version
319
- version: '2.6'
236
+ version: '2.7'
320
237
  required_rubygems_version: !ruby/object:Gem::Requirement
321
238
  requirements:
322
239
  - - ">="
323
240
  - !ruby/object:Gem::Version
324
241
  version: '0'
325
242
  requirements: []
326
- rubygems_version: 3.0.6
243
+ rubygems_version: 3.1.2
327
244
  signing_key:
328
245
  specification_version: 4
329
- summary: Provides immutable, thread-safe, semantic versioning.
246
+ summary: Provides an immutable, thread-safe, and semantic version type.
330
247
  test_files: []
metadata.gz.sig CHANGED
Binary file