Skip to content

Instantly share code, notes, and snippets.

@arbaaz
Forked from jhjguxin/replace_words.rb
Last active August 29, 2015 14:14
Show Gist options
  • Save arbaaz/52b1a3d1e800977678b4 to your computer and use it in GitHub Desktop.
Save arbaaz/52b1a3d1e800977678b4 to your computer and use it in GitHub Desktop.
# http://stackoverflow.com/questions/4397412/read-edit-and-write-a-text-file-line-wise-using-ruby
# files = Dir.glob(File.dirname(__FILE__)+"/../app/**/*.rb")
files = Dir[Rails.root.join("app", "**/*.rb")]
files.each do |f_name|
# puts f_name
File.open(f_name, "r+") do |f|
old_pos = 0
f.each do |line|
f.pos = old_pos # this is the 'rewind'
f.print line.gsub(/GxUserContacts/, "GxUserContact")
old_pos = f.pos
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment