Skip to content

Instantly share code, notes, and snippets.

@kany
Created Jan 14, 2015
Embed
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
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