Class: Librr::DirMonitor::DirWatcher
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Librr::DirMonitor::DirWatcher
- Includes:
- Logger::ClassLogger
- Defined in:
- lib/librr/dir_monitor.rb
Instance Method Summary collapse
-
#initialize(monitor) ⇒ DirWatcher
constructor
A new instance of DirWatcher.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Methods included from Logger::ClassLogger
Constructor Details
#initialize(monitor) ⇒ DirWatcher
Returns a new instance of DirWatcher.
90 91 92 93 |
# File 'lib/librr/dir_monitor.rb', line 90 def initialize(monitor) super @monitor = monitor end |
Instance Method Details
#post_init ⇒ Object
95 96 97 |
# File 'lib/librr/dir_monitor.rb', line 95 def post_init @monitor.post_init end |
#receive_data(data) ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/librr/dir_monitor.rb', line 99 def receive_data data self.debug "on receive data: #{data}" changes = data.strip.split(':').map(&:strip).reject{|s| s == ''} changes.each do |file| @monitor.indexer.index_file(file) end end |
#unbind ⇒ Object
107 108 109 110 111 |
# File 'lib/librr/dir_monitor.rb', line 107 def unbind self.debug "dir monitor process stopped." @monitor.after_process_stop File.delete Librr::DirMonitor.pid_file rescue nil end |