Class: Ichiban::Deleter

Inherits:
Object
  • Object
show all
Defined in:
lib/ichiban/deleter.rb

Instance Method Summary collapse

Instance Method Details

#delete_dest(path) ⇒ Object

Deletes a file’s associated destination file, if any.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ichiban/deleter.rb', line 4

def delete_dest(path)
  file = Ichiban::ProjectFile.from_abs(path)
  # file will be nil if the path doesn't map to a known subclass of IchibanFile. Furthermore,
  # even if file is not nil, it may be a kind of IchibanFile that does not have a destination.
  if file and file.has_dest?
    dest = file.dest
  else
    dest = nil
  end
  if dest and File.exists?(dest)
    FileUtils.rm(dest)
  end

  # Log the deletion(s)
  Ichiban.logger.deletion(path, dest)
end