Class: Listen::Change
- Inherits:
-
Object
- Object
- Listen::Change
- Includes:
- Celluloid
- Defined in:
- lib/listen/change.rb
Instance Attribute Summary collapse
-
#listener ⇒ Object
Returns the value of attribute listener.
Instance Method Summary collapse
- #_log(type, message) ⇒ Object private
- #change(type, watched_dir, rel_path, options = {}) ⇒ Object
-
#initialize(listener) ⇒ Change
constructor
A new instance of Change.
Constructor Details
#initialize(listener) ⇒ Change
Returns a new instance of Change.
10 11 12 |
# File 'lib/listen/change.rb', line 10 def initialize(listener) @listener = listener end |
Instance Attribute Details
#listener ⇒ Object
Returns the value of attribute listener.
8 9 10 |
# File 'lib/listen/change.rb', line 8 def listener @listener end |
Instance Method Details
#_log(type, message) ⇒ Object (private)
54 55 56 |
# File 'lib/listen/change.rb', line 54 def _log(type, ) Celluloid.logger.send(type, ) end |
#change(type, watched_dir, rel_path, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/listen/change.rb', line 14 def change(type, watched_dir, rel_path, = {}) change = [:change] = [:cookie] if ! && listener.silencer.silenced?(Pathname(rel_path), type) _log :debug, "(silenced): #{rel_path.inspect}" return end path = watched_dir + rel_path log_details = [:silence] && 'recording' || change || 'unknown' _log :debug, "#{log_details}: #{type}:#{path} (#{options.inspect})" if change # TODO: move this to Listener to avoid Celluloid overhead # from caller = ? { cookie: } : {} listener.queue(type, change, watched_dir, rel_path, ) else return unless (record = listener.sync(:record)) if type == :dir return unless (change_queue = listener.async(:change_pool)) Directory.scan(change_queue, record, watched_dir, rel_path, ) else change = File.change(record, watched_dir, rel_path) return if !change || [:silence] listener.queue(:file, change, watched_dir, rel_path) end end rescue Celluloid::Task::TerminatedError _log :debug, "Change#change was terminated: #{$!.inspect}" rescue RuntimeError _log :error, "Change#change crashed #{$!.inspect}:#{[email protected]("\n")}" raise end |