def watch(pattern, &action)
      # Allow watches in the global scope (to execute arbitrary commands) by
      # building a generic Guard::Plugin.
      @plugin_options ||= nil
      return guard(:plugin) { watch(pattern, &action) } unless @plugin_options

      @plugin_options[:watchers] << Watcher.new(pattern, action)
    end
def watch(pattern, &action)
      # Allow watches in the global scope (to execute arbitrary commands) by
      # building a generic Guard::Plugin.
      @plugin_options ||= nil
      return guard(:plugin) { watch(pattern, &action) } unless @plugin_options

      @plugin_options[:watchers] << Watcher.new(pattern, action)
    end
Defines a pattern to be watched in order to run actions on file
 modification.

 @example Declare watchers for a Guard
   guard :rspec do
     watch('spec/spec_helper.rb')
     watch(%r{^.+_spec.rb})
     watch(%r{^app/controllers/(.+).rb}) do |m|
       'spec/acceptance/#{m[1]}s_spec.rb'
     end
   end

 @example Declare global watchers outside of a Guard
   watch(%r{^(.+)$}) { |m| puts "#{m[1]} changed." }

 @param [String, Regexp] pattern the pattern that Guard must watch for
 modification

 @yield a block to be run when the pattern is matched
 @yieldparam [MatchData] m matches of the pattern
 @yieldreturn a directory, a filename, an array of
   directories / filenames, or nothing (can be an arbitrary command)

 @see Guard::Watcher
 @see #guard