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*
|
*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
|
* Added Actor.default_io_proc
|
||||||
|
|
||||||
* Set :actor key on SSH channel instances
|
* 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)
|
*0.10.0* (January 2nd, 2006)
|
||||||
|
|
||||||
|
|
|
@ -326,11 +326,11 @@ module SwitchTower
|
||||||
self.class.default_io_proc
|
self.class.default_io_proc
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def metaclass
|
||||||
|
class << self; self; end
|
||||||
|
end
|
||||||
|
|
||||||
def metaclass
|
private
|
||||||
class << self; self; end
|
|
||||||
end
|
|
||||||
|
|
||||||
def define_method(name, &block)
|
def define_method(name, &block)
|
||||||
metaclass.send(:define_method, name, &block)
|
metaclass.send(:define_method, name, &block)
|
||||||
|
@ -382,5 +382,6 @@ module SwitchTower
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,9 @@ module SwitchTower
|
||||||
# determining the release path.
|
# determining the release path.
|
||||||
attr_reader :now
|
attr_reader :now
|
||||||
|
|
||||||
|
# The has of variables currently known by the configuration
|
||||||
|
attr_reader :variables
|
||||||
|
|
||||||
def initialize(actor_class=Actor) #:nodoc:
|
def initialize(actor_class=Actor) #:nodoc:
|
||||||
@roles = Hash.new { |h,k| h[k] = [] }
|
@roles = Hash.new { |h,k| h[k] = [] }
|
||||||
@actor = actor_class.new(self)
|
@actor = actor_class.new(self)
|
||||||
|
@ -60,6 +63,15 @@ module SwitchTower
|
||||||
|
|
||||||
# Set a variable to the given value.
|
# Set a variable to the given value.
|
||||||
def set(variable, 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
|
@variables[variable] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ require 'stringio'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'switchtower/actor'
|
require 'switchtower/actor'
|
||||||
require 'switchtower/logger'
|
require 'switchtower/logger'
|
||||||
|
require 'switchtower/configuration'
|
||||||
|
|
||||||
class ActorTest < Test::Unit::TestCase
|
class ActorTest < Test::Unit::TestCase
|
||||||
|
|
||||||
|
@ -258,4 +259,12 @@ class ActorTest < Test::Unit::TestCase
|
||||||
@actor.foo
|
@actor.foo
|
||||||
assert_equal %w(foo after_foo), history
|
assert_equal %w(foo after_foo), history
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue