class Driskell::Listen::Listener

Attributes

backend[R]
processor[R]

Public Class Methods

new(*dirs, &block) click to toggle source

Initializes the directories listener.

@param [String] directory the directories to listen to @param [Hash] options the listen options (see Driskell::Listen::Listener::Options)

@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

Calls superclass method Driskell::Listen::FSM::new
# File lib/driskell-listen/listener.rb, line 34
def initialize(*dirs, &block)
  options = dirs.last.is_a?(Hash) ? dirs.pop : {}

  @config = Config.new(options)

  eq_config = Event::Queue::Config.new(@config.relative?)
  queue = Event::Queue.new(eq_config) { @processor.wakeup_on_event }

  silencer = Silencer.new
  rules = @config.silencer_rules
  @silencer_controller = Silencer::Controller.new(silencer, rules)

  @backend = Backend.new(dirs, queue, silencer, @config)

  optimizer_config = QueueOptimizer::Config.new(@backend, silencer)

  pconfig = Event::Config.new(
    self,
    queue,
    QueueOptimizer.new(optimizer_config),
    @backend.min_delay_between_events,
    &block)

  @processor = Event::Loop.new(pconfig)

  super() # FSM
end

Public Instance Methods

ignore(regexps) click to toggle source
# File lib/driskell-listen/listener.rb, line 115
def ignore(regexps)
  @silencer_controller.append_ignores(regexps)
end
ignore!(regexps) click to toggle source
# File lib/driskell-listen/listener.rb, line 119
def ignore!(regexps)
  @silencer_controller.replace_with_bang_ignores(regexps)
end
only(regexps) click to toggle source
# File lib/driskell-listen/listener.rb, line 123
def only(regexps)
  @silencer_controller.replace_with_only(regexps)
end
pause() click to toggle source

Stops invoking callbacks (messages pile up)

# File lib/driskell-listen/listener.rb, line 102
def pause
  transition :paused
end
paused?() click to toggle source
# File lib/driskell-listen/listener.rb, line 111
def paused?
  state == :paused
end
processing?() click to toggle source

processing means callbacks are called

# File lib/driskell-listen/listener.rb, line 107
def processing?
  state == :processing_events
end
start() click to toggle source

Starts processing events and starts adapters or resumes invoking callbacks if paused

# File lib/driskell-listen/listener.rb, line 89
def start
  transition :backend_started if state == :initializing
  transition :frontend_ready if state == :backend_started
  transition :processing_events if state == :frontend_ready
  transition :processing_events if state == :paused
end
stop() click to toggle source

Stops both listening for events and processing them

# File lib/driskell-listen/listener.rb, line 97
def stop
  transition :stopped
end