Class: Listen::Record::SymlinkDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/listen/record/symlink_detector.rb

Constant Summary collapse

README_URL =
'https://github.com/guard/listen/blob/master/README.md'
<<-EOS.freeze
  ** ERROR: directory is already being watched! **

  Directory: %s

  is already being watched through: %s

  MORE INFO: #{README_URL}
EOS
Error =

for backward compatibility

::Listen::Error

Instance Method Summary collapse

Constructor Details

#initializeSymlinkDetector

Returns a new instance of SymlinkDetector.



24
25
26
# File 'lib/listen/record/symlink_detector.rb', line 24

def initialize
  @real_dirs = Set.new
end

Instance Method Details

#_fail(symlinked, real_path) ⇒ Object (private)



41
42
43
44
# File 'lib/listen/record/symlink_detector.rb', line 41

def _fail(symlinked, real_path)
  warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path))
  raise ::Listen::Error::SymlinkLoop, 'Failed due to looped symlinks'
end

#verify_unwatched!(entry) ⇒ Object



28
29
30
31
# File 'lib/listen/record/symlink_detector.rb', line 28

def verify_unwatched!(entry)
  real_path = entry.real_path
  @real_dirs.add?(real_path) or _fail(entry.sys_path, real_path)
end

#warn(message) ⇒ Object

Leaving this stub here since some warning work-arounds were referring to it. Deprecated. Will be removed in Listen v4.0.



35
36
37
# File 'lib/listen/record/symlink_detector.rb', line 35

def warn(message)
  Listen.adapter_warn(message)
end