Improve whitespace:cleanup and whitespace:retab

This commit is contained in:
Dorian 2010-09-25 23:15:04 +02:00 committed by Stephen Caudill
parent 6ffc03a4c9
commit d8c497177f

View file

@ -1,15 +1,18 @@
namespace :whitespace do
desc 'Removes trailing whitespace'
task :cleanup do
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
sh %{for f in `find . -type f | grep -v -e '.git/' -e 'public/' -e '.png'`;
do cat $f | sed 's/[ \t]*$//' > tmp; cp tmp $f; rm tmp; echo -n .;
done}
end
desc 'Converts hard-tabs into two-space soft-tabs'
task :retab do
sh %{find . -name '*.rb' -exec sed -i '' 's/\t/ /g' {} \\;}
sh %{for f in `find . -type f | grep -v -e '.git/' -e 'public/' -e '.png'`;
do cat $f | sed 's/\t/ /g' > tmp; cp tmp $f; rm tmp; echo -n .;
done}
end
desc 'Remove consecutive blank lines'
task :scrub_gratuitous_newlines do
sh %{find . -name '*.rb' -exec sed -i '' '/./,/^$/!d' {} \\;}
end
end