Class: Rake::Funnel::Support::Copier

Inherits:
Object
  • Object
show all
Defined in:
lib/rake/funnel/support/copier.rb

Class Method Summary collapse

Class Method Details

.copy(files, target) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rake/funnel/support/copier.rb', line 6

def copy(files, target)
  raise 'Target not defined' unless target

  common_path = files.common_path
  files.each do |source|
    next if File.directory?(source)

    target_path = target_path(source, common_path, target)

    dir = File.dirname(target_path)
    RakeFileUtils.mkdir_p(dir) unless File.directory?(dir)

    RakeFileUtils.cp(source, target_path, preserve: true)
  end
end