Class: Cape::RecipeDefinition

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

Overview

Determines how a Capistrano recipe will be defined.

Instance Method Summary collapse

Instance Method Details

#cdString, Proc #cd(path) ⇒ String, Proc #cd(&block) ⇒ String, Proc

The remote directory from which Rake tasks will be executed.

Overloads:

  • #cdString, Proc

    The remote directory from which Rake tasks will be executed.

    Returns:

    • (String, Proc)

      the value or a block that returns the value

  • #cd(path) ⇒ String, Proc

    Sets the remote directory from which Rake tasks will be executed.

    Parameters:

    • path (String, Proc)

      the value or a callable object that returns the value

    Returns:

    • (String, Proc)

      path

    Raises:

    • (ArgumentError)

      path is a callable object that has parameters

  • #cd(&block) ⇒ String, Proc

    Sets the remote directory from which Rake tasks will be executed.

    Yield Returns:

    • (String)

      the value

    Returns:

    • (String, Proc)

      block

    Raises:

    • (ArgumentError)

      block has parameters



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cape/recipe_definition.rb', line 33

def cd(path=nil, &block)
  if (cd = (path || block))
    if cd.respond_to?(:arity)
      case cd.arity
        when -1
          # Lambda: good
        when 0
          # Good
        else
          raise ::ArgumentError, "Must have 0 parameters but has #{cd.arity}"
      end
    end

    @cd = cd
  else
    @cd
  end
end

#envHashList

A hash of remote environment variables.

Returns:

  • (HashList)

    the desired environment of the remote computer



55
56
57
# File 'lib/cape/recipe_definition.rb', line 55

def env
  @env ||= HashList.new
end

#optionsHashList

A hash of Capistrano recipe options to pass to the Capistrano task method.

Returns:

  • (HashList)

    the desired Capistrano recipe options

See Also:



65
66
67
# File 'lib/cape/recipe_definition.rb', line 65

def options
  @options ||= HashList.new
end

#renameProc #rename {|task_name| ... } ⇒ Proc

How Rake tasks will be named when they are mirrored as Capistrano recipes.

Overloads:

  • #renameProc

    How Rake tasks will be named when they are mirrored as Capistrano recipes.

    Returns:

    • (Proc)

      the block that generates a Capistrano recipe name from a Rake task name

  • #rename {|task_name| ... } ⇒ Proc

    Determines how Rake tasks will be named when they are mirrored as Capistrano recipes.

    Yields:

    • (task_name)

    Yield Parameters:

    • task_name (String)

      the name of a Rake task

    Yield Returns:

    • (String)

      a name for the Capistrano recipe

    Returns:

    • (Proc)

      block

    Raises:

    • (ArgumentError)

      block does not have exactly one parameter



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cape/recipe_definition.rb', line 89

def rename(&block)
  if block
    unless (block.arity == 1)
      raise ::ArgumentError, "Must have 1 parameter but has #{block.arity}"
    end

    @rename = block
  else
    @rename
  end
end