Module: Listen
- Defined in:
- lib/listen/adapter/bsd.rb,
lib/listen.rb,
lib/listen/cli.rb,
lib/listen/file.rb,
lib/listen/change.rb,
lib/listen/record.rb,
lib/listen/adapter.rb,
lib/listen/options.rb,
lib/listen/version.rb,
lib/listen/listener.rb,
lib/listen/silencer.rb,
lib/listen/directory.rb,
lib/listen/adapter/tcp.rb,
lib/listen/tcp/message.rb,
lib/listen/adapter/base.rb,
lib/listen/adapter/linux.rb,
lib/listen/adapter/darwin.rb,
lib/listen/adapter/polling.rb,
lib/listen/adapter/windows.rb,
lib/listen/queue_optimizer.rb,
lib/listen/tcp/broadcaster.rb
Overview
Listener implementation for BSD's kqueue
.
Defined Under Namespace
Modules: Adapter, QueueOptimizer, TCP Classes: CLI, Change, Directory, File, Forwarder, Listener, Options, Record, Silencer
Constant Summary collapse
- VERSION =
'2.7.9'
Class Method Summary collapse
- ._add_listener(*args, &block) ⇒ Object private
-
.on(target, *args) {|modified, added, removed| ... } ⇒ Listen::Listener
Listens to file system modifications broadcast over TCP.
-
.stop ⇒ Object
Stop all listeners & Celluloid.
-
.to(*args) {|modified, added, removed| ... } ⇒ Listen::Listener
Listens to file system modifications on a either single directory or multiple directories.
Class Method Details
._add_listener(*args, &block) ⇒ Object (private)
68 69 70 71 72 73 |
# File 'lib/listen.rb', line 68 def _add_listener(*args, &block) @listeners ||= [] Listener.new(*args, &block).tap do |listener| @listeners << listener end end |
.on(target, *args) {|modified, added, removed| ... } ⇒ Listen::Listener
Listens to file system modifications broadcast over TCP.
62 63 64 |
# File 'lib/listen.rb', line 62 def on(target, *args, &block) _add_listener(target, :recipient, *args, &block) end |
.stop ⇒ Object
Stop all listeners & Celluloid
Use it for testing purpose or when you are sure that Celluloid could be ended.
This is used by the listen
binary to handle Ctrl-C
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/listen.rb', line 38 def 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 Celluloid.shutdown end |
.to(*args) {|modified, added, removed| ... } ⇒ Listen::Listener
Listens to file system modifications on a either single directory or multiple directories.
When :forward_to is specified, this listener will broadcast modifications over TCP.
21 22 23 24 25 26 27 28 29 |
# File 'lib/listen.rb', line 21 def to(*args, &block) Celluloid.boot unless Celluloid.running? = args.last.is_a?(Hash) ? args.last : {} if target = .delete(:forward_to) _add_listener(target, :broadcaster, *args, &block) else _add_listener(*args, &block) end end |