Module: Listen

Defined in:
lib/listen/error.rb,
lib/listen.rb,
lib/listen/cli.rb,
lib/listen/fsm.rb,
lib/listen/file.rb,
lib/listen/change.rb,
lib/listen/logger.rb,
lib/listen/record.rb,
lib/listen/thread.rb,
lib/listen/adapter.rb,
lib/listen/backend.rb,
lib/listen/options.rb,
lib/listen/version.rb,
lib/listen/listener.rb,
lib/listen/silencer.rb,
lib/listen/directory.rb,
lib/listen/event/loop.rb,
lib/listen/adapter/bsd.rb,
lib/listen/event/queue.rb,
lib/listen/adapter/base.rb,
lib/listen/event/config.rb,
lib/listen/record/entry.rb,
lib/listen/adapter/linux.rb,
lib/listen/adapter/config.rb,
lib/listen/adapter/darwin.rb,
lib/listen/monotonic_time.rb,
lib/listen/adapter/polling.rb,
lib/listen/adapter/windows.rb,
lib/listen/event/processor.rb,
lib/listen/listener/config.rb,
lib/listen/queue_optimizer.rb,
lib/listen/silencer/controller.rb,
lib/listen/record/symlink_detector.rb

Overview

Listener implementation for BSD's `kqueue`.

Defined Under Namespace

Modules: Adapter, Event, FSM, MonotonicTime, Thread Classes: Backend, CLI, Change, Directory, Error, File, Forwarder, Listener, Options, QueueOptimizer, Record, Silencer

Constant Summary collapse

VERSION =
'3.6.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject


12
13
14
# File 'lib/listen/logger.rb', line 12

def logger
  @logger ||= default_logger
end

Class Method Details

.stopObject

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


37
38
39
40
41
42
43
44
45
# 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) {|modified, added, removed| ... } ⇒ Listen::Listener

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

Yields:

  • (modified, added, removed)

    the changed files

Yield Parameters:

  • modified (Array<String>)

    the list of modified files

  • added (Array<String>)

    the list of added files

  • removed (Array<String>)

    the list of removed files

Returns:


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

def to(*args, &block)
  Listener.new(*args, &block).tap do |listener|
    @listeners.enq(WeakRef.new(listener))
  end
end