Class: EMDirWatcher::Platform::Linux::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/em-dir-watcher/platform/linux.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, inclusions, exclusions) ⇒ Watcher

Returns a new instance of Watcher.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/em-dir-watcher/platform/linux.rb', line 10

def initialize path, inclusions, exclusions
  @notifier = INotify::Notifier.new

  @notifier.watch(path, :recursive, :attrib, :modify, :create,
                  :delete, :delete_self, :moved_from, :moved_to,
                  :move_self) do |event|
    yield event.absolute_name
  end

  @conn = EM.watch @notifier.to_io do |conn|
    class << conn
      attr_accessor :notifier

      def notify_readable
        @notifier.process
      end
    end
    conn.notifier = @notifier
    conn.notify_readable = true
  end
end

Instance Method Details

#ready_to_use?Boolean

Returns:

  • (Boolean)


36
# File 'lib/em-dir-watcher/platform/linux.rb', line 36

def ready_to_use?; true; end

#stopObject



38
39
40
41
# File 'lib/em-dir-watcher/platform/linux.rb', line 38

def stop
  @notifier.close
rescue SystemCallError
end

#when_ready_to_useObject



32
33
34
# File 'lib/em-dir-watcher/platform/linux.rb', line 32

def when_ready_to_use
    yield
end