Module: Listen::Adapter
- Defined in:
- lib/listen/adapter.rb,
lib/listen/adapter/bsd.rb,
lib/listen/adapter/base.rb,
lib/listen/adapter/linux.rb,
lib/listen/adapter/config.rb,
lib/listen/adapter/darwin.rb,
lib/listen/adapter/polling.rb,
lib/listen/adapter/windows.rb
Defined Under Namespace
Classes: BSD, Base, Config, Darwin, Linux, Polling, Windows
Constant Summary
collapse
- OPTIMIZED_ADAPTERS =
[Darwin, Linux, BSD, Windows].freeze
- POLLING_FALLBACK_MESSAGE =
'Listen will be polling for changes.'\
'Learn more at https://github.com/guard/listen#listen-adapters.'
Class Method Summary
collapse
Class Method Details
._usable_adapter_class ⇒ Object
33
34
35
|
# File 'lib/listen/adapter.rb', line 33
def _usable_adapter_class
OPTIMIZED_ADAPTERS.find(&:usable?)
end
|
._warn_polling_fallback(options) ⇒ Object
37
38
39
40
|
# File 'lib/listen/adapter.rb', line 37
def _warn_polling_fallback(options)
msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
Listen.adapter_warn("[Listen warning]:\n #{msg}") if msg
end
|
.select(options = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/listen/adapter.rb', line 17
def select(options = {})
Listen.logger.debug 'Adapter: considering polling ...'
return Polling if options[:force_polling]
Listen.logger.debug 'Adapter: considering optimized backend...'
return _usable_adapter_class if _usable_adapter_class
Listen.logger.debug 'Adapter: falling back to polling...'
_warn_polling_fallback(options)
Polling
rescue
Listen.logger.warn format('Adapter: failed: %s:%s', $ERROR_POSITION.inspect,
$ERROR_POSITION * "\n")
raise
end
|