Skip to content
Enforce a strict versioning policy in your Gemfile
Ruby Other
  1. Ruby 99.2%
  2. Other 0.8%
Branch: master
Clone or download

README.md

StrongVersions

The right thing to guide us
Is right here inside us
               --Nickelback

Overview

StrongVersions enforces a strict policy on your Gemfile requirements:

  • The pessimistic ~> operator must be used for all gem requirement definitions.
  • If the gem version is greater than 1, the requirement format must be major.minor, e.g. '~> 2.5'
  • If the gem version is less than 1, the requirement format must be major.minor.patch, e.g. '~> 0.8.9'
  • A lower/upper bound can be specified as long as a valid pessimistic version is also specified, e.g. '~> 8.4', '< 8.6.7'
  • All gems with a path or git source are ignored, e.g. path: '/path/to/gem', git: 'https://github.com/bobf/strong_versions'
  • All gems specified in the ignore list are ignored.

Any gems that do not satisfy these rules will be included in the StrongVersions output with details on why they did not meet the standard.

When all gems in a Gemfile follow this convention it SHOULD always be safe to run bundle update (assuming all gems adhere to Semantic Versioning).

StrongVersions

Installation

Add the gem to your Gemfile

gem 'strong_versions', '~> 0.4.2'

And rebuild your bundle:

$ bundle install

Or install yourself:

$ gem install strong_versions -v '0.4.2'

Usage

StrongVersions is invoked with a provided executable:

$ bundle exec strong_versions

The executable will output all non-passing gems and will return an exit code of 1 on failure, 0 on success (i.e. all gems passing). This makes StrongVersions suitable for use in a continuous integration pipeline:

StrongVersions

If you are feeling brave, auto-correct is available:

$ bundle exec strong_versions -a

Exclusions

You can tell StrongVersions to ignore any of your gems (e.g. those that don't follow semantic versioning) by adding them to the ignore section of .strong_versions.yml in your project root, e.g.:

# .strong_versions.yml
ignore:
  - rails

Contributing

Fork and create a pull request.

Run tests with RSpec:

$ bin/rspec

Check code with Rubocop:

$ bin/rubocop

License

MIT License

You can’t perform that action at this time.