class Guard::Watcher
def self.match_files(guard, files)
-
(Array
- the matched watcher response
Parameters:
-
files
(Array
) -- the changed files -
guard
(Guard::Plugin
) -- the Guard plugin which watchers are used
def self.match_files(guard, files) return [] if files.empty? files.inject([]) do |paths, file| guard.watchers.each do |watcher| matches = watcher.match(file) next(paths) unless matches 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) else next(paths) end else paths << matches[0] end break if guard.options[:first_match] end guard.options[:any_return] ? paths : paths.flatten.map(&:to_s) end end