module Thor::Actions

def prepend_file(path, data=nil, config={}, &block)


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

==== Example

config:: give :verbose => false to not log the status.
data:: the data to prepend to the file, can be also given as a block.
path:: path of the file to be changed
==== Parameters

Prepend text to a file.
def prepend_file(path, data=nil, config={}, &block)
  return unless behavior == :invoke
  path = File.expand_path(path, destination_root)
  say_status :prepend, relative_to_original_destination_root(path), config.fetch(:verbose, true)
  unless options[:pretend]
    content = data || block.call
    content << File.read(path)
    File.open(path, 'wb') { |file| file.write(content) }
  end
end