version_gem-1.1.9/ 0000755 0000041 0000041 00000000000 15056747637 014113 5 ustar www-data www-data version_gem-1.1.9/FUNDING.md 0000644 0000041 0000041 00000013503 15056747637 015531 0 ustar www-data www-data
Official Discord 👉️ [![Live Chat on Discord][✉️discord-invite-img]][✉️discord-invite]
Many paths lead to being a sponsor or a backer of this project. Are you on such a path?
[![OpenCollective Backers][🖇osc-backers-i]][🖇osc-backers] [![OpenCollective Sponsors][🖇osc-sponsors-i]][🖇osc-sponsors] [![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor] [![Liberapay Goal Progress][⛳liberapay-img]][⛳liberapay] [![Donate on PayPal][🖇paypal-img]][🖇paypal]
[![Buy me a coffee][🖇buyme-small-img]][🖇buyme] [![Donate on Polar][🖇polar-img]][🖇polar] [![Donate to my FLOSS or refugee efforts at ko-fi.com][🖇kofi-img]][🖇kofi] [![Donate to my FLOSS or refugee efforts using Patreon][🖇patreon-img]][🖇patreon]
[⛳liberapay-img]: https://img.shields.io/liberapay/goal/pboling.svg?logo=liberapay&color=a51611&style=flat
[⛳liberapay]: https://liberapay.com/pboling/donate
[🖇osc-backers]: https://opencollective.com/ruby-oauth#backer
[🖇osc-backers-i]: https://opencollective.com/ruby-oauth/backers/badge.svg?style=flat
[🖇osc-sponsors]: https://opencollective.com/ruby-oauth#sponsor
[🖇osc-sponsors-i]: https://opencollective.com/ruby-oauth/sponsors/badge.svg?style=flat
[🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
[🖇sponsor]: https://github.com/sponsors/pboling
[🖇polar-img]: https://img.shields.io/badge/polar-donate-a51611.svg?style=flat
[🖇polar]: https://polar.sh/pboling
[🖇kofi-img]: https://img.shields.io/badge/ko--fi-✓-a51611.svg?style=flat
[🖇kofi]: https://ko-fi.com/O5O86SNP4
[🖇patreon-img]: https://img.shields.io/badge/patreon-donate-a51611.svg?style=flat
[🖇patreon]: https://patreon.com/galtzo
[🖇buyme-small-img]: https://img.shields.io/badge/buy_me_a_coffee-✓-a51611.svg?style=flat
[🖇buyme]: https://www.buymeacoffee.com/pboling
[🖇paypal-img]: https://img.shields.io/badge/donate-paypal-a51611.svg?style=flat&logo=paypal
[🖇paypal]: https://www.paypal.com/paypalme/peterboling
[✉️discord-invite]: https://discord.gg/3qme4XHNKN
[✉️discord-invite-img]: https://img.shields.io/discord/1373797679469170758?style=flat
# 🤑 Request for Help
Maintainers have teeth and need to pay their dentists.
After getting laid off in an RIF in March and filled with many dozens of rejections,
I'm now spending ~60+ hours a week building open source tools.
I'm hoping to be able to pay for my kids' health insurance this month,
so if you value the work I am doing, I need your support.
Please consider sponsoring me or the project.
To join the community or get help 👇️ Join the Discord.
[![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite]
To say "thanks for maintaining such a great tool" ☝️ Join the Discord or 👇️ send money.
[![Sponsor ruby-oauth/version_gem on Open Source Collective][🖇osc-all-bottom-img]][🖇osc] 💌 [![Sponsor me on GitHub Sponsors][🖇sponsor-bottom-img]][🖇sponsor] 💌 [![Sponsor me on Liberapay][⛳liberapay-bottom-img]][⛳liberapay-img] 💌 [![Donate on PayPal][🖇paypal-bottom-img]][🖇paypal-img]
# Another Way to Support Open Source Software
> How wonderful it is that nobody need wait a single moment before starting to improve the world.
>—Anne Frank
I’m driven by a passion to foster a thriving open-source community – a space where people can tackle complex problems, no matter how small. Revitalizing libraries that have fallen into disrepair, and building new libraries focused on solving real-world challenges, are my passions — totaling 79 hours of FLOSS coding over just the past seven days, a pretty regular week for me. I was recently affected by layoffs, and the tech jobs market is unwelcoming. I’m reaching out here because your support would significantly aid my efforts to provide for my family, and my farm (11 🐔 chickens, 2 🐶 dogs, 3 🐰 rabbits, 8 🐈 cats).
If you work at a company that uses my work, please encourage them to support me as a corporate sponsor. My work on gems you use might show up in `bundle fund`.
I’m developing a new library, [floss_funding][🖇floss-funding-gem], designed to empower open-source developers like myself to get paid for the work we do, in a sustainable way. Please give it a look.
**[Floss-Funding.dev][🖇floss-funding.dev]: 👉️ No network calls. 👉️ No tracking. 👉️ No oversight. 👉️ Minimal crypto hashing. 💡 Easily disabled nags**
[⛳liberapay-bottom-img]: https://img.shields.io/liberapay/goal/pboling.svg?style=for-the-badge&logo=liberapay&color=a51611
[🖇osc-all-img]: https://img.shields.io/opencollective/all/ruby-oauth
[🖇osc-sponsors-img]: https://img.shields.io/opencollective/sponsors/ruby-oauth
[🖇osc-backers-img]: https://img.shields.io/opencollective/backers/ruby-oauth
[🖇osc-all-bottom-img]: https://img.shields.io/opencollective/all/ruby-oauth?style=for-the-badge
[🖇osc-sponsors-bottom-img]: https://img.shields.io/opencollective/sponsors/ruby-oauth?style=for-the-badge
[🖇osc-backers-bottom-img]: https://img.shields.io/opencollective/backers/ruby-oauth?style=for-the-badge
[🖇osc]: https://opencollective.com/ruby-oauth
[🖇sponsor-bottom-img]: https://img.shields.io/badge/Sponsor_Me!-pboling-blue?style=for-the-badge&logo=github
[🖇buyme-img]: https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff
[🖇paypal-bottom-img]: https://img.shields.io/badge/donate-paypal-a51611.svg?style=for-the-badge&logo=paypal&color=0A0A0A
[🖇floss-funding.dev]: https://floss-funding.dev
[🖇floss-funding-gem]: https://github.com/galtzo-floss/floss_funding
[✉️discord-invite-img-ftb]: https://img.shields.io/discord/1373797679469170758?style=for-the-badge
version_gem-1.1.9/RUBOCOP.md 0000644 0000041 0000041 00000006531 15056747637 015553 0 ustar www-data www-data # RuboCop Usage Guide
## Overview
A tale of two RuboCop plugin gems.
### RuboCop Gradual
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.
### RuboCop LTS
This project uses `rubocop-lts` to ensure, on a best-effort basis, compatibility with Ruby >= 1.9.2.
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.
## Checking RuboCop Violations
To check for RuboCop violations in this project, always use:
```bash
bundle exec rake rubocop_gradual:check
```
**Do not use** the standard RuboCop commands like:
- `bundle exec rubocop`
- `rubocop`
## Understanding the Lock File
The `.rubocop_gradual.lock` file tracks all current RuboCop violations in the project. This allows the team to:
1. Prevent new violations while gradually fixing existing ones
2. Track progress on code style improvements
3. Ensure CI builds don't fail due to pre-existing violations
## Common Commands
- **Check violations**
- `bundle exec rake rubocop_gradual`
- `bundle exec rake rubocop_gradual:check`
- **(Safe) Autocorrect violations, and update lockfile if no new violations**
- `bundle exec rake rubocop_gradual:autocorrect`
- **Force update the lock file (w/o autocorrect) to match violations present in code**
- `bundle exec rake rubocop_gradual:force_update`
## Workflow
1. Before submitting a PR, run `bundle exec rake rubocop_gradual:autocorrect`
a. or just the default `bundle exec rake`, as autocorrection is a pre-requisite of the default task.
2. If there are new violations, either:
- Fix them in your code
- Run `bundle exec rake rubocop_gradual:force_update` to update the lock file (only for violations you can't fix immediately)
3. Commit the updated `.rubocop_gradual.lock` file along with your changes
## Never add inline RuboCop disables
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:
- 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.
- Temporary exceptions while improving code: record the current violations in `.rubocop_gradual.lock` via the gradual workflow:
- `bundle exec rake rubocop_gradual:autocorrect` (preferred; will autocorrect what it can and update the lock only if no new violations were introduced)
- If needed, `bundle exec rake rubocop_gradual:force_update` (as a last resort when you cannot fix the newly reported violations immediately)
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.
## Benefits of rubocop_gradual
- Allows incremental adoption of code style rules
- Prevents CI failures due to pre-existing violations
- Provides a clear record of code style debt
- Enables focused efforts on improving code quality over time
version_gem-1.1.9/CONTRIBUTING.md 0000644 0000041 0000041 00000024505 15056747637 016352 0 ustar www-data www-data # Contributing
Bug reports and pull requests are welcome on [CodeBerg][📜src-cb], [GitLab][📜src-gl], or [GitHub][📜src-gh].
This project should be a safe, welcoming space for collaboration, so contributors agree to adhere to
the [code of conduct][🤝conduct].
To submit a patch, please fork the project, create a patch with tests, and send a pull request.
Remember to [![Keep A Changelog][📗keep-changelog-img]][📗keep-changelog] if you make changes.
## Help out!
Take a look at the `reek` list which is the file called `REEK` and find something to improve.
Follow these instructions:
1. Fork the repository
2. Create a feature branch (`git checkout -b my-new-feature`)
3. Make some fixes.
4. Commit changes (`git commit -am 'Added some feature'`)
5. Push to the branch (`git push origin my-new-feature`)
6. Make sure to add tests for it. This is important, so it doesn't break in a future release.
7. Create new Pull Request.
## Environment Variables for Local Development
Below are the primary environment variables recognized by stone_checksums (and its integrated tools). Unless otherwise noted, set boolean values to the string "true" to enable.
General/runtime
- DEBUG: Enable extra internal logging for this library (default: false)
- REQUIRE_BENCH: Enable `require_bench` to profile requires (default: false)
- CI: When set to true, adjusts default rake tasks toward CI behavior
Coverage (kettle-soup-cover / SimpleCov)
- K_SOUP_COV_DO: Enable coverage collection (default: true in .envrc)
- K_SOUP_COV_FORMATTERS: Comma-separated list of formatters (html, xml, rcov, lcov, json, tty)
- K_SOUP_COV_MIN_LINE: Minimum line coverage threshold (integer, e.g., 100)
- K_SOUP_COV_MIN_BRANCH: Minimum branch coverage threshold (integer, e.g., 100)
- K_SOUP_COV_MIN_HARD: Fail the run if thresholds are not met (true/false)
- K_SOUP_COV_MULTI_FORMATTERS: Enable multiple formatters at once (true/false)
- K_SOUP_COV_OPEN_BIN: Path to browser opener for HTML (empty disables auto-open)
- MAX_ROWS: Limit console output rows for simplecov-console (e.g., 1)
Tip: When running a single spec file locally, you may want `K_SOUP_COV_MIN_HARD=false` to avoid failing thresholds for a partial run.
GitHub API and CI helpers
- GITHUB_TOKEN or GH_TOKEN: Token used by `ci:act` and release workflow checks to query GitHub Actions status at higher rate limits
Releasing and signing
- SKIP_GEM_SIGNING: If set, skip gem signing during build/release
- GEM_CERT_USER: Username for selecting your public cert in `certs/.pem` (defaults to $USER)
- SOURCE_DATE_EPOCH: Reproducible build timestamp. `kettle-release` will set this automatically for the session.
Git hooks and commit message helpers (exe/kettle-commit-msg)
- GIT_HOOK_BRANCH_VALIDATE: Branch name validation mode (e.g., `jira`) or `false` to disable
- GIT_HOOK_FOOTER_APPEND: Append a footer to commit messages when goalie allows (true/false)
- GIT_HOOK_FOOTER_SENTINEL: Required when footer append is enabled — a unique first-line sentinel to prevent duplicates
- GIT_HOOK_FOOTER_APPEND_DEBUG: Extra debug output in the footer template (true/false)
For a quick starting point, this repository’s `.envrc` shows sane defaults, and `.env.local` can override them locally.
## Appraisals
From time to time the [appraisal2][🚎appraisal2] gemfiles in `gemfiles/` will need to be updated.
They are created and updated with the commands:
```console
bin/rake appraisal:update
```
When adding an appraisal to CI, check the [runner tool cache][🏃♂️runner-tool-cache] to see which runner to use.
## The Reek List
Take a look at the `reek` list which is the file called `REEK` and find something to improve.
To refresh the `reek` list:
```console
bundle exec reek > REEK
```
## Run Tests
To run all tests
```console
bundle exec rake test
```
### Spec organization (required)
- One spec file per class/module. For each class or module under `lib/`, keep all of its unit tests in a single spec file under `spec/` that mirrors the path and file name exactly: `lib/version_gem/release_cli.rb` -> `spec/version_gem/release_cli_spec.rb`.
- Never add a second spec file for the same class/module. Examples of disallowed names: `*_more_spec.rb`, `*_extra_spec.rb`, `*_status_spec.rb`, or any other suffix that still targets the same class. If you find yourself wanting a second file, merge those examples into the canonical spec file for that class/module.
- Exception: Integration specs that intentionally span multiple classes. Place these under `spec/integration/` (or a clearly named integration folder), and do not directly mirror a single class. Name them after the scenario, not a class.
- Migration note: If a duplicate spec file exists, move all examples into the canonical file and delete the duplicate. Do not leave stubs or empty files behind.
## Lint It
Run all the default tasks, which includes running the gradually autocorrecting linter, `rubocop-gradual`.
```console
bundle exec rake
```
Or just run the linter.
```console
bundle exec rake rubocop_gradual:autocorrect
```
For more detailed information about using RuboCop in this project, please see the [RUBOCOP.md](RUBOCOP.md) guide. This project uses `rubocop_gradual` instead of vanilla RuboCop, which requires specific commands for checking violations.
### Important: Do not add inline RuboCop disables
Never add `# rubocop:disable ...` / `# rubocop:enable ...` comments to code or specs (except when following the few existing `rubocop:disable` patterns for a rule already being disabled elsewhere in the code). Instead:
- Prefer configuration-based exclusions when a rule should not apply to certain paths or files (e.g., via `.rubocop.yml`).
- When a violation is temporary and you plan to fix it later, record it in `.rubocop_gradual.lock` using the gradual workflow:
- `bundle exec rake rubocop_gradual:autocorrect` (preferred)
- `bundle exec rake rubocop_gradual:force_update` (only when you cannot fix the violations immediately)
As a general rule, fix style issues rather than ignoring them. For example, our specs should follow RSpec conventions like using `described_class` for the class under test.
## Contributors
Your picture could be here!
[![Contributors][🖐contributors-img]][🖐contributors]
Made with [contributors-img][🖐contrib-rocks].
Also see GitLab Contributors: [https://gitlab.com/ruby-oauth/version_gem/-/graphs/main][🚎contributors-gl]
## For Maintainers
### One-time, Per-maintainer, Setup
**IMPORTANT**: To sign a build,
a public key for signing gems will need to be picked up by the line in the
`gemspec` defining the `spec.cert_chain` (check the relevant ENV variables there).
All releases to RubyGems.org are signed releases.
See: [RubyGems Security Guide][🔒️rubygems-security-guide]
NOTE: To build without signing the gem set `SKIP_GEM_SIGNING` to any value in the environment.
### To release a new version:
#### Automated process
1. Update version.rb to contian the correct version-to-be-released.
2. Run `bundle exec kettle-changelog`.
3. Run `bundle exec kettle-release`.
#### Manual process
1. Run `bin/setup && bin/rake` as a "test, coverage, & linting" sanity check
2. Update the version number in `version.rb`, and ensure `CHANGELOG.md` reflects changes
3. Run `bin/setup && bin/rake` again as a secondary check, and to update `Gemfile.lock`
4. Run `git commit -am "🔖 Prepare release v"` to commit the changes
5. Run `git push` to trigger the final CI pipeline before release, and merge PRs
- NOTE: Remember to [check the build][🧪build].
6. Run `export GIT_TRUNK_BRANCH_NAME="$(git remote show origin | grep 'HEAD branch' | cut -d ' ' -f5)" && echo $GIT_TRUNK_BRANCH_NAME`
7. Run `git checkout $GIT_TRUNK_BRANCH_NAME`
8. Run `git pull origin $GIT_TRUNK_BRANCH_NAME` to ensure latest trunk code
9. Optional for older Bundler (< 2.7.0): Set `SOURCE_DATE_EPOCH` so `rake build` and `rake release` use the same timestamp and generate the same checksums
- If your Bundler is >= 2.7.0, you can skip this; builds are reproducible by default.
- Run `export SOURCE_DATE_EPOCH=$EPOCHSECONDS && echo $SOURCE_DATE_EPOCH`
- If the echo above has no output, then it didn't work.
- Note: `zsh/datetime` module is needed, if running `zsh`.
- In older versions of `bash` you can use `date +%s` instead, i.e. `export SOURCE_DATE_EPOCH=$(date +%s) && echo $SOURCE_DATE_EPOCH`
10. Run `bundle exec rake build`
11. Run `bin/gem_checksums` (more context [1][🔒️rubygems-checksums-pr], [2][🔒️rubygems-guides-pr])
to create SHA-256 and SHA-512 checksums. This functionality is provided by the `stone_checksums`
[gem][💎stone_checksums].
- The script automatically commits but does not push the checksums
12. Sanity check the SHA256, comparing with the output from the `bin/gem_checksums` command:
- `sha256sum pkg/-.gem`
13. Run `bundle exec rake release` which will create a git tag for the version,
push git commits and tags, and push the `.gem` file to [rubygems.org][💎rubygems]
[📜src-gl]: https://gitlab.com/ruby-oauth/version_gem/
[📜src-cb]: https://codeberg.org/ruby-oauth/version_gem
[📜src-gh]: https://github.com/ruby-oauth/version_gem
[🧪build]: https://github.com/ruby-oauth/version_gem/actions
[🤝conduct]: https://gitlab.com/ruby-oauth/version_gem/-/blob/main/CODE_OF_CONDUCT.md
[🖐contrib-rocks]: https://contrib.rocks
[🖐contributors]: https://github.com/ruby-oauth/version_gem/graphs/contributors
[🚎contributors-gl]: https://gitlab.com/ruby-oauth/version_gem/-/graphs/main
[🖐contributors-img]: https://contrib.rocks/image?repo=ruby-oauth/version_gem
[💎rubygems]: https://rubygems.org
[🔒️rubygems-security-guide]: https://guides.rubygems.org/security/#building-gems
[🔒️rubygems-checksums-pr]: https://github.com/rubygems/rubygems/pull/6022
[🔒️rubygems-guides-pr]: https://github.com/rubygems/guides/pull/325
[💎stone_checksums]: https://github.com/galtzo-floss/stone_checksums
[📗keep-changelog]: https://keepachangelog.com/en/1.0.0/
[📗keep-changelog-img]: https://img.shields.io/badge/keep--a--changelog-1.0.0-FFDD67.svg?style=flat
[📌semver-breaking]: https://github.com/semver/semver/issues/716#issuecomment-869336139
[📌major-versions-not-sacred]: https://tom.preston-werner.com/2022/05/23/major-version-numbers-are-not-sacred.html
[🚎appraisal2]: https://github.com/appraisal-rb/appraisal2
[🏃♂️runner-tool-cache]: https://github.com/ruby/ruby-builder/releases/tag/toolcache
version_gem-1.1.9/SECURITY.md 0000755 0000041 0000041 00000001100 15056747637 015677 0 ustar www-data www-data # Security Policy
## Supported Versions
| Version | Supported |
|----------|-----------|
| 1.latest | ✅ |
## Security contact information
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
## Additional Support
If you are interested in support for versions older than the latest release,
please consider sponsoring the project / maintainer @ https://liberapay.com/pboling/donate,
or find other sponsorship links in the [README].
[README]: README.md
version_gem-1.1.9/lib/ 0000755 0000041 0000041 00000000000 15056747637 014661 5 ustar www-data www-data version_gem-1.1.9/lib/version_gem.rb 0000755 0000041 0000041 00000000405 15056747637 017525 0 ustar www-data www-data # frozen_string_literal: true
require_relative "version_gem/version"
require_relative "version_gem/basic"
require_relative "version_gem/epoch"
# Namespace of this library
module VersionGem
end
VersionGem::Version.class_eval do
extend VersionGem::Basic
end
version_gem-1.1.9/lib/version_gem/ 0000755 0000041 0000041 00000000000 15056747637 017176 5 ustar www-data www-data version_gem-1.1.9/lib/version_gem/error.rb 0000755 0000041 0000041 00000000215 15056747637 020655 0 ustar www-data www-data # frozen_string_literal: true
module VersionGem
# Errors raised by VersionGem will be of this class
class Error < RuntimeError; end
end
version_gem-1.1.9/lib/version_gem/rspec.rb 0000755 0000041 0000041 00000004575 15056747637 020655 0 ustar www-data www-data # frozen_string_literal: true
RSpec::Matchers.define(:have_version_constant) do
match do |version_mod|
version_mod.const_defined?(:VERSION, false)
end
end
RSpec::Matchers.define(:have_version_as_string) do
match do |version_mod|
!version_mod::VERSION.nil? && version_mod::VERSION.is_a?(String)
end
end
RSpec::Matchers.define(:have_epoch_as_integer) do
match do |version_mod|
version_mod.epoch.is_a?(Integer)
end
end
RSpec::Matchers.define(:have_major_as_integer) do
match do |version_mod|
version_mod.major.is_a?(Integer)
end
end
RSpec::Matchers.define(:have_minor_as_integer) do
match do |version_mod|
version_mod.minor.is_a?(Integer)
end
end
RSpec::Matchers.define(:have_patch_as_integer) do
match do |version_mod|
version_mod.patch.is_a?(Integer)
end
end
RSpec::Matchers.define(:have_pre_as_nil_or_string) do
match do |version_mod|
version_mod.pre.nil? || version_mod.pre.is_a?(String)
end
end
RSpec.shared_examples_for("a Version module") do |version_mod|
it "is introspectable" do
aggregate_failures "introspectable api" do
expect(version_mod).is_a?(Module)
expect(version_mod).to(have_version_constant)
expect(version_mod).to(have_version_as_string)
expect(version_mod.to_s).to(be_a(String))
expect(version_mod).to(have_major_as_integer)
expect(version_mod).to(have_minor_as_integer)
expect(version_mod).to(have_patch_as_integer)
expect(version_mod).to(have_pre_as_nil_or_string)
expect(version_mod.to_h.keys).to(match_array(%i[major minor patch pre]))
expect(version_mod.to_a).to(be_a(Array))
end
end
end
# This one is more Epoch ;)
RSpec.shared_examples_for("an Epoch Version module") do |version_mod|
it "is introspectable" do
aggregate_failures "introspectable api" do
expect(version_mod).is_a?(Module)
expect(version_mod).to(have_version_constant)
expect(version_mod).to(have_version_as_string)
expect(version_mod.to_s).to(be_a(String))
expect(version_mod).to(have_epoch_as_integer)
expect(version_mod).to(have_major_as_integer)
expect(version_mod).to(have_minor_as_integer)
expect(version_mod).to(have_patch_as_integer)
expect(version_mod).to(have_pre_as_nil_or_string)
expect(version_mod.to_h.keys).to(match_array(%i[epoch major minor patch pre]))
expect(version_mod.to_a).to(be_a(Array))
end
end
end
version_gem-1.1.9/lib/version_gem/version.rb 0000644 0000041 0000041 00000000653 15056747637 021214 0 ustar www-data www-data # frozen_string_literal: true
module VersionGem
module Version
VERSION = "1.1.9"
# This would work in this gem, but not in external libraries,
# because version files are loaded in Gemspecs before bundler
# has a chance to load dependencies.
# Instead, see lib/version_gem.rb for a solution that will work everywhere
# extend VersionGem::Basic
# or
# extend VersionGem::Epoch
end
end
version_gem-1.1.9/lib/version_gem/api.rb 0000755 0000041 0000041 00000002240 15056747637 020275 0 ustar www-data www-data # frozen_string_literal: true
module VersionGem
# Public API of this library
module Api
# The version number as a string
#
# @return [String]
def to_s
self::VERSION
end
# The major version
#
# @return [Integer]
def major
@major ||= _to_a[0].to_i
end
# The minor version
#
# @return [Integer]
def minor
@minor ||= _to_a[1].to_i
end
# The patch version
#
# @return [Integer]
def patch
@patch ||= _to_a[2].to_i
end
# The pre-release version, if any
#
# @return [String, NilClass]
def pre
@pre ||= _to_a[3]
end
# The version number as a hash
#
# @return [Hash]
def to_h
@to_h ||= {
major: major,
minor: minor,
patch: patch,
pre: pre,
}
end
# The version number as an array of cast values
#
# @return [Array<[Integer, String, NilClass]>]
def to_a
@to_a ||= [major, minor, patch, pre]
end
private
# The version number as an array of strings
#
# @return [Array]
def _to_a
@_to_a = self::VERSION.split(".")
end
end
end
version_gem-1.1.9/lib/version_gem/basic.rb 0000755 0000041 0000041 00000000620 15056747637 020605 0 ustar www-data www-data # frozen_string_literal: true
require_relative "error"
require_relative "api"
module VersionGem
# This is a very *basic* version parser. Others could be built based on this pattern!
module Basic
class << self
def extended(base)
raise Error, "VERSION must be defined before 'extend #{name}'" unless defined?(base::VERSION)
base.extend(Api)
end
end
end
end
version_gem-1.1.9/lib/version_gem/epoch.rb 0000755 0000041 0000041 00000003040 15056747637 020621 0 ustar www-data www-data # frozen_string_literal: true
require_relative "error"
require_relative "api"
module VersionGem
# Support for Epoch Semantic Versioning
# See: https://antfu.me/posts/epoch-semver
module Epoch
EPOCH_SIZE = 1_000
class << self
def extended(base)
raise Error, "VERSION must be defined before 'extend #{name}'" unless defined?(base::VERSION)
base.extend(Api)
base.extend(OverloadApiForEpoch)
end
end
# Tweak the basic API so it will support Epoch Semantic Versioning
module OverloadApiForEpoch
# *** OVERLOAD METHODS FROM API ***
#
# The epoch version
#
# @return [Integer]
def epoch
@epoch ||= _major / EPOCH_SIZE
end
# The major version
#
# @return [Integer]
def major
@major ||= _major % EPOCH_SIZE
end
# The version number as a hash
#
# @return [Hash]
def to_h
@to_h ||= {
epoch: epoch,
major: major,
minor: minor,
patch: patch,
pre: pre,
}
end
# NOTE: This is not the same as _to_a, which returns an array of strings
#
# The version number as an array of cast values
# where epoch and major are derived from a single string:
# EPOCH * 1000 + MAJOR
#
# @return [Array<[Integer, String, NilClass]>]
def to_a
@to_a ||= [epoch, major, minor, patch, pre]
end
private
def _major
@_major ||= _to_a[0].to_i
end
end
end
end
version_gem-1.1.9/lib/version_gem/ruby.rb 0000755 0000041 0000041 00000001425 15056747637 020511 0 ustar www-data www-data # frozen_string_literal: true
module VersionGem
# Helpers for library CI integration against many different versions of Ruby
module Ruby
RUBY_VER = ::Gem::Version.new(RUBY_VERSION)
# Check if the current Ruby version is greater than or equal to the given version
def gte_minimum_version?(version, engine = "ruby")
RUBY_VER >= ::Gem::Version.new(version) && ::RUBY_ENGINE == engine
end
module_function :gte_minimum_version?
# Check if the current Ruby version (MAJOR.MINOR) is equal to the given version
def actual_minor_version?(major, minor, engine = "ruby")
segs = RUBY_VER.segments
major.to_i == segs[0] &&
minor.to_i == segs[1] &&
::RUBY_ENGINE == engine
end
module_function :actual_minor_version?
end
end
version_gem-1.1.9/LICENSE.txt 0000755 0000041 0000041 00000002076 15056747637 015746 0 ustar www-data www-data The MIT License (MIT)
Copyright (c) 2022 - 2025 Peter Boling
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
version_gem-1.1.9/CITATION.cff 0000644 0000041 0000041 00000001063 15056747637 016005 0 ustar www-data www-data cff-version: 1.2.0
title: version_gem
message: >-
If you use this work and you want to cite it,
then you can use the metadata from this file.
type: software
authors:
- given-names: Peter Hurn
family-names: Boling
email: peter@railsbling.com
affiliation: railsbling.com
orcid: 'https://orcid.org/0009-0008-8519-441X'
identifiers:
- type: url
value: 'https://github.com/ruby-oauth/version_gem'
description: version_gem
repository-code: 'https://github.com/ruby-oauth/version_gem'
abstract: >-
version_gem
license: See license file
version_gem-1.1.9/checksums.yaml.gz.sig 0000444 0000041 0000041 00000000600 15056747637 020156 0 ustar www-data www-data cpzUL헉ΕE[