Created
May 18, 2012 16:16
-
-
Save gerhard/2726160 to your computer and use it in GitHub Desktop.
Find all gems in your Gemfile without a version
This file contains hidden or 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
#!/usr/bin/env bash | |
LOCAL_PATH="$(pwd)" | |
GEMS_WITHOUT_VERSION=$(cat $LOCAL_PATH/Gemfile | awk -F"['\"]" '! /[0-9].[0-9]/ && ! /source|group|end/ { print $2 }') | |
BUNDLED_GEMS=$(bundle list) | |
if [ ! $? = 0 ] | |
then | |
bundle | |
exit $? | |
fi | |
echo "" | |
if [ ! -z "$GEMS_WITHOUT_VERSION" ] | |
then | |
echo -e "Gems in your Gemfile without a version:\n" | |
for gem in $GEMS_WITHOUT_VERSION | |
do | |
echo -e "$BUNDLED_GEMS" | awk -F"[()]" '/ '$gem' / { print "gem \"'$gem'\", \"~> "$2"\"" }' | |
done | |
else | |
echo "Well done! Every gem in your Gemfile has a version." | |
fi | |
echo "" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment