Module: Listen::Adapter
- Defined in:
- lib/listen/adapter.rb,
lib/listen/adapter/bsd.rb,
lib/listen/adapter/tcp.rb,
lib/listen/adapter/base.rb,
lib/listen/adapter/linux.rb,
lib/listen/adapter/darwin.rb,
lib/listen/adapter/polling.rb,
lib/listen/adapter/windows.rb
Defined Under Namespace
Classes: BSD, Base, Darwin, Linux, Polling, TCP, Windows
Constant Summary
collapse
- OPTIMIZED_ADAPTERS =
[Darwin, Linux, BSD, Windows]
- POLLING_FALLBACK_MESSAGE =
'Listen will be polling for changes.'\
'Learn more at https://github.com/guard/listen#polling-fallback.'
Class Method Summary
collapse
Class Method Details
._log(type, message) ⇒ Object
40
41
42
|
# File 'lib/listen/adapter.rb', line 40
def self._log(type, message)
Celluloid.logger.send(type, message)
end
|
._usable_adapter_class ⇒ Object
31
32
33
|
# File 'lib/listen/adapter.rb', line 31
def self._usable_adapter_class
OPTIMIZED_ADAPTERS.detect(&:usable?)
end
|
._warn_polling_fallback(options) ⇒ Object
35
36
37
38
|
# File 'lib/listen/adapter.rb', line 35
def self._warn_polling_fallback(options)
msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
Kernel.warn "[Listen warning]:\n #{msg}" if msg
end
|
.select(options = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/listen/adapter.rb', line 14
def self.select(options = {})
_log :debug, 'Adapter: considering TCP ...'
return TCP if options[:force_tcp]
_log :debug, 'Adapter: considering polling ...'
return Polling if options[:force_polling]
_log :debug, 'Adapter: considering optimized backend...'
return _usable_adapter_class if _usable_adapter_class
_log :debug, 'Adapter: falling back to polling...'
_warn_polling_fallback(options)
Polling
rescue
_log :warn, "Adapter: failed: #{$!.inspect}:#{$@.join("\n")}"
raise
end
|