From 297276b99c2d14bcce2fd19f9ab3de75ea3dbc68 Mon Sep 17 00:00:00 2001 From: Andrew Timberlake Date: Sat, 27 Dec 2008 18:29:40 +0200 Subject: Added documentation to gsub_file method --- .../generators/applications/app/template_runner.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/railties/lib/rails_generator/generators/applications/app/template_runner.rb b/railties/lib/rails_generator/generators/applications/app/template_runner.rb index c6113648e6..1e0c6cc3ff 100644 --- a/railties/lib/rails_generator/generators/applications/app/template_runner.rb +++ b/railties/lib/rails_generator/generators/applications/app/template_runner.rb @@ -359,6 +359,12 @@ module Rails !yes?(question) end + # Run a regular expression replacement on a file + # + # ==== Example + # + # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' + # def gsub_file(relative_destination, regexp, *args, &block) path = destination_path(relative_destination) content = File.read(path).gsub(regexp, *args, &block) @@ -369,4 +375,4 @@ module Rails File.join(root, relative_destination) end end -end \ No newline at end of file +end -- cgit v1.2.3