version_gem 1.1.0 → 1.1.8

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.
data/SECURITY.md CHANGED
@@ -2,12 +2,20 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- | Version | Supported |
6
- |------------|-----------|
7
- | 1.<latest> | ✅ |
5
+ | Version | Supported |
6
+ |----------|-----------|
7
+ | 1.latest | ✅ |
8
8
 
9
- ## Reporting a Vulnerability
9
+ ## Security contact information
10
10
 
11
- Peter Boling is the primary maintainer of this gem. Please find a way
12
- to [contact him directly](https://railsbling.com/contact) to report the issue. Include as much relevant information as
13
- possible.
11
+ To report a security vulnerability, please use the
12
+ [Tidelift security contact](https://tidelift.com/security).
13
+ Tidelift will coordinate the fix and disclosure.
14
+
15
+ ## Additional Support
16
+
17
+ If you are interested in support for versions older than the latest release,
18
+ please consider sponsoring the project / maintainer @ https://liberapay.com/pboling/donate,
19
+ or find other sponsorship links in the [README].
20
+
21
+ [README]: README.md
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VersionGem
4
+ # Public API of this library
2
5
  module Api
3
6
  # The version number as a string
4
7
  #
@@ -11,39 +14,39 @@ module VersionGem
11
14
  #
12
15
  # @return [Integer]
13
16
  def major
14
- _to_a[0].to_i
17
+ @major ||= _to_a[0].to_i
15
18
  end
16
19
 
17
20
  # The minor version
18
21
  #
19
22
  # @return [Integer]
20
23
  def minor
21
- _to_a[1].to_i
24
+ @minor ||= _to_a[1].to_i
22
25
  end
23
26
 
24
27
  # The patch version
25
28
  #
26
29
  # @return [Integer]
27
30
  def patch
28
- _to_a[2].to_i
31
+ @patch ||= _to_a[2].to_i
29
32
  end
30
33
 
31
34
  # The pre-release version, if any
32
35
  #
33
36
  # @return [String, NilClass]
34
37
  def pre
35
- _to_a[3]
38
+ @pre ||= _to_a[3]
36
39
  end
37
40
 
38
41
  # The version number as a hash
39
42
  #
40
43
  # @return [Hash]
41
44
  def to_h
42
- {
45
+ @to_h ||= {
43
46
  major: major,
44
47
  minor: minor,
45
48
  patch: patch,
46
- pre: pre
49
+ pre: pre,
47
50
  }
48
51
  end
49
52
 
@@ -51,7 +54,7 @@ module VersionGem
51
54
  #
52
55
  # @return [Array<[Integer, String, NilClass]>]
53
56
  def to_a
54
- [major, minor, patch, pre]
57
+ @to_a ||= [major, minor, patch, pre]
55
58
  end
56
59
 
57
60
  private
@@ -60,7 +63,7 @@ module VersionGem
60
63
  #
61
64
  # @return [Array<String>]
62
65
  def _to_a
63
- self::VERSION.split('.')
66
+ @_to_a = self::VERSION.split(".")
64
67
  end
65
68
  end
66
69
  end
@@ -1,15 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'error'
4
- require_relative 'api'
3
+ require_relative "error"
4
+ require_relative "api"
5
5
 
6
6
  module VersionGem
7
7
  # This is a very *basic* version parser. Others could be built based on this pattern!
8
8
  module Basic
9
- def self.extended(base)
10
- raise Error, "VERSION must be defined before 'extend #{name}'" unless defined?(base::VERSION)
9
+ class << self
10
+ def extended(base)
11
+ raise Error, "VERSION must be defined before 'extend #{name}'" unless defined?(base::VERSION)
11
12
 
12
- base.extend Api
13
+ base.extend(Api)
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "error"
4
+ require_relative "api"
5
+
6
+ module VersionGem
7
+ # Support for Epoch Semantic Versioning
8
+ # See: https://antfu.me/posts/epoch-semver
9
+ module Epoch
10
+ EPOCH_SIZE = 1_000
11
+
12
+ class << self
13
+ def extended(base)
14
+ raise Error, "VERSION must be defined before 'extend #{name}'" unless defined?(base::VERSION)
15
+
16
+ base.extend(Api)
17
+ base.extend(OverloadApiForEpoch)
18
+ end
19
+ end
20
+
21
+ # Tweak the basic API so it will support Epoch Semantic Versioning
22
+ module OverloadApiForEpoch
23
+ # *** OVERLOAD METHODS FROM API ***
24
+ #
25
+ # The epoch version
26
+ #
27
+ # @return [Integer]
28
+ def epoch
29
+ @epoch ||= _major / EPOCH_SIZE
30
+ end
31
+
32
+ # The major version
33
+ #
34
+ # @return [Integer]
35
+ def major
36
+ @major ||= _major % EPOCH_SIZE
37
+ end
38
+
39
+ # The version number as a hash
40
+ #
41
+ # @return [Hash]
42
+ def to_h
43
+ @to_h ||= {
44
+ epoch: epoch,
45
+ major: major,
46
+ minor: minor,
47
+ patch: patch,
48
+ pre: pre,
49
+ }
50
+ end
51
+
52
+ # NOTE: This is not the same as _to_a, which returns an array of strings
53
+ #
54
+ # The version number as an array of cast values
55
+ # where epoch and major are derived from a single string:
56
+ # EPOCH * 1000 + MAJOR
57
+ #
58
+ # @return [Array<[Integer, String, NilClass]>]
59
+ def to_a
60
+ @to_a ||= [epoch, major, minor, patch, pre]
61
+ end
62
+
63
+ private
64
+
65
+ def _major
66
+ @_major ||= _to_a[0].to_i
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VersionGem
4
+ # Errors raised by VersionGem will be of this class
2
5
  class Error < RuntimeError; end
3
6
  end
@@ -1,54 +1,79 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec::Matchers.define :have_version_constant do
3
+ RSpec::Matchers.define(:have_version_constant) do
4
4
  match do |version_mod|
5
5
  version_mod.const_defined?(:VERSION, false)
6
6
  end
7
7
  end
8
8
 
9
- RSpec::Matchers.define :have_version_as_string do
9
+ RSpec::Matchers.define(:have_version_as_string) do
10
10
  match do |version_mod|
11
11
  !version_mod::VERSION.nil? && version_mod::VERSION.is_a?(String)
12
12
  end
13
13
  end
14
14
 
15
- RSpec::Matchers.define :have_major_as_integer do
15
+ RSpec::Matchers.define(:have_epoch_as_integer) do
16
+ match do |version_mod|
17
+ version_mod.epoch.is_a?(Integer)
18
+ end
19
+ end
20
+
21
+ RSpec::Matchers.define(:have_major_as_integer) do
16
22
  match do |version_mod|
17
23
  version_mod.major.is_a?(Integer)
18
24
  end
19
25
  end
20
26
 
21
- RSpec::Matchers.define :have_minor_as_integer do
27
+ RSpec::Matchers.define(:have_minor_as_integer) do
22
28
  match do |version_mod|
23
29
  version_mod.minor.is_a?(Integer)
24
30
  end
25
31
  end
26
32
 
27
- RSpec::Matchers.define :have_patch_as_integer do
33
+ RSpec::Matchers.define(:have_patch_as_integer) do
28
34
  match do |version_mod|
29
35
  version_mod.patch.is_a?(Integer)
30
36
  end
31
37
  end
32
38
 
33
- RSpec::Matchers.define :have_pre_as_nil_or_string do
39
+ RSpec::Matchers.define(:have_pre_as_nil_or_string) do
34
40
  match do |version_mod|
35
41
  version_mod.pre.nil? || version_mod.pre.is_a?(String)
36
42
  end
37
43
  end
38
44
 
39
- RSpec.shared_examples_for 'a Version module' do |version_mod|
40
- it 'is introspectable' do
41
- aggregate_failures 'introspectable api' do
45
+ RSpec.shared_examples_for("a Version module") do |version_mod|
46
+ it "is introspectable" do
47
+ aggregate_failures "introspectable api" do
48
+ expect(version_mod).is_a?(Module)
49
+ expect(version_mod).to(have_version_constant)
50
+ expect(version_mod).to(have_version_as_string)
51
+ expect(version_mod.to_s).to(be_a(String))
52
+ expect(version_mod).to(have_major_as_integer)
53
+ expect(version_mod).to(have_minor_as_integer)
54
+ expect(version_mod).to(have_patch_as_integer)
55
+ expect(version_mod).to(have_pre_as_nil_or_string)
56
+ expect(version_mod.to_h.keys).to(match_array(%i[major minor patch pre]))
57
+ expect(version_mod.to_a).to(be_a(Array))
58
+ end
59
+ end
60
+ end
61
+
62
+ # This one is more Epoch ;)
63
+ RSpec.shared_examples_for("an Epoch Version module") do |version_mod|
64
+ it "is introspectable" do
65
+ aggregate_failures "introspectable api" do
42
66
  expect(version_mod).is_a?(Module)
43
- expect(version_mod).to have_version_constant
44
- expect(version_mod).to have_version_as_string
45
- expect(version_mod.to_s).to be_a(String)
46
- expect(version_mod).to have_major_as_integer
47
- expect(version_mod).to have_minor_as_integer
48
- expect(version_mod).to have_patch_as_integer
49
- expect(version_mod).to have_pre_as_nil_or_string
50
- expect(version_mod.to_h.keys).to match_array(%i[major minor patch pre])
51
- expect(version_mod.to_a).to be_a(Array)
67
+ expect(version_mod).to(have_version_constant)
68
+ expect(version_mod).to(have_version_as_string)
69
+ expect(version_mod.to_s).to(be_a(String))
70
+ expect(version_mod).to(have_epoch_as_integer)
71
+ expect(version_mod).to(have_major_as_integer)
72
+ expect(version_mod).to(have_minor_as_integer)
73
+ expect(version_mod).to(have_patch_as_integer)
74
+ expect(version_mod).to(have_pre_as_nil_or_string)
75
+ expect(version_mod.to_h.keys).to(match_array(%i[epoch major minor patch pre]))
76
+ expect(version_mod.to_a).to(be_a(Array))
52
77
  end
53
78
  end
54
79
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VersionGem
4
+ # Helpers for library CI integration against many different versions of Ruby
5
+ module Ruby
6
+ RUBY_VER = ::Gem::Version.new(RUBY_VERSION)
7
+
8
+ # Check if the current Ruby version is greater than or equal to the given version
9
+ def gte_minimum_version?(version, engine = "ruby")
10
+ RUBY_VER >= ::Gem::Version.new(version) && ::RUBY_ENGINE == engine
11
+ end
12
+ module_function :gte_minimum_version?
13
+
14
+ # Check if the current Ruby version (MAJOR.MINOR) is equal to the given version
15
+ def actual_minor_version?(major, minor, engine = "ruby")
16
+ segs = RUBY_VER.segments
17
+ major.to_i == segs[0] &&
18
+ minor.to_i == segs[1] &&
19
+ ::RUBY_ENGINE == engine
20
+ end
21
+ module_function :actual_minor_version?
22
+ end
23
+ end
@@ -2,11 +2,13 @@
2
2
 
3
3
  module VersionGem
4
4
  module Version
5
- VERSION = '1.1.0'.freeze
5
+ VERSION = "1.1.8"
6
6
  # This would work in this gem, but not in external libraries,
7
7
  # because version files are loaded in Gemspecs before bundler
8
8
  # has a chance to load dependencies.
9
9
  # Instead, see lib/version_gem.rb for a solution that will work everywhere
10
10
  # extend VersionGem::Basic
11
+ # or
12
+ # extend VersionGem::Epoch
11
13
  end
12
14
  end
data/lib/version_gem.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'version_gem/version'
4
- require_relative 'version_gem/basic'
3
+ require_relative "version_gem/version"
4
+ require_relative "version_gem/basic"
5
+ require_relative "version_gem/epoch"
5
6
 
7
+ # Namespace of this library
6
8
  module VersionGem
7
9
  end
8
10
 
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: version_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
8
- autorequire:
9
- bindir: exe
10
- cert_chain: []
11
- date: 2022-06-24 00:00:00.000000000 Z
8
+ bindir: bin
9
+ cert_chain:
10
+ - |
11
+ -----BEGIN CERTIFICATE-----
12
+ MIIEgDCCAuigAwIBAgIBATANBgkqhkiG9w0BAQsFADBDMRUwEwYDVQQDDAxwZXRl
13
+ ci5ib2xpbmcxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
14
+ A2NvbTAeFw0yNTA1MDQxNTMzMDlaFw00NTA0MjkxNTMzMDlaMEMxFTATBgNVBAMM
15
+ DHBldGVyLmJvbGluZzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
16
+ LGQBGRYDY29tMIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAruUoo0WA
17
+ uoNuq6puKWYeRYiZekz/nsDeK5x/0IEirzcCEvaHr3Bmz7rjo1I6On3gGKmiZs61
18
+ LRmQ3oxy77ydmkGTXBjruJB+pQEn7UfLSgQ0xa1/X3kdBZt6RmabFlBxnHkoaGY5
19
+ mZuZ5+Z7walmv6sFD9ajhzj+oIgwWfnEHkXYTR8I6VLN7MRRKGMPoZ/yvOmxb2DN
20
+ coEEHWKO9CvgYpW7asIihl/9GMpKiRkcYPm9dGQzZc6uTw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rZt
36
+ L9nRqA==
37
+ -----END CERTIFICATE-----
38
+ date: 2025-05-06 00:00:00.000000000 Z
12
39
  dependencies:
13
40
  - !ruby/object:Gem::Dependency
14
41
  name: rspec
15
42
  requirement: !ruby/object:Gem::Requirement
16
43
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: pry
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
44
+ - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '0'
46
+ version: '3.13'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - ">="
51
+ - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '0'
53
+ version: '3.13'
55
54
  - !ruby/object:Gem::Dependency
56
- name: rubocop-lts
55
+ name: rspec-block_is_expected
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: '8.0'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 8.0.2
60
+ version: '1.0'
65
61
  type: :development
66
62
  prerelease: false
67
63
  version_requirements: !ruby/object:Gem::Requirement
68
64
  requirements:
69
65
  - - "~>"
70
66
  - !ruby/object:Gem::Version
71
- version: '8.0'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 8.0.2
67
+ version: '1.0'
75
68
  - !ruby/object:Gem::Dependency
76
- name: rubocop-rspec
69
+ name: rake
77
70
  requirement: !ruby/object:Gem::Requirement
78
71
  requirements:
79
- - - ">="
72
+ - - "~>"
80
73
  - !ruby/object:Gem::Version
81
- version: '0'
74
+ version: '13.0'
82
75
  type: :development
83
76
  prerelease: false
84
77
  version_requirements: !ruby/object:Gem::Requirement
85
78
  requirements:
86
- - - ">="
79
+ - - "~>"
87
80
  - !ruby/object:Gem::Version
88
- version: '0'
81
+ version: '13.0'
89
82
  - !ruby/object:Gem::Dependency
90
- name: rubocop-performance
83
+ name: stone_checksums
91
84
  requirement: !ruby/object:Gem::Requirement
92
85
  requirements:
93
- - - ">="
86
+ - - "~>"
94
87
  - !ruby/object:Gem::Version
95
- version: '0'
88
+ version: '1.0'
96
89
  type: :development
97
90
  prerelease: false
98
91
  version_requirements: !ruby/object:Gem::Requirement
99
92
  requirements:
100
- - - ">="
93
+ - - "~>"
101
94
  - !ruby/object:Gem::Version
102
- version: '0'
95
+ version: '1.0'
103
96
  description: Versions are good. Versions are cool. Versions will win.
104
97
  email:
105
98
  - peter.boling@gmail.com
99
+ - oauth-ruby@googlegroups.com
106
100
  executables: []
107
101
  extensions: []
108
- extra_rdoc_files: []
102
+ extra_rdoc_files:
103
+ - CHANGELOG.md
104
+ - CODE_OF_CONDUCT.md
105
+ - CONTRIBUTING.md
106
+ - LICENSE.txt
107
+ - README.md
108
+ - SECURITY.md
109
109
  files:
110
110
  - CHANGELOG.md
111
111
  - CODE_OF_CONDUCT.md
@@ -116,23 +116,32 @@ files:
116
116
  - lib/version_gem.rb
117
117
  - lib/version_gem/api.rb
118
118
  - lib/version_gem/basic.rb
119
+ - lib/version_gem/epoch.rb
119
120
  - lib/version_gem/error.rb
120
121
  - lib/version_gem/rspec.rb
122
+ - lib/version_gem/ruby.rb
121
123
  - lib/version_gem/version.rb
122
- - sig/version_gem.rbs
123
- homepage: https://github.com/pboling/version_gem
124
+ homepage: https://gitlab.com/oauth-xx/version_gem
124
125
  licenses:
125
126
  - MIT
126
127
  metadata:
127
- homepage_uri: https://github.com/pboling/version_gem
128
- source_code_uri: https://github.com/pboling/version_gem/tree/v1.1.0
129
- changelog_uri: https://github.com/pboling/version_gem/blob/v1.1.0/CHANGELOG.md
130
- bug_tracker_uri: https://github.com/pboling/version_gem/issues
131
- documentation_uri: https://www.rubydoc.info/gems/version_gem/1.1.0
132
- wiki_uri: https://github.com/pboling/version_gem/wiki
128
+ homepage_uri: https://railsbling.com/tags/version_gem/
129
+ source_code_uri: https://gitlab.com/oauth-xx/version_gem/-/tree/v1.1.8
130
+ changelog_uri: https://gitlab.com/oauth-xx/version_gem/-/blob/v1.1.8/CHANGELOG.md
131
+ bug_tracker_uri: https://gitlab.com/oauth-xx/version_gem/-/issues
132
+ documentation_uri: https://www.rubydoc.info/gems/version_gem/1.1.8
133
+ wiki_uri: https://gitlab.com/oauth-xx/version_gem/-/wiki
134
+ mailing_list_uri: https://groups.google.com/g/oauth-ruby
135
+ funding_uri: https://liberapay.com/pboling
133
136
  rubygems_mfa_required: 'true'
134
- post_install_message:
135
- rdoc_options: []
137
+ rdoc_options:
138
+ - "--title"
139
+ - version_gem - Enhance your VERSION! Sugar for Version modules.
140
+ - "--main"
141
+ - README.md
142
+ - "--line-numbers"
143
+ - "--inline-source"
144
+ - "--quiet"
136
145
  require_paths:
137
146
  - lib
138
147
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -146,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
155
  - !ruby/object:Gem::Version
147
156
  version: '0'
148
157
  requirements: []
149
- rubygems_version: 3.3.16
150
- signing_key:
158
+ rubygems_version: 3.6.8
151
159
  specification_version: 4
152
160
  summary: Enhance your VERSION! Sugar for Version modules.
153
161
  test_files: []
metadata.gz.sig ADDED
Binary file
data/sig/version_gem.rbs DELETED
@@ -1,4 +0,0 @@
1
- module VersionGem
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end