Sha256: dabb0acbdf2ed424ab96c2ddf7243e5afd438c6dbbd8be8f815d4ac9819ad2b5

Contents?: true

Size: 859 Bytes

Versions: 18

Compression:

Stored size: 859 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

18 entries across 18 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/support/copier.rb
rake-funnel-0.17.0 lib/rake/funnel/support/copier.rb
rake-funnel-0.16.1 lib/rake/funnel/support/copier.rb
rake-funnel-0.16.0 lib/rake/funnel/support/copier.rb
rake-funnel-0.15.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.14.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.13.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.12.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.11.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.10.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.9.1.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.9.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.8.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.7.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.6.1.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.6.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.5.0.pre lib/rake/funnel/support/copier.rb
rake-funnel-0.4.0.pre lib/rake/funnel/support/copier.rb