Sha256: 3355e90491fe77618ba2b1a7afa04ca02f3e4401156f3b31248e6776b19b72a9

Contents?: true

Size: 646 Bytes

Versions: 1

Compression:

Stored size: 646 Bytes

Contents

module FSSM::Backends
  class Inotify
    def initialize
      @notifier = INotify::Notifier.new
    end

    def add_handler(handler, preload=true)
      @notifier.watch(handler.path.to_s, :recursive, :attrib, :modify, :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

    def run
      begin
        @notifier.run
      rescue Interrupt
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fssm-0.2.5 lib/fssm/backends/inotify.rb