Module: Filander::CopyDirectory

Includes:
Base
Included in:
Filander
Defined in:
lib/filander/actions/copy_directory.rb

Instance Method Summary collapse

Methods included from Base

#create_directory_for, #entries, #join_destination, #join_source, #report, #with_report

Instance Method Details

#copy_directory(source, destination = source) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/filander/actions/copy_directory.rb', line 5

def copy_directory(source, destination = source)
  create_directory_for destination
  filename = join_source(source)
  raise "Source file `#{filename}' does not exist" if !File.exists?(filename) && Filander.behavior != :pretend

  dest = join_destination(destination)
  with_report destination, entries(filename) do
    FileUtils.rm_rf dest
    FileUtils.cp_r filename, dest
  end
end