Skip to content

Instantly share code, notes, and snippets.

@indirect
indirect / source.rake
Created June 13, 2012 06:56
rake tasks to remove trailing whitespace and tabs from your codebase
namespace :source do
def find_and_replace_in_source_files(find, replace)
puts "Search and replace #{find.inspect} => #{replace.inspect}"
files = %w[ .autotest .rspec .rvmrc Gemfile Procfile config.ru ].select{|f| File.exist?(f) }
directories = %w[app config lib public script spec test] # exclude bin, db, doc, log, and tmp
directories.each do |d|
files += Dir[File.join(d, "**/*.{rb,rake,haml,erb,builder,js,coffee,css,scss}")]
end