Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add rails-cleanup script

  • Loading branch information...
commit a5c15982f31686b7e1754d34d2c621da54cccca9 1 parent 9e83c34
@NARKOZ authored
Showing with 28 additions and 2 deletions.
  1. +0 −1  .aliases
  2. +1 −1  bin/license
  3. +27 −0 bin/rails-cleanup
View
1  .aliases
@@ -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
2  bin/license
@@ -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
27 bin/rails-cleanup
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.