class Guard::Windows


Listener implementation for Windows ‘fchange`.

def self.usable?(no_vendor = false)

Returns:
  • (Boolean) - whether usable or not
def self.usable?(no_vendor = false)
  return false unless RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
  $LOAD_PATH << File.expand_path('../../../vendor/windows/lib', __FILE__) unless no_vendor
  require 'rb-fchange'
  true
rescue LoadError
  false
end

def initialize(*)


Initialize the Listener.
def initialize(*)
  super
  @fchange = FChange::Notifier.new
end

def start


Start the listener.
def start
  super
  worker.run
end

def stop


Stop the listener.
def stop
  super
  worker.stop
end

def watch(directory)

Parameters:
  • directory (String) -- the directory to watch
def watch(directory)
  worker.watch(directory, :all_events, :recursive) do |event|
    paths = [File.expand_path(event.watcher.path)]
    files = modified_files(paths, :all => true)
    @callback.call(files) unless files.empty?
  end
end

def worker


Get the listener worker.
def worker
  @fchange
end