module Listen

Listener implementation for BSD’s ‘kqueue`. @see www.freebsd.org/cgi/man.cgi?query=kqueue @see github.com/mat813/rb-kqueue/blob/master/lib/rb-kqueue/queue.rb

This class just aggregates configuration object to avoid Listener specs from exploding with huge test setup blocks

Besides programming error exceptions like ArgumentError, all public interface exceptions should be declared here and inherit from Listen::Error.

Constants

VERSION

Attributes

logger[W]

Public Class Methods

logger() click to toggle source
# File lib/listen/logger.rb, line 12
def logger
  @logger ||= default_logger
end
stop() click to toggle source

This is used by the ‘listen` binary to handle Ctrl-C

# File lib/listen.rb, line 37
def stop
  while (listener = @listeners.deq(true))
    begin
      listener.stop
    rescue WeakRef::RefError
    end
  end
rescue ThreadError
end
to(*args, &block) click to toggle source

Listens to file system modifications on a either single directory or multiple directories.

@param (see Listen::Listener#new)

@yield [modified, added, removed] the changed files @yieldparam [Array<String>] modified the list of modified files @yieldparam [Array<String>] added the list of added files @yieldparam [Array<String>] removed the list of removed files

@return [Listen::Listener] the listener

# File lib/listen.rb, line 29
def to(*args, &block)
  Listener.new(*args, &block).tap do |listener|
    @listeners.enq(WeakRef.new(listener))
  end
end

Private Class Methods

default_logger() click to toggle source
# File lib/listen/logger.rb, line 18
def default_logger
  level =
    case ENV['LISTEN_GEM_DEBUGGING'].to_s
    when /debug|2/i
      ::Logger::DEBUG
    when /info|true|yes|1/i
      ::Logger::INFO
    when /warn/i
      ::Logger::WARN
    when /fatal/i
      ::Logger::FATAL
    else
      ::Logger::ERROR
    end

  ::Logger.new(STDERR, level: level)
end