123456789_123456789_123456789_123456789_123456789_

Module: Rake::Cleaner

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::FileUtils
Defined in: lib/rake/clean.rb

Class Method Summary

::FileUtils - Extended

ruby

Run a Ruby interpreter with the given arguments.

safe_ln

Attempt to do a normal file link, but fall back to a copy if the link fails.

sh

Run the system command cmd.

split_all

Split a file path into individual directory names.

create_shell_runner, set_verbose_option, sh_show_command

Class Method Details

.cant_be_deleted?(path_name) ⇒ Boolean (private, mod_func)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rake/clean.rb', line 55

def cant_be_deleted?(path_name)
  File.exist?(path_name) &&
    (!File.readable?(path_name) || !File.executable?(path_name))
end

.cleanup(file_name, **opts) (mod_func)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rake/clean.rb', line 31

def cleanup(file_name, **opts)
  begin
    opts = { verbose: Rake.application.options.trace }.merge(opts)
    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) (mod_func)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rake/clean.rb', line 25

def cleanup_files(file_names)
  file_names.each do |file_name|
    cleanup(file_name)
  end
end

.file_already_gone?(file_name) ⇒ Boolean (private, mod_func)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rake/clean.rb', line 40

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