lib/guard.rb
def supervised_task(guard, task_to_supervise, *args)
      guard.hook("#{ task_to_supervise }_begin", *args)
      result = guard.send(task_to_supervise, *args)
      guard.hook("#{ task_to_supervise }_end", result)

      result

    rescue Exception => ex
      UI.error("#{ guard.class.name } failed to achieve its <#{ task_to_supervise.to_s }>, exception was:" +
               "\n#{ ex.class }: #{ ex.message }\n#{ ex.backtrace.join("\n") }")
      guards.delete guard
      UI.info("\n#{ guard.class.name } has just been fired")

      ex
    end
# Let a Guard execute its task, but fire it
# if his work leads to a system failure.
#
# @param [Guard::Guard] the guard to execute
# @param [Symbol] task_to_supervise the task to run
# @param [Array] args the arguments for the task
# @return [Boolean, Exception] the result of the Guard
#
Let a Guard execute its task, but fire it
if his work leads to a system failure.
Let a Guard execute its task but fire it if his work leads to a system failure .
def supervised_task(guard, task_to_supervise, *args)
      guard.hook("#{ task_to_supervise }_begin", *args)
      result = guard.send(task_to_supervise, *args)
      guard.hook("#{ task_to_supervise }_end", result)
      result
    rescue Exception => ex
      UI.error("#{ guard.class.name } failed to achieve its <#{ task_to_supervise.to_s }>, exception was:" +
               "\n#{ ex.class }: #{ ex.message }\n#{ ex.backtrace.join("\n") }")
      guards.delete guard
      UI.info("\n#{ guard.class.name } has just been fired")
      ex
    end
def supervised_task ( guard , task_to_supervise , * args ) guard . hook ( "#{ task_to_supervise }_begin" , * args ) result = guard . send ( task_to_supervise , * args ) guard . hook ( "#{ task_to_supervise }_end" , result ) result rescue Exception => ex UI . error ( "#{ guard.class.name } failed to achieve its <#{ task_to_supervise.to_s }>, exception was:" + "\n#{ ex.class }: #{ ex.message }\n#{ ex.backtrace.join("\n") }" ) guards . delete guard UI . info ( "\n#{ guard.class.name } has just been fired" ) ex end
Let a Guard execute its task, but fire it
if his work leads to a system failure.
Let a Guard execute its task but fire it if his work leads to a system failure .
the result of the Guard
the result of the Guard
Boolean, Exception
guard
task_to_supervise
args
args the arguments for the task
args the arguments for the task