Skip to content

Instantly share code, notes, and snippets.

@guimello
Created June 5, 2010 03:02
Show Gist options
  • Save guimello/426253 to your computer and use it in GitHub Desktop.
Save guimello/426253 to your computer and use it in GitHub Desktop.
added reindent method
class String
def reindent(by = 2)
self.gsub("\t", " " * by)
end
end
absolute_path = "/home/guimello/NetBeansProjects/ihouse"
dirs = ["#{absolute_path}/app/**", "#{absolute_path}/config/",
"#{absolute_path}/config/environments",
"#{absolute_path}/db/migrate", "#{absolute_path}/lib",
"#{absolute_path}/public/**"]
dirs.each do |dir|
Dir.glob("#{dir}/*.{rb,erb,js,css}") do |match|
next if match.split("/").last == "boot.rb"
lines = []
File.open(match, "r") do |file|
while line = file.gets
lines << line.reindent
end
end
File.open(match, "w") do |file|
lines.each {|l| file.write l}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment