Module: Cape::DSLDeprecated Private

Included in:
Cape
Defined in:
lib/cape/dsl_deprecated.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Implements deprecated methods of DSL.

Instance Method Summary collapse

Instance Method Details

#deprecationDeprecation::Base

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The stream to which deprecation messages are printed.

Returns:



15
16
17
# File 'lib/cape/dsl_deprecated.rb', line 15

def deprecation
  @deprecation ||= Deprecation::DSLDeprecatedMirrorRakeTasks.new
end

#mirror_rake_tasks(task_expression = nil) {|env| ... } ⇒ DSLDeprecated #mirror_rake_tasks(capistrano_task_options = {}) {|env| ... } ⇒ DSLDeprecated #mirror_rake_tasks(task_expression, capistrano_task_options = {}) {|env| ... } ⇒ DSLDeprecated

Note:

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

Defines Rake tasks as Capistrano recipes.

Examples:

Mirroring all Rake tasks

# config/deploy.rb

require 'cape'

Cape do
  mirror_rake_tasks
end

Mirroring some Rake tasks, but not others

# config/deploy.rb

require 'cape'

Cape do
  # Create Capistrano recipes for the Rake task 'foo' and/or for the
  # tasks in the 'foo' namespace.
  mirror_rake_tasks :foo
end

Mirroring Rake tasks that require Capistrano recipe options and/or environment variables

# config/deploy.rb

require 'cape'

Cape do
  # Display defined Rails routes on application server remote machines
  # only.
  mirror_rake_tasks :routes, :roles => :app

  # Execute database migration on application server remote machines
  # only, and set the 'RAILS_ENV' environment variable to the value of
  # the Capistrano variable 'rails_env'.
  mirror_rake_tasks 'db:migrate', :roles => :app do |env|
    env['RAILS_ENV'] = rails_env
  end
end

Mirroring Rake tasks into a Capistrano namespace

# config/deploy.rb

require 'cape'

namespace :rake_tasks do
  Cape do |cape|
    cape.mirror_rake_tasks
  end
end

Overloads:

  • #mirror_rake_tasks(task_expression = nil) {|env| ... } ⇒ DSLDeprecated

    Defines Rake tasks as Capistrano recipes.

    Parameters:

    • task_expression (String, Symbol) (defaults to: nil)

      the full name of a Rake task or namespace to filter

    Yields:

    • (env)

      a block that defines environment variables for the Rake task; optional

    Yield Parameters:

    Returns:

  • #mirror_rake_tasks(capistrano_task_options = {}) {|env| ... } ⇒ DSLDeprecated
    Deprecated.

    Defines all Rake tasks as Capistrano recipes with options.

    Parameters:

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

      options to pass to the Capistrano task method

    Yields:

    • (env)

      a block that defines environment variables for the Rake task; optional

    Yield Parameters:

    Returns:

  • #mirror_rake_tasks(task_expression, capistrano_task_options = {}) {|env| ... } ⇒ DSLDeprecated
    Deprecated.

    Defines specific Rake tasks as Capistrano recipes with options.

    Parameters:

    • task_expression (String, Symbol)

      the full name of a Rake task or namespace to filter

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

      options to pass to the Capistrano task method

    Yields:

    • (env)

      a block that defines environment variables for the Rake task; optional

    Yield Parameters:

    Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/cape/dsl_deprecated.rb', line 124

def mirror_rake_tasks(*arguments, &block)
  arguments_count = arguments.length
  options = arguments.last.is_a?(::Hash) ? arguments.pop.dup : {}
  deprecation.task_expression = arguments.first
  deprecation.options = options.dup
  unless arguments.length <= 1
    raise ::ArgumentError,
          ("wrong number of arguments (#{arguments_count} for 0 or 1, " +
           'plus an options hash)')
  end

  task_expression = arguments.first
  options[:binding] = binding
  rake.each_task task_expression do |t|
    deployment_library.define_rake_wrapper(t, options, &block)
  end
  deployment_library.deprecation.env.each do |name, value|
    deprecation.env[name] = value
  end
  unless deprecation.options.empty? && deprecation.env.empty?
    deprecation.write_formatted_message_to_stream
  end
  self
end