Class: Listen::Adapters::Darwin

Inherits:
Listen::Adapter show all
Defined in:
lib/listen/adapters/darwin.rb

Overview

Adapter implementation for Mac OS X ‘FSEvents`.

Constant Summary

Constants inherited from Listen::Adapter

Listen::Adapter::DEFAULT_LATENCY, Listen::Adapter::POLLING_FALLBACK_MESSAGE

Instance Attribute Summary

Attributes inherited from Listen::Adapter

#latency

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Listen::Adapter

select_and_initialize

Constructor Details

#initialize(directory, options = {}, &callback) ⇒ Darwin

Initialize the Adapter. See Listen::Adapter#initialize for more info.



10
11
12
13
# File 'lib/listen/adapters/darwin.rb', line 10

def initialize(directory, options = {}, &callback)
  super
  init_worker
end

Class Method Details

.usable?Boolean

Check if the adapter is usable on the current OS.

Returns:

  • (Boolean)

    whether usable or not



33
34
35
36
37
38
39
40
# File 'lib/listen/adapters/darwin.rb', line 33

def self.usable?
  return false unless RbConfig::CONFIG['target_os'] =~ /darwin(1.+)?$/i

  require 'rb-fsevent'
  true
rescue LoadError
  false
end

Instance Method Details

#startObject

Start the adapter.



17
18
19
20
# File 'lib/listen/adapters/darwin.rb', line 17

def start
  super
  @worker.run
end

#stopObject

Stop the adapter.



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

def stop
  super
  @worker.stop
end