mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Allow Proc-valued variables to be set more conveniently
git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3449 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
243a4671c5
commit
9fd7fc8f19
5 changed files with 9 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
|||
*0.11.0* *SVN*
|
||||
|
||||
* Allow Proc-valued variables to be set more conveniently (set(:foo) { "bar" })
|
||||
|
||||
* Add perforce SCM module [Richard McMahon]
|
||||
|
||||
* Add bazaar (v1) SCM module [Edd Dumbill] (#3533)
|
||||
|
|
|
@ -86,7 +86,7 @@ module SwitchTower
|
|||
# require 'switchtower/cli'
|
||||
# config = SwitchTower::Configuration.new
|
||||
# config.logger_level = SwitchTower::Logger::TRACE
|
||||
# config.set :password, Proc.new { SwitchTower::CLI.password_prompt }
|
||||
# config.set(:password) { SwitchTower::CLI.password_prompt }
|
||||
# config.load "standard", "config/deploy"
|
||||
# config.actor.update_code
|
||||
#
|
||||
|
|
|
@ -51,18 +51,18 @@ module SwitchTower
|
|||
|
||||
set :ssh_options, Hash.new
|
||||
|
||||
set :deploy_to, Proc.new { "/u/apps/#{application}" }
|
||||
set(:deploy_to) { "/u/apps/#{application}" }
|
||||
|
||||
set :version_dir, DEFAULT_VERSION_DIR_NAME
|
||||
set :current_dir, DEFAULT_CURRENT_DIR_NAME
|
||||
set :shared_dir, DEFAULT_SHARED_DIR_NAME
|
||||
set :scm, :subversion
|
||||
|
||||
set :revision, Proc.new { source.latest_revision }
|
||||
set(:revision) { source.latest_revision }
|
||||
end
|
||||
|
||||
# Set a variable to the given value.
|
||||
def set(variable, value)
|
||||
def set(variable, value=nil, &block)
|
||||
# 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.
|
||||
|
@ -72,6 +72,7 @@ module SwitchTower
|
|||
klass.const_set(variable, value)
|
||||
end
|
||||
|
||||
value = block if value.nil? && block_given?
|
||||
@variables[variable] = value
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ set :migrate_target, :current
|
|||
set :migrate_env, ""
|
||||
|
||||
set :use_sudo, true
|
||||
set :run_method, Proc.new { use_sudo ? :sudo : :run }
|
||||
set(:run_method) { use_sudo ? :sudo : :run }
|
||||
|
||||
set :spinner_user, :app
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ class ConfigurationTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_get_proc_variable_sets_original_value_hash
|
||||
@config.set :proc, Proc.new { "foo" }
|
||||
@config.set(:proc) { "foo" }
|
||||
assert_nil @config[:original_value][:proc]
|
||||
assert_equal "foo", @config[:proc]
|
||||
assert_not_nil @config[:original_value][:proc]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue