Class: FSSM::Backends::Inotify

Inherits:
Object
  • Object
show all
Defined in:
lib/fssm/backends/inotify.rb

Instance Method Summary collapse

Constructor Details

#initializeInotify

Returns a new instance of Inotify.



3
4
5
# File 'lib/fssm/backends/inotify.rb', line 3

def initialize
  @notifier = INotify::Notifier.new
end

Instance Method Details

#add_handler(handler, preload = true) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/fssm/backends/inotify.rb', line 7

def add_handler(handler, preload=true)
  @notifier.watch(handler.path.to_s, :recursive, :attrib, :close_write, :create,
                  :delete, :delete_self, :moved_from, :moved_to, :move_self) do |event|
    path = FSSM::Pathname.for(event.absolute_name)
    path = path.dirname unless event.name == "" # Event on root directory
    handler.refresh(path)
  end

  handler.refresh(nil, true) if preload
end

#runObject



18
19
20
21
22
23
# File 'lib/fssm/backends/inotify.rb', line 18

def run
  begin
    @notifier.run
  rescue Interrupt
  end
end