Class: Listen::Adapter::Darwin

Inherits:
Base
  • Object
show all
Defined in:
lib/listen/adapter/darwin.rb

Overview

Adapter implementation for Mac OS X FSEvents.

Constant Summary collapse

OS_REGEXP =
/darwin(1.+)?$/i
DEFAULT_LATENCY =

The default delay between checking for changes.

0.1

Instance Attribute Summary

Attributes inherited from Base

#listener

Instance Method Summary collapse

Methods inherited from Base

#_directories, #_log, #_notify_change, #initialize, local_fs?, #start, usable?

Constructor Details

This class inherits a constructor from Listen::Adapter::Base

Instance Method Details

#_configureObject (private)



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/listen/adapter/darwin.rb', line 13

def _configure
  require 'rb-fsevent'
  @worker = FSEvent.new
  @worker.watch(_directories.map(&:to_s), latency: _latency) do |changes|
    changes.each do |path|
      new_path = Pathname.new(path.sub(/\/$/, ''))
      _log :debug, "fsevent: #{new_path}"
      _notify_change(:dir, new_path)
    end
  end
end

#_latencyObject (private)



29
30
31
# File 'lib/listen/adapter/darwin.rb', line 29

def _latency
  listener.options[:latency] || DEFAULT_LATENCY
end

#_runObject (private)



25
26
27
# File 'lib/listen/adapter/darwin.rb', line 25

def _run
  @worker.run
end