Class Airbrussh::Rake::Context
In: lib/airbrussh/rake/context.rb
Parent: Object

Maintains information about what Rake task is currently being invoked, in order to be able to decorate SSHKit commands with additional context-sensitive information. Works via a monkey patch to Rake::Task, which can be disabled via by setting Airbrussh.configuration.monkey_patch_rake = false.

Note that this class is not thread-safe. Normally this is not a problem, but some Capistrano users are known to use `invoke` to switch the Rake task in the middle of an SSHKit thread, which causes Context to get very confused. It such scenarios Context is not reliable and may return `nil` for the `position` of a command.

Methods

Attributes

current_task_name  [RW] 
history  [R] 
last_task_name  [RW] 

Public Class methods

Public Instance methods

Returns the name of the currently-executing rake task, if it can be determined. If monkey patching is disabled, this will be nil.

The zero-based position of the specified command in the current rake task. May be `nil` in certain multi-threaded scenarios, so be careful!

Update the context when a new command starts by:

  • Clearing the command history if the rake task has changed
  • Recording the command in the history

Returns whether or not this command was the first execution of this command in the current rake task

[Validate]