Class: Lifeline::LifelineRakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/lifeline.rb

Overview

Define rake tasks for running, starting, and terminating

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, opts = {}, &block) ⇒ LifelineRakeTask

Creates 3 new tasks for the lifeline in the namespace specified. These tasks are

  • run - a task for running the code provided in the block

  • lifeline - a lifeline task for running the run task if it’s not already running

  • terminate - a task for terminating all lifelines.

Parameters:

  • name (String, Symbol)

    the namespace of the rake tasks

  • opts (optional, Hash) (defaults to: {})

    Additional options for the method

  • a

    block that defines the body of the run task

Options Hash (opts):

  • :prereqs (Array<String, Symbol>) — default: []

    If there any any rake tasks that should be prerequisites of the :run task, specify them here (For Rails, you would do :prereqs => :environment)



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/lifeline.rb', line 75

def initialize(namespace, opts={}, &block)
  if !block_given?
    raise ArgumentError, "You must pass in a block to be the body of the run rake task"
  end

  @namespace = namespace

  define_run_task(opts, &block)
  define_lifeline_task
  define_terminate_task
end

Instance Attribute Details

#namespaceString

The namespace to define the tasks in

Returns:

  • (String)

    the namespace for the tasks



62
63
64
# File 'lib/lifeline.rb', line 62

def namespace
  @namespace
end