Class: Guard::Linux

Inherits:
Listener show all
Defined in:
lib/guard/listeners/linux.rb

Overview

Listener implementation for Linux ‘inotify`.

Constant Summary

Constants inherited from Listener

Guard::Listener::DEFAULT_IGNORE_PATHS

Instance Attribute Summary

Attributes inherited from Listener

#changed_files, #directory, #ignore_paths

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Listener

#all_files, #clear_changed_files, #exclude_ignored_paths, #modified_files, #on_change, #pause, #paused?, #relativize_paths, #relativize_paths?, #run, select_and_init, #start_reactor, #timestamp_files, #update_last_event

Constructor Details

#initializeLinux

Initialize the Listener.



9
10
11
12
13
14
# File 'lib/guard/listeners/linux.rb', line 9

def initialize(*)
  super
  @inotify = INotify::Notifier.new
  @files   = []
  @latency = 0.5
end

Class Method Details

.usable?(no_vendor = false) ⇒ Boolean

Check if the listener is usable on the current OS.

Returns:

  • (Boolean)

    whether usable or not



35
36
37
38
39
40
41
# File 'lib/guard/listeners/linux.rb', line 35

def self.usable?(no_vendor = false)
  $LOAD_PATH << File.expand_path('../../../vendor/linux/lib', __FILE__) unless no_vendor
  require 'rb-inotify'
  true
rescue LoadError
  false
end

Instance Method Details

#startObject

Start the listener.



18
19
20
21
22
# File 'lib/guard/listeners/linux.rb', line 18

def start
  @stop = false
  super
  watch_change unless watch_change?
end

#stopObject

Stop the listener.



26
27
28
29
# File 'lib/guard/listeners/linux.rb', line 26

def stop
  super
  @stop = true
end