Permalink
Browse files

Added documentation to gsub_file method

  • Loading branch information...
1 parent 1ea13fc commit 297276b99c2d14bcce2fd19f9ab3de75ea3dbc68 @andrewtimberlake andrewtimberlake committed with al2o3cr Dec 27, 2008
Showing with 7 additions and 1 deletion.
  1. +7 −1 railties/lib/rails_generator/generators/applications/app/template_runner.rb
@@ -359,6 +359,12 @@ def no?(question)
!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 @@ def destination_path(relative_destination)
File.join(root, relative_destination)
end
end
-end
+end

0 comments on commit 297276b

Please sign in to comment.