Added documentation to gsub_file method

This commit is contained in:
Andrew Timberlake
2008-12-27 18:29:40 +02:00
committed by Matt Jones
parent 1ea13fce1a
commit 297276b99c

View File

@@ -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
end