Created
January 14, 2015 18:40
-
-
Save kany/22fe43ad356187df6688 to your computer and use it in GitHub Desktop.
rubocop - script to install rubocop and rubocop-rspec gems before running rubocop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------- | |
# 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