Permalink
Browse files

add rails-cleanup script

  • Loading branch information...
1 parent 9e83c34 commit a5c15982f31686b7e1754d34d2c621da54cccca9 @NARKOZ committed Dec 1, 2011
Showing with 28 additions and 2 deletions.
  1. +0 −1 .aliases
  2. +1 −1 bin/license
  3. +27 −0 bin/rails-cleanup
View
@@ -86,7 +86,6 @@ alias 193='rvm use 1.9.3'
alias irbn='pry'
alias gi='gem install'
alias optall='optipng -o7 *.png' # optimize png images
-alias rake_clean="rake whitespace:cleanup; rake whitespace:retab; rake whitespace:scrub_gratuitous_newlines"
# eheheh :>
alias bitch='sudo'
View
@@ -1,6 +1,6 @@
#!/bin/sh
# Usage: license
-# Prints an BSD license appropriate for totin' around.
+# Prints a BSD license appropriate for totin' around.
#
# $ license > COPYING
#
View
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Usage: rails-cleanup
+# Removes a trailing whitespace and consecutive blank lines
+# from Rails project. Requires a BSD sed, not GNU.
+
+function cleanup {
+ echo "removing trailing whitespace";
+ for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
+ do sed -i '' 's/ *$//g' "$f"; printf .;
+ done
+ echo "\ndone"
+}
+
+function scrub_gratuitous_newlines {
+ echo "removing consecutive blank lines";
+ for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
+ do sed -i '' '/./,/^$/!d' "$f"; printf .;
+ done
+ echo "\ndone"
+}
+
+if [ -e "script/rails" ]; then
+ cleanup; scrub_gratuitous_newlines
+else
+ echo "failed: not in rails root"
+ exit 1
+fi

0 comments on commit a5c1598

Please sign in to comment.