Sha256: ffc2f4c30eea190488144d0ae6d42247f61a94e6481801f92fcaf26b960efbc3
Contents?: true
Size: 1.17 KB
Versions: 14
Compression:
Stored size: 1.17 KB
Contents
gem "listen", "~> 1.0" require "listen" require "listen/version" module Spring module Watcher class Listen < Abstract attr_reader :listener def start unless @listener @listener = ::Listen.to(*base_directories, relative_paths: false) @listener.latency(latency) @listener.change(&method(:changed)) @listener.start end end def stop if @listener @listener.stop @listener = nil end end def subjects_changed if @listener && @listener.directories.sort != base_directories.sort restart end end def watching?(file) files.include?(file) || file.start_with?(*directories) end def changed(modified, added, removed) synchronize do if (modified + added + removed).any? { |f| watching? f } mark_stale end end end def base_directories ([root] + files.reject { |f| f.start_with? root }.map { |f| File.expand_path("#{f}/..") } + directories.reject { |d| d.start_with? root } ).uniq end end end end
Version data entries
14 entries across 14 versions & 1 rubygems