~ubuntu-branches/ubuntu/vivid/capistrano/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/capistrano/configuration/alias_task.rb

  • Committer: Package Import Robot
  • Author(s): Antonio Terceiro
  • Date: 2012-06-30 09:48:35 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120630094835-vf8ylntcdylh65re
Tags: 2.12.0-1
* New upstream release.
* Fix typo in the short description (Closes: #655389)
* Bump build dependency on gem2deb to 0.3.0~
* debian/patches/0001-Remove-unecessary-explicit-rubygems-access.patch:
  removed, applied upstream
* debian/patches/0002-Remove-bundler-rubygems-stuff-from-test-code.patch:
  refreshed.
* Bump standards version to 3.9.3; no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module Capistrano
 
2
  class Configuration
 
3
    module AliasTask
 
4
      # Attempts to find the task at the given fully-qualified path, and
 
5
      # alias it. If arguments don't have correct task names, an ArgumentError
 
6
      # wil be raised. If no such task exists, a Capistrano::NoSuchTaskError
 
7
      # will be raised.
 
8
      #
 
9
      # Usage:
 
10
      #
 
11
      #   alias_task :original_deploy, :deploy
 
12
      #
 
13
      def alias_task(new_name, old_name)
 
14
        if !new_name.respond_to?(:to_sym) or !old_name.respond_to?(:to_sym)
 
15
          raise ArgumentError, "expected a valid task name"
 
16
        end
 
17
 
 
18
        original_task = find_task(old_name) or raise NoSuchTaskError, "the task `#{old_name}' does not exist"
 
19
        task = original_task.dup # Dup. task to avoid modify original task
 
20
        task.name = new_name
 
21
 
 
22
        define_task(task)
 
23
      end
 
24
    end
 
25
  end
 
26
end