Module: Driskell::Listen

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

Overview

Listener implementation for BSD’s ‘kqueue`.

Defined Under Namespace

Modules: Adapter, Event, FSM, Internals Classes: Backend, CLI, Change, Directory, File, Forwarder, Listener, Logger, Options, QueueOptimizer, Record, Silencer

Constant Summary collapse

VERSION =
'3.0.6.11'

Class Method Summary collapse

Class Method Details

.loggerObject



2
3
4
# File 'lib/driskell-listen/logger.rb', line 2

def self.logger
  @logger ||= nil
end

.logger=(logger) ⇒ Object



6
7
8
# File 'lib/driskell-listen/logger.rb', line 6

def self.logger=(logger)
  @logger = logger
end

.setup_default_logger_if_unsetObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/driskell-listen/logger.rb', line 10

def self.setup_default_logger_if_unset
  self.logger ||= ::Logger.new(STDERR).tap do |logger|
    debugging = ENV['LISTEN_GEM_DEBUGGING']
    logger.level =
      case debugging.to_s
      when /2/
        ::Logger::DEBUG
      when /true|yes|1/i
        ::Logger::INFO
      else
        ::Logger::ERROR
      end
  end
end

.stopObject

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



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/driskell-listen.rb', line 49

def stop
  Internals::ThreadPool.stop
  @listeners ||= []

  # TODO: should use a mutex for this
  @listeners.each do |listener|
    # call stop to halt the main loop
    listener.stop
  end
  @listeners = nil
end

.to(*args) {|modified, added, removed| ... } ⇒ Driskell::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:



40
41
42
43
44
45
# File 'lib/driskell-listen.rb', line 40

def to(*args, &block)
  @listeners ||= []
  Listener.new(*args, &block).tap do |listener|
    @listeners << listener
  end
end