Method: Thor::Actions#uncomment_lines

Defined in:
lib/thor/actions/file_manipulation.rb

#uncomment_lines(path, flag, *args) ⇒ Object

Uncomment all lines matching a given regex. Preserves indentation before the comment hash and removes the hash and any immediate following space.

Parameters

path<String>

path of the file to be changed

flag<Regexp|String>

the regexp or string used to decide which lines to uncomment

config<Hash>

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

Example

uncomment_lines 'config/initializers/session_store.rb', /active_record/

289
290
291
292
293
# File 'lib/thor/actions/file_manipulation.rb', line 289

def uncomment_lines(path, flag, *args)
  flag = flag.respond_to?(:source) ? flag.source : flag

  gsub_file(path, /^(\s*)#[[:blank:]]?(.*#{flag})/, '\1\2', *args)
end