Created
September 30, 2012 13:06
-
-
Save stigi/3806684 to your computer and use it in GitHub Desktop.
erb2haml.sh
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
#!/bin/sh | |
check_gem() { | |
REPLY=$(gem which $1 &>/dev/null) | |
} | |
convert() { | |
printf "Starting conversion\n[" | |
for erb_file in `find . -name '*.erb'` | |
do | |
printf "." | |
html2haml -r $erb_file `ruby -e "puts '$erb_file'.sub(/erb$/,'haml')"` | |
rm $erb_file | |
done | |
printf "]\nDone.\n" | |
} | |
if | |
check_gem haml | |
check_gem hpricot | |
check_gem ruby_parser | |
then | |
convert | |
exit 0 | |
else | |
echo "To use $0 you need to have the following gems installed: haml, hpricot and ruby_parser" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need someone who is better in shell scripting than me + google. I want to AND bind the calls of check_gem in lines 24-26.