module SassListen
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
Code copied from github.com/celluloid/celluloid-fsm
Constants
- VERSION
Public Class Methods
# File lib/sass-listen/logger.rb, line 2 def self.logger @logger ||= nil end
# File lib/sass-listen/logger.rb, line 6 def self.logger=(logger) @logger = logger end
# 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
This is used by the `listen` binary to handle Ctrl-C
# 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
Listens to file system modifications on a either single directory or multiple directories.
@param (see SassListen::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 [SassListen::Listener] the listener
# File lib/sass-listen.rb, line 34 def to(*args, &block) @listeners ||= [] Listener.new(*args, &block).tap do |listener| @listeners << listener end end