method

gsub_file

ruby latest stable - Class: Bundler::Thor::Actions

Method not available on this version

This method is only available on newer versions. The first available version (v2_6_3) is shown here.

gsub_file(path, flag, *args, &block)
public

Run a regular expression replacement on a file.

Parameters

path

path of the file to be changed

flag<Regexp|String>

the regexp or string to be replaced

replacement

the replacement, can be also given as a block

config

give :verbose => false to not log the status.

Example

gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'

gsub_file 'README', /rake/, :green do |match|
  match << " no more. Use thor!"
end