Changeset 8926
- Timestamp:
- 02/23/08 04:15:16 (4 months ago)
- Files:
-
- tools/capistrano/CHANGELOG (modified) (1 diff)
- tools/capistrano/lib/capistrano/configuration/roles.rb (modified) (1 diff)
- tools/capistrano/test/configuration/roles_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/capistrano/CHANGELOG
r8925 r8926 1 1 *SVN* 2 3 * Add alternative server-centric role definition method [James Duncan Davidson] 2 4 3 5 * Add support for password prompts from the Mercurial SCM [ches] tools/capistrano/lib/capistrano/configuration/roles.rb
r8905 r8926 49 49 args.each { |host| roles[which] << ServerDefinition.new(host, options) } 50 50 end 51 52 # An alternative way to associate servers with roles. If you have a server 53 # that participates in multiple roles, this can be a DRYer way to describe 54 # the relationships. Pass the host definition as the first parameter, and 55 # the roles as the remaining parameters: 56 # 57 # server "master.example.com", :web, :app 58 def server(host, *roles) 59 options = roles.last.is_a?(Hash) ? roles.pop : {} 60 raise ArgumentError, "you must associate a server with at least one role" if roles.empty? 61 roles.each { |name| role(name, host, options) } 62 end 51 63 end 52 64 end tools/capistrano/test/configuration/roles_test.rb
r8905 r8926 16 16 def setup 17 17 @config = MockConfig.new 18 end19 20 def assert_role_equals(list)21 assert_equal list, @config.roles[:app].map { |s| s.host }22 18 end 23 19 … … 133 129 assert_role_equals ([]) 134 130 end 131 132 def test_role_definitions_via_server_should_associate_server_with_roles 133 @config.server "www.capistrano.test", :web, :app 134 assert_equal %w(www.capistrano.test), @config.roles[:app].map { |s| s.host } 135 assert_equal %w(www.capistrano.test), @config.roles[:web].map { |s| s.host } 136 end 137 138 private 139 140 def assert_role_equals(list) 141 assert_equal list, @config.roles[:app].map { |s| s.host } 142 end 135 143 end