class Guard::Watcher
def initialize(pattern, action = nil)
-
action
(Block
) -- the action to execute before passing the result to -
pattern
(String, Regexp
) -- the pattern to be watched by the Guard
def initialize(pattern, action = nil) @pattern, @action = pattern, action @@warning_printed ||= false # deprecation warning if @pattern.is_a?(String) && @pattern =~ /(^(\^))|(>?(\\\.)|(\.\*))|(\(.*\))|(\[.*\])|(\$$)/ unless @@warning_printed ::Guard::UI.info "*"*20 + "\nDEPRECATION WARNING!\n" + "*"*20 ::Guard::UI.info <<-MSG You have a string in your Guardfile watch patterns that seem to represent a Regexp. Guard matches String with == and Regexp with Regexp#match. You should either use plain String (without Regexp special characters) or real Regexp. MSG @@warning_printed = true end ::Guard::UI.info "\"#{@pattern}\" has been converted to #{ Regexp.new(@pattern).inspect }\n" @pattern = Regexp.new(@pattern) end end