module MTBuild::Cleaner
Attributes
global_clean_list[R]
The list of files/folder to clean
Public Class Methods
generate_clean_task_for_project(project_name, project_clean_list)
click to toggle source
# File lib/mtbuild/cleaner.rb, line 19 def generate_clean_task_for_project(project_name, project_clean_list) desc "Remove intermediate and output files/folders for #{project_name}." task :clean do cleanup_files(project_clean_list) end end
generate_global_clean_task()
click to toggle source
# File lib/mtbuild/cleaner.rb, line 12 def generate_global_clean_task desc "Remove intermediate and output files/folders for all projects." task :clean do cleanup_files(@global_clean_list) end end
Private Class Methods
cant_be_deleted?(path_name)
click to toggle source
# File lib/mtbuild/cleaner.rb, line 56 def cant_be_deleted?(path_name) File.exist?(path_name) && (!File.readable?(path_name) || !File.executable?(path_name)) end
cleanup(file_name, opts={})
click to toggle source
# File lib/mtbuild/cleaner.rb, line 34 def cleanup(file_name, opts={}) begin Rake::FileUtilsExt.rm_r file_name, opts rescue StandardError => ex puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name) end end
cleanup_files(file_names)
click to toggle source
# File lib/mtbuild/cleaner.rb, line 28 def cleanup_files(file_names) file_names.each do |file_name| cleanup(file_name) end end
file_already_gone?(file_name)
click to toggle source
# File lib/mtbuild/cleaner.rb, line 42 def file_already_gone?(file_name) return false if File.exist?(file_name) path = file_name prev = nil while (path = File.dirname(path)) return false if cant_be_deleted?(path) break if [prev, "."].include?(path) prev = path end true end