class Rake::Funnel::Support::Copier

Public Class Methods

copy(files, target) click to toggle source
# File lib/rake/funnel/support/copier.rb, line 8
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

Private Class Methods

target_path(file, common_path, target) click to toggle source
# File lib/rake/funnel/support/copier.rb, line 26
def target_path(file, common_path, target)
  target_relative = Pathname.new(file).relative_path_from(Pathname.new(common_path)).to_s
  File.join(target, target_relative)
end