version_gem 1.1.3 → 1.1.9
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/CHANGELOG.md +143 -26
- data/CITATION.cff +20 -0
- data/CODE_OF_CONDUCT.md +79 -29
- data/CONTRIBUTING.md +189 -29
- data/FUNDING.md +77 -0
- data/LICENSE.txt +1 -1
- data/README.md +613 -202
- data/REEK +0 -0
- data/RUBOCOP.md +71 -0
- data/SECURITY.md +12 -4
- data/lib/version_gem/api.rb +2 -0
- data/lib/version_gem/basic.rb +0 -0
- data/lib/version_gem/epoch.rb +70 -0
- data/lib/version_gem/error.rb +3 -0
- data/lib/version_gem/rspec.rb +25 -0
- data/lib/version_gem/ruby.rb +7 -2
- data/lib/version_gem/version.rb +3 -1
- data/lib/version_gem.rb +1 -0
- data/sig/all_formatters.rbs +1 -0
- data/sig/debug.rbs +1 -0
- data/sig/debug_ide.rbs +1 -0
- data/sig/debug_jruby.rbs +1 -0
- data/sig/debugging.rbs +1 -0
- data/sig/run_coverage.rbs +1 -0
- data/sig/version_gem/api.rbs +27 -0
- data/sig/version_gem/basic.rbs +5 -0
- data/sig/version_gem/epoch.rbs +26 -0
- data/sig/version_gem/error.rbs +4 -0
- data/sig/version_gem/ruby.rbs +11 -0
- data/sig/version_gem/version.rbs +9 -0
- data/sig/version_gem.rbs +2 -0
- data.tar.gz.sig +0 -0
- metadata +199 -49
- metadata.gz.sig +0 -0
data/REEK
ADDED
File without changes
|
data/RUBOCOP.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# RuboCop Usage Guide
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
|
5
|
+
A tale of two RuboCop plugin gems.
|
6
|
+
|
7
|
+
### RuboCop Gradual
|
8
|
+
|
9
|
+
This project uses `rubocop_gradual` instead of vanilla RuboCop for code style checking. The `rubocop_gradual` tool allows for gradual adoption of RuboCop rules by tracking violations in a lock file.
|
10
|
+
|
11
|
+
### RuboCop LTS
|
12
|
+
|
13
|
+
This project uses `rubocop-lts` to ensure, on a best-effort basis, compatibility with Ruby >= 1.9.2.
|
14
|
+
RuboCop rules are meticulously configured by the `rubocop-lts` family of gems to ensure that a project is compatible with a specific version of Ruby. See: https://rubocop-lts.gitlab.io for more.
|
15
|
+
|
16
|
+
## Checking RuboCop Violations
|
17
|
+
|
18
|
+
To check for RuboCop violations in this project, always use:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
bundle exec rake rubocop_gradual:check
|
22
|
+
```
|
23
|
+
|
24
|
+
**Do not use** the standard RuboCop commands like:
|
25
|
+
- `bundle exec rubocop`
|
26
|
+
- `rubocop`
|
27
|
+
|
28
|
+
## Understanding the Lock File
|
29
|
+
|
30
|
+
The `.rubocop_gradual.lock` file tracks all current RuboCop violations in the project. This allows the team to:
|
31
|
+
|
32
|
+
1. Prevent new violations while gradually fixing existing ones
|
33
|
+
2. Track progress on code style improvements
|
34
|
+
3. Ensure CI builds don't fail due to pre-existing violations
|
35
|
+
|
36
|
+
## Common Commands
|
37
|
+
|
38
|
+
- **Check violations**
|
39
|
+
- `bundle exec rake rubocop_gradual`
|
40
|
+
- `bundle exec rake rubocop_gradual:check`
|
41
|
+
- **(Safe) Autocorrect violations, and update lockfile if no new violations**
|
42
|
+
- `bundle exec rake rubocop_gradual:autocorrect`
|
43
|
+
- **Force update the lock file (w/o autocorrect) to match violations present in code**
|
44
|
+
- `bundle exec rake rubocop_gradual:force_update`
|
45
|
+
|
46
|
+
## Workflow
|
47
|
+
|
48
|
+
1. Before submitting a PR, run `bundle exec rake rubocop_gradual:autocorrect`
|
49
|
+
a. or just the default `bundle exec rake`, as autocorrection is a pre-requisite of the default task.
|
50
|
+
2. If there are new violations, either:
|
51
|
+
- Fix them in your code
|
52
|
+
- Run `bundle exec rake rubocop_gradual:force_update` to update the lock file (only for violations you can't fix immediately)
|
53
|
+
3. Commit the updated `.rubocop_gradual.lock` file along with your changes
|
54
|
+
|
55
|
+
## Never add inline RuboCop disables
|
56
|
+
|
57
|
+
Do not add inline `rubocop:disable` / `rubocop:enable` comments anywhere in the codebase (including specs, except when following the few existing `rubocop:disable` patterns for a rule already being disabled elsewhere in the code). We handle exceptions in two supported ways:
|
58
|
+
|
59
|
+
- Permanent/structural exceptions: prefer adjusting the RuboCop configuration (e.g., in `.rubocop.yml`) to exclude a rule for a path or file pattern when it makes sense project-wide.
|
60
|
+
- Temporary exceptions while improving code: record the current violations in `.rubocop_gradual.lock` via the gradual workflow:
|
61
|
+
- `bundle exec rake rubocop_gradual:autocorrect` (preferred; will autocorrect what it can and update the lock only if no new violations were introduced)
|
62
|
+
- If needed, `bundle exec rake rubocop_gradual:force_update` (as a last resort when you cannot fix the newly reported violations immediately)
|
63
|
+
|
64
|
+
In general, treat the rules as guidance to follow; fix violations rather than ignore them. For example, RSpec conventions in this project expect `described_class` to be used in specs that target a specific class under test.
|
65
|
+
|
66
|
+
## Benefits of rubocop_gradual
|
67
|
+
|
68
|
+
- Allows incremental adoption of code style rules
|
69
|
+
- Prevents CI failures due to pre-existing violations
|
70
|
+
- Provides a clear record of code style debt
|
71
|
+
- Enables focused efforts on improving code quality over time
|
data/SECURITY.md
CHANGED
@@ -6,8 +6,16 @@
|
|
6
6
|
|----------|-----------|
|
7
7
|
| 1.latest | ✅ |
|
8
8
|
|
9
|
-
##
|
9
|
+
## Security contact information
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
data/lib/version_gem/api.rb
CHANGED
data/lib/version_gem/basic.rb
CHANGED
File without changes
|
@@ -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
|
data/lib/version_gem/error.rb
CHANGED
data/lib/version_gem/rspec.rb
CHANGED
@@ -12,6 +12,12 @@ RSpec::Matchers.define(:have_version_as_string) do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
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
|
+
|
15
21
|
RSpec::Matchers.define(:have_major_as_integer) do
|
16
22
|
match do |version_mod|
|
17
23
|
version_mod.major.is_a?(Integer)
|
@@ -52,3 +58,22 @@ RSpec.shared_examples_for("a Version module") do |version_mod|
|
|
52
58
|
end
|
53
59
|
end
|
54
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
|
66
|
+
expect(version_mod).is_a?(Module)
|
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))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/version_gem/ruby.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module VersionGem
|
2
4
|
# Helpers for library CI integration against many different versions of Ruby
|
3
5
|
module Ruby
|
4
6
|
RUBY_VER = ::Gem::Version.new(RUBY_VERSION)
|
5
7
|
|
8
|
+
# Check if the current Ruby version is greater than or equal to the given version
|
6
9
|
def gte_minimum_version?(version, engine = "ruby")
|
7
10
|
RUBY_VER >= ::Gem::Version.new(version) && ::RUBY_ENGINE == engine
|
8
11
|
end
|
9
12
|
module_function :gte_minimum_version?
|
10
13
|
|
14
|
+
# Check if the current Ruby version (MAJOR.MINOR) is equal to the given version
|
11
15
|
def actual_minor_version?(major, minor, engine = "ruby")
|
12
|
-
|
13
|
-
|
16
|
+
segs = RUBY_VER.segments
|
17
|
+
major.to_i == segs[0] &&
|
18
|
+
minor.to_i == segs[1] &&
|
14
19
|
::RUBY_ENGINE == engine
|
15
20
|
end
|
16
21
|
module_function :actual_minor_version?
|
data/lib/version_gem/version.rb
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
module VersionGem
|
4
4
|
module Version
|
5
|
-
VERSION = "1.1.
|
5
|
+
VERSION = "1.1.9"
|
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
@@ -0,0 +1 @@
|
|
1
|
+
ALL_FORMATTERS: bool
|
data/sig/debug.rbs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
DEBUG: bool
|
data/sig/debug_ide.rbs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
DEBUG_IDE: bool
|
data/sig/debug_jruby.rbs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
DEBUG_JRUBY: bool
|
data/sig/debugging.rbs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
DEBUGGING: bool
|
@@ -0,0 +1 @@
|
|
1
|
+
RUN_COVERAGE: bool
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module VersionGem
|
2
|
+
module Api
|
3
|
+
# Internal memoized version string segments
|
4
|
+
@_to_a: Array[String]
|
5
|
+
|
6
|
+
# Memoized components
|
7
|
+
@major: Integer
|
8
|
+
@minor: Integer
|
9
|
+
@patch: Integer
|
10
|
+
@pre: String?
|
11
|
+
@to_a: Array[Integer | String | nil]
|
12
|
+
@to_h: Hash[Symbol, (Integer | String | nil)]
|
13
|
+
|
14
|
+
# Public API
|
15
|
+
def to_s: () -> String
|
16
|
+
def major: () -> Integer
|
17
|
+
def minor: () -> Integer
|
18
|
+
def patch: () -> Integer
|
19
|
+
def pre: () -> String?
|
20
|
+
def to_a: () -> Array[Integer | String | nil]
|
21
|
+
def to_h: () -> Hash[Symbol, (Integer | String | nil)]
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def _to_a: () -> Array[String]
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module VersionGem
|
2
|
+
module Epoch
|
3
|
+
EPOCH_SIZE: Integer
|
4
|
+
|
5
|
+
# Hook used when this module is extended
|
6
|
+
def self.extended: (untyped) -> void
|
7
|
+
|
8
|
+
module OverloadApiForEpoch
|
9
|
+
# The epoch component (derived)
|
10
|
+
def epoch: () -> Integer
|
11
|
+
|
12
|
+
# Override of Api#major returning the derived major component
|
13
|
+
def major: () -> Integer
|
14
|
+
|
15
|
+
# Hash representation including epoch
|
16
|
+
def to_h: () -> Hash[Symbol, (Integer | String | nil)]
|
17
|
+
|
18
|
+
# Array of components [epoch, major, minor, patch, pre]
|
19
|
+
def to_a: () -> Array[Integer | String | nil]
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def _major: () -> Integer
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module VersionGem
|
2
|
+
module Ruby
|
3
|
+
RUBY_VER: ::Gem::Version
|
4
|
+
|
5
|
+
# Check if the current Ruby version is >= given version for the engine
|
6
|
+
def self.gte_minimum_version?: (String, ?String) -> bool
|
7
|
+
|
8
|
+
# Check if the current Ruby MAJOR.MINOR equals the given values for the engine
|
9
|
+
def self.actual_minor_version?: ((Integer | String), (Integer | String), ?String) -> bool
|
10
|
+
end
|
11
|
+
end
|
data/sig/version_gem.rbs
ADDED
data.tar.gz.sig
CHANGED
Binary file
|