Created
August 31, 2011 00:39
-
-
Save mathias/1182534 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
source $(dirname $0)/scriptlib | |
TMP=/tmp/_git_hamlize_tmp | |
TARGET_FILES="$*" | |
REQUIRED_GEMS="hpricot ruby_parser" | |
function move_and_hamlize { | |
for F in $TARGET_FILES | |
do | |
BASE_PATH_NAME="$(basename $F .html.erb)" | |
echo "Git-Moving ${BASE_PATH_NAME}.html.erb to ${BASE_PATH_NAME}.html.haml" | |
git mv ${BASE_PATH_NAME}.html.erb ${BASE_PATH_NAME}.html.haml | |
html2haml -r ${BASE_PATH_NAME}.html.haml > $TMP | |
mv $TMP ${BASE_PATH_NAME}.html.haml | |
done | |
} | |
function all_gems_present { | |
for gem in $REQUIRED_GEMS | |
do | |
if [ "$(gem list $gem | grep $gem | wc -l | sed -e 's/^ *//')" != "1" ]; then | |
return -1 | |
fi | |
done | |
return 0 | |
} | |
if all_gems_present; then | |
move_and_hamlize | |
else | |
fail "$0 requires the following gems: $REQUIRED_GEMS" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment