Class: Cape::Capistrano

Inherits:
Object
  • Object
show all
Defined in:
lib/cape/capistrano.rb

Overview

An abstraction of the Capistrano installation.

Direct Known Subclasses

CapistranoDeprecated

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Capistrano

Constructs a new Capistrano object with the specified attributes.

Parameters:

  • attributes (Hash) (defaults to: {})

    attribute values



17
18
19
20
21
22
# File 'lib/cape/capistrano.rb', line 17

def initialize(attributes={})
  attributes.each do |name, value|
    send "#{name}=", value
  end
  self.rake ||= new_rake
end

Instance Attribute Details

#rakeObject

A Cape abstraction of the Rake installation.



12
13
14
# File 'lib/cape/capistrano.rb', line 12

def rake
  @rake
end

Instance Method Details

#define_rake_wrapper(task, named_arguments) {|recipes| ... } ⇒ Capistrano

Note:

Any parameters that the Rake task has are integrated via environment variables, since Capistrano does not support recipe parameters per se.

Defines a wrapper in Capistrano around the specified Rake task.

Parameters:

  • task (Hash)

    metadata for a Rake task

  • named_arguments (Hash)

Options Hash (task):

  • :name (String)

    the name of the Rake task

  • :parameters (Array of String, nil)

    the names of the Rake task’s parameters, if any

  • :description (String)

    documentation for the Rake task

Options Hash (named_arguments):

  • :binding (Binding)

    the Binding of your Capistrano recipes file

Yields:

  • (recipes)

    a block that customizes the Capistrano recipe(s) generated for the Rake task(s); optional

Yield Parameters:

  • recipes (RecipeDefinition)

    an interface for customizing the Capistrano recipe(s) generated for the Rake task(s)

Returns:

Raises:

  • (ArgumentError)

    named_arguments[:binding] is missing



49
50
51
52
53
54
55
56
57
# File 'lib/cape/capistrano.rb', line 49

def define_rake_wrapper(task, named_arguments, &block)
  unless (binding = named_arguments[:binding])
    raise ::ArgumentError, ':binding named argument is required'
  end

  capistrano_context = binding.eval('self', __FILE__, __LINE__)
  describe  task, capistrano_context
  implement(task, capistrano_context, &block)
end