Method: ASRake::FileUtilsExt#cp_u
- Defined in:
- lib/asrake/file_utils.rb
#cp_u(src, dest, options = {}) ⇒ Object
Copies files recursivly only if they don’t exist at the destination or the destination files are older.
There are two possible ways to copy, multiple files, or a single file
-
Copying multiple files Examples:
-
‘cp_u FileList, “/dest”`
-
‘cp_u %w/path/src2, “/dest”`
-
‘cp_u /path/to/src/, “/dest”`
An error will be thrown if the destination already exists and is not a directory.
-
-
Copying a single file For example, copying file “src”
-
If destination is, or is infered to be, a directory, the src file is copied to an identically named file at the destination directory ‘cp_u /path/src, /path/dest/` `cp_u /path/src, /path/dest` <- dest is an existing directory
-
If destination is, or is infered to be, a file, the src file is copied and renamed to the destination file ‘cp_u /path/src, /path/dest` <- dest does not exist or is a file
-
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/asrake/file_utils.rb', line 28 def cp_u(src, dest, = {}) if tmp = Array.try_convert(src) tmp.each do |s| copy_files(s, File.join(dest, File.basename(s)), ) end else copy_files(src, dest, ) end #puts "Files copied. #{src} => #{dest}" end |