kpn-style
kpn shared style configs.
Installation
Add this line to your application's Gemfile:
group :test, :development do
gem 'kpn-style'
endOr, for a Ruby library, add this to your gemspec:
spec.add_development_dependency 'kpn-style'And then run:
$ bundle installUsage
Create a .rubocop.yml with the following directives:
inherit_gem:
kpn-style:
- ruby-2.1.ymlOr for Ruby 2.4:
inherit_gem:
kpn-style:
- ruby-2.4.ymlOr for Ruby 2.5:
inherit_gem:
kpn-style:
- ruby-2.5.ymlOr for Ruby 2.7:
inherit_gem:
kpn-style:
- ruby-2.7.ymlOr for Ruby 3.0:
inherit_gem:
kpn-style:
- ruby-3.0.ymlNow, run:
$ bundle exec rubocop
or
$ rake rubocopYou 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.rbUpdate gem
- Update the ruby-2.X.yml file
- Update the version parameter
spec.versionin 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.gemTo 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.