mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Make UPPERCASE variables work
git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3385 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
b5780d8f90
commit
3af8352664
4 changed files with 30 additions and 6 deletions
|
@ -1,11 +1,13 @@
|
|||
*0.11.0* *SVN*
|
||||
|
||||
* Make UPPERCASE variables work
|
||||
|
||||
* Added rails_env variable (defaults to production) for use by tasks that employ the RAILS_ENV environment variable
|
||||
|
||||
* Added Actor.default_io_proc
|
||||
|
||||
* Set :actor key on SSH channel instances
|
||||
|
||||
* Added rails_env variable (defaults to production) for use by tasks that employ the RAILS_ENV environment variable
|
||||
|
||||
|
||||
*0.10.0* (January 2nd, 2006)
|
||||
|
||||
|
|
|
@ -326,11 +326,11 @@ module SwitchTower
|
|||
self.class.default_io_proc
|
||||
end
|
||||
|
||||
private
|
||||
def metaclass
|
||||
class << self; self; end
|
||||
end
|
||||
|
||||
def metaclass
|
||||
class << self; self; end
|
||||
end
|
||||
private
|
||||
|
||||
def define_method(name, &block)
|
||||
metaclass.send(:define_method, name, &block)
|
||||
|
@ -382,5 +382,6 @@ module SwitchTower
|
|||
super
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,9 @@ module SwitchTower
|
|||
# determining the release path.
|
||||
attr_reader :now
|
||||
|
||||
# The has of variables currently known by the configuration
|
||||
attr_reader :variables
|
||||
|
||||
def initialize(actor_class=Actor) #:nodoc:
|
||||
@roles = Hash.new { |h,k| h[k] = [] }
|
||||
@actor = actor_class.new(self)
|
||||
|
@ -60,6 +63,15 @@ module SwitchTower
|
|||
|
||||
# Set a variable to the given value.
|
||||
def set(variable, value)
|
||||
# if the variable is uppercase, then we add it as a constant to the
|
||||
# actor. This is to allow uppercase "variables" to be set and referenced
|
||||
# in recipes.
|
||||
if variable.to_s[0].between?(?A, ?Z)
|
||||
klass = @actor.metaclass
|
||||
klass.send(:remove_const, variable) if klass.const_defined?(variable)
|
||||
klass.const_set(variable, value)
|
||||
end
|
||||
|
||||
@variables[variable] = value
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ require 'stringio'
|
|||
require 'test/unit'
|
||||
require 'switchtower/actor'
|
||||
require 'switchtower/logger'
|
||||
require 'switchtower/configuration'
|
||||
|
||||
class ActorTest < Test::Unit::TestCase
|
||||
|
||||
|
@ -258,4 +259,12 @@ class ActorTest < Test::Unit::TestCase
|
|||
@actor.foo
|
||||
assert_equal %w(foo after_foo), history
|
||||
end
|
||||
|
||||
def test_uppercase_variables
|
||||
config = SwitchTower::Configuration.new(TestActor)
|
||||
config.set :HELLO, "world"
|
||||
assert_equal "world", config.actor.instance_eval("HELLO")
|
||||
config.set :HELLO, "test"
|
||||
assert_equal "test", config.actor.instance_eval("HELLO")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue