Improve whitespace:cleanup and whitespace:retab
This commit is contained in:
parent
6ffc03a4c9
commit
d8c497177f
1 changed files with 6 additions and 3 deletions
|
|
@ -1,15 +1,18 @@
|
||||||
namespace :whitespace do
|
namespace :whitespace do
|
||||||
desc 'Removes trailing whitespace'
|
desc 'Removes trailing whitespace'
|
||||||
task :cleanup do
|
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
|
end
|
||||||
desc 'Converts hard-tabs into two-space soft-tabs'
|
desc 'Converts hard-tabs into two-space soft-tabs'
|
||||||
task :retab do
|
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
|
end
|
||||||
desc 'Remove consecutive blank lines'
|
desc 'Remove consecutive blank lines'
|
||||||
task :scrub_gratuitous_newlines do
|
task :scrub_gratuitous_newlines do
|
||||||
sh %{find . -name '*.rb' -exec sed -i '' '/./,/^$/!d' {} \\;}
|
sh %{find . -name '*.rb' -exec sed -i '' '/./,/^$/!d' {} \\;}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue