Skip to content

Instantly share code, notes, and snippets.

Created Jan 14, 2015
What would you like to do?
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
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 $@
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 $@
alias rubocop='run_rubocop $@'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment