Module: SassListen

Defined in:
lib/sass-listen/fsm.rb,
lib/sass-listen.rb,
lib/sass-listen/cli.rb,
lib/sass-listen/file.rb,
lib/sass-listen/change.rb,
lib/sass-listen/logger.rb,
lib/sass-listen/record.rb,
lib/sass-listen/adapter.rb,
lib/sass-listen/backend.rb,
lib/sass-listen/options.rb,
lib/sass-listen/version.rb,
lib/sass-listen/listener.rb,
lib/sass-listen/silencer.rb,
lib/sass-listen/directory.rb,
lib/sass-listen/event/loop.rb,
lib/sass-listen/adapter/bsd.rb,
lib/sass-listen/event/queue.rb,
lib/sass-listen/adapter/base.rb,
lib/sass-listen/event/config.rb,
lib/sass-listen/record/entry.rb,
lib/sass-listen/adapter/linux.rb,
lib/sass-listen/adapter/config.rb,
lib/sass-listen/adapter/darwin.rb,
lib/sass-listen/adapter/polling.rb,
lib/sass-listen/adapter/windows.rb,
lib/sass-listen/event/processor.rb,
lib/sass-listen/listener/config.rb,
lib/sass-listen/queue_optimizer.rb,
lib/sass-listen/silencer/controller.rb,
lib/sass-listen/internals/thread_pool.rb,
lib/sass-listen/record/symlink_detector.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 =
'4.0.0'

Class Method Summary collapse

Class Method Details

.loggerObject


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

def self.logger
  @logger ||= nil
end

.logger=(logger) ⇒ Object


6
7
8
# File 'lib/sass-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/sass-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


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/sass-listen.rb', line 43

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| ... } ⇒ SassListen::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:


34
35
36
37
38
39
# File 'lib/sass-listen.rb', line 34

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