diff options
author | José Valim <jose.valim@gmail.com> | 2009-06-28 16:48:22 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-06-28 16:48:22 +0200 |
commit | a2d4d755ae1b69455e515ad8a4fa363ccee8a790 (patch) | |
tree | c54c9fb61e612e5036e8ac368012ce6b9a190b26 /railties | |
parent | 1ca51df0001a750fafb0da70e4560c1ec439236c (diff) | |
download | rails-a2d4d755ae1b69455e515ad8a4fa363ccee8a790.tar.gz rails-a2d4d755ae1b69455e515ad8a4fa363ccee8a790.tar.bz2 rails-a2d4d755ae1b69455e515ad8a4fa363ccee8a790.zip |
Use inject_into_file instead of gsub_file (the first is reversible)
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/generators/actions.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/railties/lib/generators/actions.rb b/railties/lib/generators/actions.rb index ee4fe7183f..f0d630e15a 100644 --- a/railties/lib/generators/actions.rb +++ b/railties/lib/generators/actions.rb @@ -77,15 +77,13 @@ module Rails # file in config/environments. # def environment(data=nil, options={}, &block) - sentinel = 'Rails::Initializer.run do |config|' + sentinel = "Rails::Initializer.run do |config|" data = block.call if !data && block_given? in_root do if options[:env].nil? - gsub_file 'config/environment.rb', /(#{Regexp.escape(sentinel)})/mi, false do |match| - "#{match}\n " << data - end + inject_into_file 'config/environment.rb', "\n #{data}", { :after => sentinel }, false else Array.wrap(options[:env]).each do|env| append_file "config/environments/#{env}.rb", "\n#{data}", false @@ -251,12 +249,10 @@ module Rails # def route(routing_code) log :route, routing_code - sentinel = 'ActionController::Routing::Routes.draw do |map|' + sentinel = "ActionController::Routing::Routes.draw do |map|" in_root do - gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi, false do |match| - "#{match}\n #{routing_code}\n" - end + inject_into_file 'config/routes.rb', "\n #{routing_code}", { :after => sentinel }, false end end |