Sha256: 465af38b31f000e29422d2f785ba15f691950bc96d32e4892f20a2ab225c157c

Contents?: true

Size: 778 Bytes

Versions: 4

Compression:

Stored size: 778 Bytes

Contents

module Rake::Funnel::Support
  class Copier
    class << self
      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
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rake-funnel-0.3.2.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.3.1.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.3.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.2.0.pre lib/rake/funnel/support/copier.rb