Skip to content

Instantly share code, notes, and snippets.

@artursapek
Created August 21, 2013 21:00
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 artursapek/6300221 to your computer and use it in GitHub Desktop.
Save artursapek/6300221 to your computer and use it in GitHub Desktop.
. $HOME/.bash_profile
cd $HOME/Codecademy/app
check_usage () {
while read data
do
PARTIAL_NAME=$(echo $data | sed 's/views\///g' | sed 's/\/\_/\//g' | sed 's/\..*//g')
PARTIAL_LOCAL_NAME=$(echo $PARTIAL_NAME | sed 's/.*\///g')
if [[ $(check_extension "render.*$PARTIAL_LOCAL_NAME" haml) -eq 1 ]]; then
continue
fi
if [[ $(check_extension "render.*$PARTIAL_NAME" haml) -eq 1 ]]; then
continue
fi
if [[ $(check_extension "render.*$PARTIAL_NAME" erb) -eq 1 ]]; then
continue
fi
if [[ $(check_extension "render.*$PARTIAL_LOCAL_NAME" erb) -eq 1 ]]; then
continue
fi
echo $data
done
}
is_empty () {
COUNT=$(echo $1 | wc | awk '{print $2}')
if [ $COUNT == '0' ]; then
echo 0;
else
echo 1;
fi;
}
check_extension () {
RESULTS=$(grep -r --include="*.$2" $1 views);
if [[ $(is_empty $RESULTS) -eq 0 ]]; then
echo 0;
else
echo 1;
fi
}
find views -name 'glossary' -prune -o -name 'styleguide' -prune -o -type f | grep \/_.*$ | egrep "erb|haml" | check_usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment