Sha256: aa2924e7dbb932897857d2a10d7aac64049694e3170e580a25a3680141c54a94
Contents?: true
Size: 1.24 KB
Versions: 153
Compression:
Stored size: 1.24 KB
Contents
module Guard # Listener implementation for Windows `fchange`. # class Windows < Listener # Initialize the Listener. # def initialize(*) super @fchange = FChange::Notifier.new end # Start the listener. # def start super worker.run end # Stop the listener. # def stop super worker.stop end # Check if the listener is usable on the current OS. # # @return [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 private # Watch the given directory for file changes. # # @param [String] directory 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 # Get the listener worker. # def worker @fchange end end end
Version data entries
153 entries across 61 versions & 3 rubygems