Skip to content

Instantly share code, notes, and snippets.

@kany
Created January 14, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kany/22fe43ad356187df6688 to your computer and use it in GitHub Desktop.
Save kany/22fe43ad356187df6688 to your computer and use it in GitHub Desktop.
rubocop - script to install rubocop and rubocop-rspec gems before running rubocop
# -------
# rubocop
# -------
# example usage:
# check a directory: rubocop app/controllers
# check a file: rubocop app/controllers/application_controller.rb
# check rspec directory: rubycop spec/controllers
# check rspec file: rubycop spec/controllers/application_controller_spec.rb
run_rubocop(){
if gem list | gem list | grep 'rubocop\|rubocop-rspec' ; then
echo "rubycop and rubocop-rspec gems already installed"
echo "* Running rubocop"
rubocop --require rubocop-rspec $@
else
echo "* Installing required ruby gems"
gem install rubocop --no-ri --no-rdoc
gem install rubocop-rspec --no-ri --no-rdoc
echo "* Running rubocop"
rubocop --require rubocop-rspec $@
fi
}
alias rubocop='run_rubocop $@'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment