module Filewatcher::Snapshots
Module for snapshot logic inside Filewatcher
Public Instance Methods
found_filenames()
click to toggle source
# File lib/filewatcher/snapshots.rb, line 9 def found_filenames current_snapshot.keys end
Private Instance Methods
current_snapshot()
click to toggle source
Takes a snapshot of the current status of watched files. (Allows avoidance of potential race condition during finalize)
# File lib/filewatcher/snapshots.rb, line 17 def current_snapshot Filewatcher::Snapshot.new( expand_directories(@unexpanded_filenames) - expand_directories(@unexpanded_excluded_filenames) ) end
expand_directories(patterns)
click to toggle source
# File lib/filewatcher/snapshots.rb, line 24 def expand_directories(patterns) patterns = Array(patterns) unless patterns.is_a? Array expanded_patterns = patterns.map do |pattern| pattern = File.expand_path(pattern) Dir[ File.directory?(pattern) ? File.join(pattern, '**', '*') : pattern ] end expanded_patterns.flatten! expanded_patterns.uniq! expanded_patterns end
file_system_updated?(snapshot = current_snapshot)
click to toggle source
# File lib/filewatcher/snapshots.rb, line 37 def file_system_updated?(snapshot = current_snapshot) debug __method__ @changes = snapshot - @last_snapshot @last_snapshot = snapshot @changes.any? end