Skip to content

Instantly share code, notes, and snippets.

@Sixeight
Created July 8, 2014 04:22
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 Sixeight/f0c5a865672d1e8afa9d to your computer and use it in GitHub Desktop.
Save Sixeight/f0c5a865672d1e8afa9d to your computer and use it in GitHub Desktop.
delete trailing white space
Dir["app/**/*.rb"].each do |file|
File.open(file, "rb+") do |io|
result = []
body = io.read
body.split("\n").each do |line|
line.gsub!(/\s+\z/, "")
result << line
puts line
end
io.rewind
io.write result.join("\n")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment