Class: EcoRake::Lib::Files::Purge

Inherits:
BaseTask show all
Defined in:
lib/eco-rake/lib/files/purge.rb

Constant Summary

Constants inherited from EcoRake

VERSION

Instance Method Summary collapse

Instance Method Details

#task(*_args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/eco-rake/lib/files/purge.rb', line 13

def task(*_args)
  if target_files.empty?
    puts "There were no files in folder '#{source_folder}' to be #{str_op}"
  elsif options[:list]
    msg  = "#{target_files.count} target log files (from '#{source_folder}') will be #{str_op}"
    msg << " to '#{dest_folder}':" unless remove?
    puts msg
    target_files.each {|file| puts "#{File.basename(file)}"}
  elsif options[:remove]
    delete_file(*target_files, message: "Removing the following #{target_files.count} files from '#{source_folder}':")
  else
    ensure_dest_folder!
    msg = "Moving #{target_files.count} log files from '#{source_folder}' to the '#{dest_folder}' folder:"
    move_file(*target_files, folder: dest_folder, message: msg)
  end
end