class Guard::Watcher
def self.match_files(guard, files)
-
(Array- the matched watcher response
Parameters:
-
files(Array) -- the changed files -
guard(Guard::Guard) -- the guard which watchers are used
def self.match_files(guard, files) guard.watchers.inject([]) do |paths, watcher| files.each do |file| if matches = watcher.match(file) if watcher.action result = watcher.call_action(matches) if guard.options[:any_return] paths << result elsif result.respond_to?(:empty?) && !result.empty? paths << Array(result) end else paths << matches[0] end end end guard.options[:any_return] ? paths : paths.flatten.map { |p| p.to_s } end end