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/darwin.rb,
lib/listen/adapter/polling.rb,
lib/listen/adapter/windows.rb

Defined Under Namespace

Classes: BSD, Base, Darwin, Linux, Polling, 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)



23
24
25
26
# File 'lib/listen/adapter.rb', line 23

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)



28
29
30
31
32
33
# File 'lib/listen/adapter.rb', line 28

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



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

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

  _warn_polling_fallback(options)
  Polling
end