Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. # requires BSD sed
  2. namespace :whitespace do
  3. desc 'Removes trailing whitespace'
  4. task :cleanup do
  5. sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
  6. do sed -i '' 's/ *$//g' "$f";
  7. done}, {:verbose => false}
  8. puts "Task cleanup done"
  9. end
  10.  
  11. desc 'Converts hard-tabs into two-space soft-tabs'
  12. task :retab do
  13. sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
  14. do sed -i '' 's/\t/ /g' "$f";
  15. done}, {:verbose => false}
  16. puts "Task retab done"
  17. end
  18.  
  19. desc 'Remove consecutive blank lines'
  20. task :scrub_gratuitous_newlines do
  21. sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
  22. do sed -i '' '/./,/^$/!d' "$f";
  23. done}, {:verbose => false}
  24. puts "Task scrub_gratuitous_newlines done"
  25. end
  26.  
  27. desc 'Execute all WHITESPACE tasks'
  28. task :all do
  29. Rake::Task['whitespace:cleanup'].execute
  30. Rake::Task['whitespace:retab'].execute
  31. Rake::Task['whitespace:scrub_gratuitous_newlines'].execute
  32. end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement