versionaire 10.6.0 → 11.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: 1bc09e4b09c2aecde2a951b64683e643d51e4d726a24a54161795dd822bb9b79
4
- data.tar.gz: 55dcce05ba6ff5224bfc68e6a59b7c3f28b765f345f27dac086c6da7274b0715
3
+ metadata.gz: eb98e3cae752ba465daee34c368625932376bb16090c9ad35daaba8af285c361
4
+ data.tar.gz: '059670fecbd63ffeb7a16eadbac9ab1eba865611017b65c7c790a4fafbf189ea'
5
5
  SHA512:
6
- metadata.gz: 7d09df087ae1c8b0730e20b82a57ad0c56b8b9272903ba7cfbab2650411020f6a7d944b2946cfd4e62cc456decb06f5fa80153297dc97b48dc455d9d6d549a29
7
- data.tar.gz: 32a6f3b7632a2971e6032385e78e2b03eeb18c9eb5aefd15b3bceaf4d9066d03db43708aa06cb39e4365118b873904e558b92b745aa652c06eaeee32d84e8b1d
6
+ metadata.gz: 23f4803ab79920bfc77025d530f25184942ce2cd677374565d25daed0628516c920e7df50e4c5aa6258fd2168597623e53600cc68d7a7ce067ff1137d55b6a15
7
+ data.tar.gz: e5a5f455bff106e41487a359eae6084be25480f016a1d4df6e925d002eb6938f90556787bb91f5582c618fa48aeb5024f39b315491ed5cce9520886a964f3e0d
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -8,8 +8,6 @@
8
8
 
9
9
  Ruby doesn't provide a primitive version type by default so Versionaire fills this gap by providing immutable and thread-safe {semver_link} so you can leverage versions within your applications. This new `Version` type behaves and feels a lot like other primitives (i.e. `String`, `Array`, `Hash`, etc) and can even be cast/converted from other primitives.
10
10
 
11
-
12
-
13
11
  toc::[]
14
12
 
15
13
  == Features
@@ -8,7 +8,6 @@ module Versionaire
8
8
  module_function
9
9
 
10
10
  # Conversion function (strict) for casting an object into a version.
11
- # :reek:TooManyStatements
12
11
  def Version object
13
12
  Converter.new(object).then do |converter|
14
13
  case object
@@ -26,13 +25,14 @@ module Versionaire
26
25
  using Refinements::Arrays
27
26
  using Refinements::Structs
28
27
 
29
- def initialize object
28
+ def initialize object, model: Version
30
29
  @object = object
30
+ @model = model
31
31
  end
32
32
 
33
33
  def from_string
34
34
  body = "Use: <major>.<minor>.<patch>, <major>.<minor>, <major>, or empty string."
35
- fail Error, error_message(object, body) unless Version.pattern.match? object
35
+ fail Error, error_message(object, body) unless PATTERN.match? object
36
36
 
37
37
  string_to_version
38
38
  end
@@ -41,7 +41,7 @@ module Versionaire
41
41
  body = "Use: [<major>, <minor>, <patch>], [<major>, <minor>], [<major>], or []."
42
42
  fail Error, error_message(object, body) unless (0..3).cover? object.size
43
43
 
44
- Version.with_positions(*object.pad(0, max: 3))
44
+ model.with_positions(*object.pad(0, max: 3))
45
45
  end
46
46
 
47
47
  def from_hash
@@ -58,16 +58,16 @@ module Versionaire
58
58
 
59
59
  private
60
60
 
61
- attr_reader :object, :filler
61
+ attr_reader :object, :model
62
62
 
63
63
  def string_to_version
64
- object.split(Version.delimiter)
64
+ object.split(DELIMITER)
65
65
  .map(&:to_i)
66
66
  .then { |numbers| numbers.pad 0, max: 3 }
67
- .then { |arguments| Version.with_positions(*arguments) }
67
+ .then { |arguments| model.with_positions(*arguments) }
68
68
  end
69
69
 
70
- def required_keys? = object.keys.all? { |key| Version.members.include? key }
70
+ def required_keys? = object.keys.all? { |key| model.members.include? key }
71
71
 
72
72
  def error_message(object, body) = "Invalid version conversion: #{object}. #{body}"
73
73
  end
@@ -9,21 +9,6 @@ module Versionaire
9
9
 
10
10
  using Refinements::Structs
11
11
 
12
- def self.delimiter = "."
13
-
14
- def self.pattern
15
- /
16
- \A( # Start of string and OR.
17
- \d* # Major only.
18
- | # OR pipe.
19
- \d+ # Major.
20
- #{delimiter}? # Delimiter.
21
- \d* # Minor.
22
- (?:#{delimiter}\d+) # Passive delimiter and patch.
23
- )\z # End of OR and string.
24
- /x
25
- end
26
-
27
12
  def initialize major: 0, minor: 0, patch: 0
28
13
  super
29
14
  validate
@@ -52,7 +37,7 @@ module Versionaire
52
37
 
53
38
  def to_proc = method(:[]).to_proc
54
39
 
55
- def to_s = to_a.join(self.class.delimiter)
40
+ def to_s = to_a.join DELIMITER
56
41
 
57
42
  alias_method :to_str, :to_s
58
43
 
data/lib/versionaire.rb CHANGED
@@ -1,6 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "versionaire/cast"
3
4
  require "versionaire/error"
4
- require "versionaire/version"
5
5
  require "versionaire/function"
6
- require "versionaire/cast"
6
+ require "versionaire/version"
7
+
8
+ module Versionaire
9
+ DELIMITER = "."
10
+
11
+ PATTERN = /
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.
20
+ /x
21
+ 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 = "10.6.0"
5
+ spec.version = "11.0.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://www.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.1"
26
- spec.add_dependency "refinements", "~> 9.7"
25
+ spec.required_ruby_version = "~> 3.2"
26
+ spec.add_dependency "refinements", "~> 10.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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionaire
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.6.0
4
+ version: 11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  CxDe2+VuChj4I1nvIHdu+E6XoEVlanUPKmSg6nddhkKn2gC45Kyzh6FZqnzH/CRp
29
29
  RFE=
30
30
  -----END CERTIFICATE-----
31
- date: 2022-10-22 00:00:00.000000000 Z
31
+ date: 2022-12-25 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: refinements
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '9.7'
39
+ version: '10.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '9.7'
46
+ version: '10.0'
47
47
  description:
48
48
  email:
49
49
  - brooke@alchemists.io
@@ -81,14 +81,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '3.1'
84
+ version: '3.2'
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.3.24
91
+ rubygems_version: 3.4.1
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Provides an immutable, thread-safe, and semantic version type.
metadata.gz.sig CHANGED
Binary file