kpn-style
kpn shared style configs.
Installation
Add this line to your application's Gemfile:
group :test, :development do
gem 'kpn-style'
end
Or, for a Ruby library, add this to your gemspec:
spec.add_development_dependency 'kpn-style'
And then run:
$ bundle install
Usage
Create a .rubocop.yml
with the following directives:
inherit_gem:
kpn-style:
- ruby-2.1.yml
Or for Ruby 2.4:
inherit_gem:
kpn-style:
- ruby-2.4.yml
Or for Ruby 2.5:
inherit_gem:
kpn-style:
- ruby-2.5.yml
Or for Ruby 2.7:
inherit_gem:
kpn-style:
- ruby-2.7.yml
Or for Ruby 3.0:
inherit_gem:
kpn-style:
- ruby-3.0.yml
Now, run:
$ bundle exec rubocop
or
$ rake rubocop
You do not need to include rubocop directly in your application's dependencies. kpn-style will include a specific version of rubocop
and rubocop-rspec
that is shared across all projects.
Style overrides
Sometimes you need to override style rules. RuboCop have a nice inheritance hierachy so you can override the default settings. The hierachy is:
inherit_gem -> inherit_from -> local rules
For example:
inherit_gem:
kpn-style:
- ruby-2.7.yml
inherit_from: .rubocop_todo.yml
AllCops:
Exclude:
- exclude/file.rb
Update gem
- Update the ruby-2.X.yml file
- Update the version parameter
spec.version
in thekpn_style.gemspec
- Tag the release:
git tag VERSION
- Push changes:
git push --tags
- Update the release notes on GitHub.com
- Build and publish:
gem build kpn_style.gemspec
gem push kpn-style-x.x.x.gem
To push gems to rubygems.org you can use a ~/.gem/credentials
with the rubygems_api_key
. You can find a small how to on the Profile edit page https://rubygems.org/profile/edit in the section API ACCESS
.
Special thanks
A special thanks to https://github.com/percy/percy-style/ for the idea and template of this Gem.