Created
June 5, 2010 03:02
-
-
Save guimello/426253 to your computer and use it in GitHub Desktop.
added reindent method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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