Skip to content

Instantly share code, notes, and snippets.

@ashmoran
Created March 20, 2011 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ashmoran/878743 to your computer and use it in GitHub Desktop.
Save ashmoran/878743 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