class Listen::Adapter::Darwin
Adapter
implementation for Mac OS X ‘FSEvents`.
Constants
- DEFAULTS
The default delay between checking for changes.
- INCOMPATIBLE_GEM_VERSION
- OS_REGEXP
Public Class Methods
usable?()
click to toggle source
# File lib/listen/adapter/darwin.rb, line 25 def self.usable? return false version = RbConfig::CONFIG['target_os'][OS_REGEXP, :major_version] return false unless version return true if version.to_i >= 13 # darwin13 is OS X 10.9 require 'rb-fsevent' fsevent_version = Gem::Version.new(FSEvent::VERSION) return true if fsevent_version <= Gem::Version.new('0.9.4') Kernel.warn INCOMPATIBLE_GEM_VERSION false end
Private Instance Methods
_configure(dir, &callback)
click to toggle source
# File lib/listen/adapter/darwin.rb, line 40 def _configure(dir, &callback) @callbacks[dir] = callback end
_process_changes(dirs)
click to toggle source
# File lib/listen/adapter/darwin.rb, line 53 def _process_changes(dirs) dirs.each do |dir| dir = Pathname.new(dir.sub(%r{/$}, '')) @callbacks.each do |watched_dir, callback| if watched_dir.eql?(dir) || Listen::Directory.ascendant_of?(watched_dir, dir) callback.call(dir) end end end end
_process_event(dir, path)
click to toggle source
# File lib/listen/adapter/darwin.rb, line 65 def _process_event(dir, path) Listen.logger.debug { "fsevent: processing path: #{path.inspect}" } # TODO: does this preserve symlinks? rel_path = path.relative_path_from(dir).to_s _queue_change(:dir, dir, rel_path, recursive: true) end
_run()
click to toggle source
# File lib/listen/adapter/darwin.rb, line 44 def _run require 'rb-fsevent' worker = FSEvent.new dirs_to_watch = @callbacks.keys.map(&:to_s) Listen.logger.info { "fsevent: watching: #{dirs_to_watch.inspect}" } worker.watch(dirs_to_watch, { latency: options.latency }, &method(:_process_changes)) @worker_thread = Listen::Thread.new("worker_thread") { worker.run } end
_stop()
click to toggle source
Calls superclass method
Listen::Adapter::Base#_stop
# File lib/listen/adapter/darwin.rb, line 72 def _stop @worker_thread&.kill super end