Sha256: b3b69f977d2d5b3697a79d0516e8a02e725bd9fb11dcbb19b97960d8772acc37
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
require 'rake/clean' require 'rake/tasklib' module Rake::Funnel::Tasks class Copy < Rake::TaskLib attr_accessor :name, :source, :target def initialize(name = :copy) @name = name @source = [] @target = nil yield self if block_given? define end private def define target && CLEAN.include(target) desc "Copy #{files.join(', ')} to #{target}" task name do raise 'Target not defined' unless target files.each do |source| next if File.directory?(source) target = target_path(source) dir = File.dirname(target) RakeFileUtils.mkdir_p(dir) unless File.directory?(dir) RakeFileUtils.cp(source, target, { preserve: true}) end end self end def files Rake::Funnel::Support::Finder.new(source, self, 'No files found.').all_or_default end def target_path(file) target_relative = Pathname.new(file).relative_path_from(Pathname.new(common_path)).to_s File.join(target, target_relative) end def common_path @common_path ||= files.common_path end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rake-funnel-0.0.6.pre | lib/rake/funnel/tasks/copy.rb |
rake-funnel-0.0.5.pre | lib/rake/funnel/tasks/copy.rb |