Class: Listen::Listener
- Inherits:
-
Object
- Object
- Listen::Listener
- Includes:
- FSM
- Defined in:
- lib/listen/listener.rb,
lib/listen/listener/config.rb
Defined Under Namespace
Classes: Config
Constant Summary
Constants included from FSM
Instance Attribute Summary
Attributes included from FSM
Instance Method Summary collapse
- #ignore(regexps) ⇒ Object
- #ignore!(regexps) ⇒ Object
-
#initialize(*dirs) {|modified, added, removed| ... } ⇒ Listener
constructor
Initializes the directories listener.
- #only(regexps) ⇒ Object
-
#pause ⇒ Object
Stops invoking callbacks (messages pile up).
- #paused? ⇒ Boolean
-
#processing? ⇒ Boolean
processing means callbacks are called.
-
#start ⇒ Object
Starts processing events and starts adapters or resumes invoking callbacks if paused.
-
#stop ⇒ Object
Stops both listening for events and processing them.
Methods included from FSM
included, #transition, #transition!
Constructor Details
#initialize(*dirs) {|modified, added, removed| ... } ⇒ Listener
Initializes the directories listener.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/listen/listener.rb', line 34 def initialize(*dirs, &block) = dirs.last.is_a?(Hash) ? dirs.pop : {} @config = Config.new() 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 |
Instance Method Details
#ignore(regexps) ⇒ Object
115 116 117 |
# File 'lib/listen/listener.rb', line 115 def ignore(regexps) @silencer_controller.append_ignores(regexps) end |
#ignore!(regexps) ⇒ Object
119 120 121 |
# File 'lib/listen/listener.rb', line 119 def ignore!(regexps) @silencer_controller.replace_with_bang_ignores(regexps) end |
#only(regexps) ⇒ Object
123 124 125 |
# File 'lib/listen/listener.rb', line 123 def only(regexps) @silencer_controller.replace_with_only(regexps) end |
#pause ⇒ Object
Stops invoking callbacks (messages pile up)
102 103 104 |
# File 'lib/listen/listener.rb', line 102 def pause transition :paused end |
#paused? ⇒ Boolean
111 112 113 |
# File 'lib/listen/listener.rb', line 111 def paused? state == :paused end |
#processing? ⇒ Boolean
processing means callbacks are called
107 108 109 |
# File 'lib/listen/listener.rb', line 107 def processing? state == :processing_events end |
#start ⇒ Object
Starts processing events and starts adapters or resumes invoking callbacks if paused
89 90 91 92 93 94 |
# File 'lib/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 ⇒ Object
Stops both listening for events and processing them
97 98 99 |
# File 'lib/listen/listener.rb', line 97 def stop transition :stopped end |