Method: Thor::Actions#append_file

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

#append_file(path, *args, &block) ⇒ Object

Append text to a file. Since it depends on inject_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_file 'config/environments/test.rb', 'config.gem "rspec"'

append_file 'config/environments/test.rb' do
  'config.gem "rspec"'
end


149
150
151
152
153
# File 'lib/wip/vendor/thor/actions/file_manipulation.rb', line 149

def append_file(path, *args, &block)
  config = args.last.is_a?(Hash) ? args.pop : {}
  config.merge!(:before => /\z/)
  inject_into_file(path, *(args << config), &block)
end