Module: Baltix::Actor::Copy

Defined in:
lib/baltix/actor/copy.rb

Defined Under Namespace

Classes: NoDestinationDirError, NoFileError, NoSourceDirError

Class Method Summary collapse

Class Method Details

.apply(context) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/baltix/actor/copy.rb', line 7

def apply context
   target_dir = context['target_dir'] || raise(NoDestinationDirError)
   source_dir = context['source_dir'] || raise(NoSourceDirError)
   file = context['file'] || raise(NoFileError)

   target_file = File.join(context['target_prefix'] || '', target_dir, file)
   source_file = File.join(source_dir, file)
   FileUtils.mkdir_p(File.dirname(target_file))
   FileUtils.cp(source_file, target_file)
   $stdout.puts "  #{source_file} => #{target_file}"
end