Class: Librr::DirMonitor::DirWatcher

Inherits:
EventMachine::Connection
  • Object
show all
Includes:
Logger::ClassLogger
Defined in:
lib/librr/dir_monitor.rb

Instance Method Summary collapse

Methods included from Logger::ClassLogger

#debug, #info, #logger

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_initObject



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

#unbindObject



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