Sha256: 25a1275b0c52e977aa4e3391ba66028b47533f0fb4994bec25095d36ae2ac35a

Contents?: true

Size: 860 Bytes

Versions: 10

Compression:

Stored size: 860 Bytes

Contents

module Rake
  module Funnel
    module 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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rake-funnel-0.22.2 lib/rake/funnel/support/copier.rb
rake-funnel-0.22.1 lib/rake/funnel/support/copier.rb
rake-funnel-0.22.0 lib/rake/funnel/support/copier.rb
rake-funnel-0.21.2 lib/rake/funnel/support/copier.rb
rake-funnel-0.21.1 lib/rake/funnel/support/copier.rb
rake-funnel-0.21.0 lib/rake/funnel/support/copier.rb
rake-funnel-0.20.2 lib/rake/funnel/support/copier.rb
rake-funnel-0.20.1 lib/rake/funnel/support/copier.rb
rake-funnel-0.20.0 lib/rake/funnel/support/copier.rb
rake-funnel-0.19.0 lib/rake/funnel/support/copier.rb