versionaire 13.10.0 → 14.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: 310b9fd7d0ef45f5fb9726503c7da4fe4174986bad951bcf38b1eb24abe4cb40
4
- data.tar.gz: 5ae0688460dc427533c9f1a6f79d72f00bf1411ab921cdae08f125e15e32f477
3
+ metadata.gz: 26297e56d0e6697b49126a2910802d914a28d5819df1ed503f662638e1f031c4
4
+ data.tar.gz: 0d4e9dbea066b75eadb1978d223fe54873ac998de4263358d977ddbc66aadc27
5
5
  SHA512:
6
- metadata.gz: f874ba10a6eccfd4aaee2e8ca1ad246ae596771dca1f40c366aff4d477ee065d0d288aafacf634037459718f0fe9d3f5924bfd21db0aca593f300fd937ac2705
7
- data.tar.gz: 8bd4dbdc3f1741d5583bf21150e67b01e0fcd7bc8bcc63edbae41454d5444cf289479dc7b3efd11e6cb8e1510efbeeed18aeeb80aaf53c0c1177e8bc1f9826f0
6
+ metadata.gz: 757d67ede0af422509430ac32fb75fdd175abbeb5b7739c6db027f8f3282c794b53ef2d69fe229a73009c5f0ad37a811bed1c9b308021e49c36fecd54bf29f38
7
+ data.tar.gz: dc2cd631f79a89c2e276b62723d86f9bdb38a372121c267cc00bcf3b9890faf74e5c28f92f20850d80b58cd182df272d29517f73c109f989ae0183b89da7058d
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -231,19 +231,14 @@ Versions can be bumped to next logical version with respect current version. Exa
231
231
 
232
232
  [source,ruby]
233
233
  ----
234
- version = Versionaire::Version.new # #<struct Versionaire::Version major=0, minor=0, patch=0>
235
- version.bump :major # #<struct Versionaire::Version major=1, minor=0, patch=0>
236
- version.bump :minor # #<struct Versionaire::Version major=0, minor=1, patch=0>
237
- version.bump :patch # #<struct Versionaire::Version major=0, minor=0, patch=1>
234
+ version = Versionaire::Version.new # "0.0.0"
235
+ version.bump :patch # "0.0.1"
236
+ version.bump :minor # "0.1.0"
237
+ version.bump :major # "1.0.0"
238
238
 
239
- Versionaire::Version[major: 1, minor: 2, patch: 3].bump :major
240
- #<struct Versionaire::Version major=2, minor=0, patch=0>
241
-
242
- Versionaire::Version[major: 1, minor: 2, patch: 3].bump :minor
243
- #<struct Versionaire::Version major=1, minor=3, patch=0>
244
-
245
- Versionaire::Version[major: 1, minor: 2, patch: 3].bump :patch
246
- #<struct Versionaire::Version major=1, minor=2, patch=4>
239
+ Versionaire::Version[major: 1, minor: 2, patch: 3].bump :major # "2.0.0"
240
+ Versionaire::Version[major: 1, minor: 2, patch: 3].bump :minor # "1.3.0"
241
+ Versionaire::Version[major: 1, minor: 2, patch: 3].bump :patch # "1.2.4"
247
242
  ----
248
243
 
249
244
  You'll notice, when bumping the major or minor versions, lower precision gets zeroed out in order to provide the next logical version.
@@ -342,8 +337,7 @@ parser.parse %w[--tag 1.2.3]
342
337
  puts options
343
338
  ----
344
339
 
345
- The above will ensure `--tag 1.2.3` is parsed as `{version: #<struct Versionaire::Version major = 1,
346
- minor = 2, patch = 3>}` within your `options` variable. Should `OptionParser` parse an invalid version, you'll get a `OptionParser::InvalidArgument` instead.
340
+ The above will ensure `--tag 1.2.3` is parsed as `{version: "1.2.3"}` within your `options` variable. Should `OptionParser` parse an invalid version, you'll get a `OptionParser::InvalidArgument` instead.
347
341
 
348
342
  == Development
349
343
 
@@ -1,29 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "refinements/array"
4
- require "refinements/struct"
5
4
 
6
5
  module Versionaire
7
6
  # An immutable, semantic version value object.
8
- Version = Struct.new :major, :minor, :patch do
7
+ Version = Data.define :major, :minor, :patch do
9
8
  include Comparable
10
9
 
11
10
  using Refinements::Array
12
- using Refinements::Struct
13
11
 
14
12
  def initialize major: 0, minor: 0, patch: 0
15
13
  super
16
14
  validate
17
- freeze
18
15
  end
19
16
 
20
- def []= key, value
21
- super.tap { validate }
22
- end
23
-
24
- def +(other) = (revalue(other.to_h) { |previous, current| previous + current }).freeze
17
+ def +(other) = add other
25
18
 
26
- def -(other) = (revalue(other.to_h) { |previous, current| previous - current }).freeze
19
+ def -(other) = substract other
27
20
 
28
21
  def ==(other) = hash == other.hash
29
22
 
@@ -31,13 +24,9 @@ module Versionaire
31
24
 
32
25
  def <=>(other) = to_s <=> other.to_s
33
26
 
34
- def down key, value = 1
35
- (revalue(key => value) { |previous, current| previous - current }).freeze
36
- end
27
+ def down(key, value = 1) = substract({key => value})
37
28
 
38
- def up key, value = 1
39
- (revalue(key => value) { |previous, current| previous + current }).freeze
40
- end
29
+ def up(key, value = 1) = add({key => value})
41
30
 
42
31
  def bump key
43
32
  case key
@@ -50,26 +39,37 @@ module Versionaire
50
39
 
51
40
  def inspect = to_s.inspect
52
41
 
53
- def to_proc = method(:[]).to_proc
42
+ def to_proc = method(:public_send).to_proc
54
43
 
55
44
  def to_s = to_a.join DELIMITER
56
45
 
57
46
  alias_method :to_str, :to_s
58
47
 
48
+ alias_method :to_a, :deconstruct
49
+
59
50
  private
60
51
 
61
52
  def validate
62
- fail Error, "Major, minor, and patch must be a number." if to_a.any? do |number|
63
- !number.is_a? Integer
64
- end
65
-
53
+ fail Error, "Major, minor, and patch must be a number." unless to_a.all? Integer
66
54
  fail Error, "Major, minor, and patch must be a positive number." if to_a.any?(&:negative?)
67
55
  end
68
56
 
69
- def bump_major = merge(major: major + 1, minor: 0, patch: 0).freeze
57
+ def add other
58
+ attributes = other.to_h
59
+ attributes.each { |key, value| attributes[key] = public_send(key) + value }
60
+ with(**attributes)
61
+ end
62
+
63
+ def substract other
64
+ attributes = other.to_h
65
+ attributes.each { |key, value| attributes[key] = public_send(key) - value }
66
+ with(**attributes)
67
+ end
68
+
69
+ def bump_major = with major: major + 1, minor: 0, patch: 0
70
70
 
71
- def bump_minor = merge(major:, minor: minor + 1, patch: 0).freeze
71
+ def bump_minor = with major:, minor: minor + 1, patch: 0
72
72
 
73
- def bump_patch = merge(major:, minor:, patch: patch + 1).freeze
73
+ def bump_patch = with major:, minor:, patch: patch + 1
74
74
  end
75
75
  end
data/versionaire.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "versionaire"
5
- spec.version = "13.10.0"
5
+ spec.version = "14.0.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/versionaire"
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.signing_key = Gem.default_key_path
23
23
  spec.cert_chain = [Gem.default_cert_path]
24
24
 
25
- spec.required_ruby_version = ">= 3.3", "<= 3.4"
26
- spec.add_dependency "refinements", "~> 12.10"
25
+ spec.required_ruby_version = "~> 3.4"
26
+ spec.add_dependency "refinements", "~> 13.0"
27
27
 
28
28
  spec.files = Dir["*.gemspec", "lib/**/*"]
29
29
  spec.extra_rdoc_files = Dir["README*", "LICENSE*"]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionaire
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.10.0
4
+ version: 14.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
@@ -35,7 +34,7 @@ cert_chain:
35
34
  3n5C8/6Zh9DYTkpcwPSuIfAga6wf4nXc9m6JAw8AuMLaiWN/r/2s4zJsUHYERJEu
36
35
  gZGm4JqtuSg8pYjPeIJxS960owq+SfuC+jxqmRA54BisFCv/0VOJi7tiJVY=
37
36
  -----END CERTIFICATE-----
38
- date: 2024-11-09 00:00:00.000000000 Z
37
+ date: 2024-12-27 00:00:00.000000000 Z
39
38
  dependencies:
40
39
  - !ruby/object:Gem::Dependency
41
40
  name: refinements
@@ -43,15 +42,14 @@ dependencies:
43
42
  requirements:
44
43
  - - "~>"
45
44
  - !ruby/object:Gem::Version
46
- version: '12.10'
45
+ version: '13.0'
47
46
  type: :runtime
48
47
  prerelease: false
49
48
  version_requirements: !ruby/object:Gem::Requirement
50
49
  requirements:
51
50
  - - "~>"
52
51
  - !ruby/object:Gem::Version
53
- version: '12.10'
54
- description:
52
+ version: '13.0'
55
53
  email:
56
54
  - brooke@alchemists.io
57
55
  executables: []
@@ -80,16 +78,12 @@ metadata:
80
78
  label: Versionaire
81
79
  rubygems_mfa_required: 'true'
82
80
  source_code_uri: https://github.com/bkuhlmann/versionaire
83
- post_install_message:
84
81
  rdoc_options: []
85
82
  require_paths:
86
83
  - lib
87
84
  required_ruby_version: !ruby/object:Gem::Requirement
88
85
  requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: '3.3'
92
- - - "<="
86
+ - - "~>"
93
87
  - !ruby/object:Gem::Version
94
88
  version: '3.4'
95
89
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -98,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
92
  - !ruby/object:Gem::Version
99
93
  version: '0'
100
94
  requirements: []
101
- rubygems_version: 3.5.23
102
- signing_key:
95
+ rubygems_version: 3.6.2
103
96
  specification_version: 4
104
97
  summary: An immutable, thread-safe, and strict semantic version type.
105
98
  test_files: []
metadata.gz.sig CHANGED
Binary file