Method: Thor::Actions#append_to_file

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

#append_to_file(path, *args, &block) ⇒ Object Also known as: append_file

Append text to a file. Since it depends on insert_into_file, it’s reversible.

Parameters

path<String>

path of the file to be changed

data<String>

the data to append to the file, can be also given as a block.

config<Hash>

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

Example

append_to_file 'config/environments/test.rb', 'config.gem "rspec"'

append_to_file 'config/environments/test.rb' do
  'config.gem "rspec"'
end
[View source]

192
193
194
195
196
# File 'lib/thor/actions/file_manipulation.rb', line 192

def append_to_file(path, *args, &block)
  config = args.last.is_a?(Hash) ? args.pop : {}
  config[:before] = /\z/
  insert_into_file(path, *(args << config), &block)
end