class Guard::Polling


file IO that the other implementations.
uses the most CPU processing power and has higher
has no dependencies. This is the listener that
Polling listener that works cross-platform and

def initialize(*)


Initialize the Listener.
def initialize(*)
  super
  @latency = 1.5
end

def start


Start the listener.
def start
  @stop = false
  super
  watch_change
end

def stop


Stop the listener.
def stop
  super
  @stop = true
end

def watch(directory)

Parameters:
  • directory (String) -- the directory to watch
def watch(directory)
  @existing = all_files
end

def watch_change


Watch for file system changes.
def watch_change
  until @stop
    start = Time.now.to_f
    files = modified_files([@directory], :all => true)
    @callback.call(files) unless files.empty?
    nap_time = @latency - (Time.now.to_f - start)
    sleep(nap_time) if nap_time > 0
  end
end