class FileWatch::Processor
Attributes
watch[R]
Public Class Methods
new(settings)
click to toggle source
# File lib/filewatch/processor.rb, line 11 def initialize(settings) @settings = settings @deletable_paths = Concurrent::AtomicReference.new [] end
Public Instance Methods
add_deletable_path(path)
click to toggle source
# File lib/filewatch/processor.rb, line 25 def add_deletable_path(path) @deletable_paths.get << path end
add_watch(watch)
click to toggle source
# File lib/filewatch/processor.rb, line 16 def add_watch(watch) @watch = watch self end
clear_deletable_paths()
click to toggle source
# File lib/filewatch/processor.rb, line 21 def clear_deletable_paths @deletable_paths.get_and_set [] end
restat(watched_file)
click to toggle source
# File lib/filewatch/processor.rb, line 29 def restat(watched_file) changed = watched_file.restat! if changed # the collection (when sorted by modified_at) needs to re-sort every time watched-file is modified, # we can perform these update operation while processing files (stat interval) instead of having to # re-sort the whole collection every time an entry is accessed @watch.watched_files_collection.update(watched_file) end end
Private Instance Methods
error_details(error, watched_file)
click to toggle source
# File lib/filewatch/processor.rb, line 41 def error_details(error, watched_file) details = { :path => watched_file.path, :exception => error.class, :message => error.message, :backtrace => error.backtrace } if logger.debug? details[:file] = watched_file else details[:backtrace] = details[:backtrace].take(8) if details[:backtrace] end details end