Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v3.2.10
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (30 sloc) 0.744 kb
module ActiveSupport
class FileWatcher
class Backend
def initialize(path, watcher)
@watcher = watcher
@path = path
end
def trigger(files)
@watcher.trigger(files)
end
end
def initialize
@regex_matchers = {}
end
def watch(pattern, &block)
@regex_matchers[pattern] = block
end
def trigger(files)
trigger_files = Hash.new { |h,k| h[k] = Hash.new { |h2,k2| h2[k2] = [] } }
files.each do |file, state|
@regex_matchers.each do |pattern, block|
trigger_files[block][state] << file if pattern === file
end
end
trigger_files.each do |block, payload|
block.call payload
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.