Module: TestBench::Session::Controls::Path::ApexDirectory::Remove

Defined in:
lib/test_bench/session/controls/path/apex_directory.rb

Class Method Summary collapse

Class Method Details

.call(apex_directory) ⇒ Object



43
44
45
# File 'lib/test_bench/session/controls/path/apex_directory.rb', line 43

def self.call(apex_directory)
  remove(apex_directory)
end

.remove(directory) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/test_bench/session/controls/path/apex_directory.rb', line 47

def self.remove(directory)
  ::Dir.each_child(directory) do |entry|
    absolute_path = ::File.expand_path(entry, directory)

    if ::File.directory?(absolute_path)
      subdirectory = absolute_path
      remove(subdirectory)
    else
      ::File.unlink(absolute_path)

      if ENV.fetch('DEBUG_PATH_CONTROLS', 'off') == 'on'
        warn "removed '#{absolute_path}'"
      end
    end
  end

  ::Dir.rmdir(directory)

  if ENV.fetch('DEBUG_PATH_CONTROLS', 'off') == 'on'
    warn "removed directory '#{directory}'"
  end
end