module Listen::Adapter

Constants

OPTIMIZED_ADAPTERS
POLLING_FALLBACK_MESSAGE

Public Class Methods

select(options = {}) click to toggle source
# 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

Private Class Methods

_usable_adapter_class() click to toggle source
# File lib/listen/adapter.rb, line 33
def _usable_adapter_class
  OPTIMIZED_ADAPTERS.find(&:usable?)
end
_warn_polling_fallback(options) click to toggle source
# File lib/listen/adapter.rb, line 37
def _warn_polling_fallback(options)
  msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
  Kernel.warn "[Listen warning]:\n  #{msg}" if msg
end