Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6438

Show
Ignore:
Timestamp:
03/16/07 22:11:45 (1 year ago)
Author:
minam
Message:

unit tests for extensions mechanism, and a bit more robustness

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/capistrano/lib/capistrano/extensions.rb

    r6436 r6438  
    11module Capistrano 
    2   class ExtensionProxy 
     2  class ExtensionProxy #:nodoc: 
    33    def initialize(config, mod) 
    44      @config = config 
     
    1111  end 
    1212 
     13  # Holds the set of registered plugins, keyed by name (where the name is a 
     14  # symbol). 
    1315  EXTENSIONS = {} 
    1416 
     17  # Register the given module as a plugin with the given name. It will henceforth 
     18  # be available via a proxy object on Configuration instances, accessible by 
     19  # a method with the given name. 
    1520  def self.plugin(name, mod) 
     21    name = name.to_sym 
    1622    return false if EXTENSIONS.has_key?(name) 
     23 
     24    methods = Capistrano::Configuration.public_instance_methods + 
     25      Capistrano::Configuration.protected_instance_methods + 
     26      Capistrano::Configuration.private_instance_methods 
     27 
     28    if methods.include?(name.to_s) 
     29      raise Capistrano::Error, "registering a plugin named `#{name}' would shadow a method on Capistrano::Configuration with the same name" 
     30    end 
    1731 
    1832    Capistrano::Configuration.class_eval <<-STR, __FILE__, __LINE__+1 
     
    2640  end 
    2741 
     42  # Unregister the plugin with the given name. 
    2843  def self.remove_plugin(name) 
     44    name = name.to_sym 
    2945    if EXTENSIONS.delete(name) 
    3046      Capistrano::Configuration.send(:remove_method, name) 
     
    3551  end 
    3652 
    37   def self.configuration(*args) 
     53  def self.configuration(*args) #:nodoc: 
    3854    warn "[DEPRECATION] Capistrano.configuration is deprecated. Use Capistrano::Configuration.instance instead" 
    3955    Capistrano::Configuration.instance(*args)