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 =
%w[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

._usable_adapter_classObject (private)



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

def self._usable_adapter_class
  adapters = OPTIMIZED_ADAPTERS.map { |adapter| Adapter.const_get(adapter) }
  adapters.detect { |adapter| adapter.send(:usable?) }
end

._warn_polling_fallback(options) ⇒ Object (private)



30
31
32
33
34
35
# File 'lib/listen/adapter.rb', line 30

def self._warn_polling_fallback(options)
  return if options[:polling_fallback_message] == false

  warning = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
  Kernel.warn "[Listen warning]:\n  #{warning}"
end

.select(options = {}) ⇒ Object



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

def self.select(options = {})
  return TCP if options[:force_tcp]
  return Polling if options[:force_polling]
  return _usable_adapter_class if _usable_adapter_class

  _warn_polling_fallback(options)
  Polling
end