Method: Ing::Files#copy_file

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

#copy_file(source, *args, &block) ⇒ Object

Copies the file from the relative source to the relative destination. If the destination is not given it’s assumed to be equal to the source.

Parameters

source<String>

the relative path to the source root.

destination<String>

the relative path to the destination root.

config<Hash>

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

Examples

copy_file "README", "doc/README"

copy_file "doc/README"


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ing/actions/file_manipulation.rb', line 21

def copy_file(source, *args, &block)
  config = args.last.is_a?(Hash) ? args.pop : {}
  destination = args.first || source
  source = File.expand_path(find_in_source_paths(source.to_s))

  create_file destination, nil, config do
    content = File.binread(source)
    content = block.call(content) if block
    content
  end
end