Skip to content

Instantly share code, notes, and snippets.

@iMagesh
Forked from ashmoran/rake_strip_whitespace.rb
Created February 24, 2012 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iMagesh/1900995 to your computer and use it in GitHub Desktop.
Save iMagesh/1900995 to your computer and use it in GitHub Desktop.
Simple Rake task to use sed to strip trailing whitespace from Ruby source
desc "Remove trailing whitespace for source files"
task :strip_whitespace do
files = %w[ .autotest .rspec .rvmrc Gemfile ]
globs = %w[ lib/**/*.rb spec/**/*.rb ]
files_from_globs = globs.map { |glob| Dir[glob] }
files_to_strip = (files + files_from_globs).flatten
system "sed -e 's/[ \t]*$//' -i '' #{files_to_strip.join(" ")}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment