Created
July 20, 2013 09:30
-
-
Save Olefine/6044447 to your computer and use it in GitHub Desktop.
append something into middle of file
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
| def append_config_to_file | |
| tempfile = File.open("file.rb", 'w') | |
| f = File.new("config/application.rb") | |
| f.each do |line| | |
| tempfile << line | |
| if line.match(/class Application/) | |
| tempfile << " config.autoload_paths += %W(\#{config.root}/searches)\n" | |
| end | |
| end | |
| f.close | |
| tempfile.close | |
| FileUtils.mv("file.rb", "config/application.rb") | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment