public
Description: Remote multi-server automation tool
Homepage: http://www.capify.org
Clone URL: git://github.com/jamis/capistrano.git
Search Repo:
Add alternative server-centric role definition method


git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@8926 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jamis (author)
Fri Feb 22 20:15:16 -0800 2008
commit  87bde937faab25dab9b1df09fa3a584c7a977fca
tree    a4627053eda69ca8e7e426220e64f3ba7875820b
parent  df23604cc61393355689a19b268c661f699bc5cb
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Add alternative server-centric role definition method [James Duncan Davidson]
0
+
0
 * Add support for password prompts from the Mercurial SCM [ches]
0
 
0
 * Add support for :max_hosts option in task definition or run() [Rob Holland <rob@inversepath.com>]
...
48
49
50
 
 
 
 
 
 
 
 
 
 
 
 
51
52
53
...
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
0
@@ -48,6 +48,18 @@ module Capistrano
0
         roles[which].push(block, options) if block_given?
0
         args.each { |host| roles[which] << ServerDefinition.new(host, options) }
0
       end
0
+
0
+ # An alternative way to associate servers with roles. If you have a server
0
+ # that participates in multiple roles, this can be a DRYer way to describe
0
+ # the relationships. Pass the host definition as the first parameter, and
0
+ # the roles as the remaining parameters:
0
+ #
0
+ # server "master.example.com", :web, :app
0
+ def server(host, *roles)
0
+ options = roles.last.is_a?(Hash) ? roles.pop : {}
0
+ raise ArgumentError, "you must associate a server with at least one role" if roles.empty?
0
+ roles.each { |name| role(name, host, options) }
0
+ end
0
     end
0
   end
0
 end
...
17
18
19
20
21
22
23
24
25
26
...
132
133
134
 
 
 
 
 
 
 
 
 
 
 
 
135
...
17
18
19
 
 
 
 
20
21
22
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
0
@@ -17,10 +17,6 @@ class ConfigurationRolesTest < Test::Unit::TestCase
0
     @config = MockConfig.new
0
   end
0
 
0
- def assert_role_equals(list)
0
- assert_equal list, @config.roles[:app].map { |s| s.host }
0
- end
0
-
0
   def test_initialize_should_initialize_roles_collection
0
     assert @config.original_initialize_called
0
     assert @config.roles.empty?
0
@@ -132,4 +128,16 @@ class ConfigurationRolesTest < Test::Unit::TestCase
0
     end
0
     assert_role_equals ([])
0
   end
0
+
0
+ def test_role_definitions_via_server_should_associate_server_with_roles
0
+ @config.server "www.capistrano.test", :web, :app
0
+ assert_equal %w(www.capistrano.test), @config.roles[:app].map { |s| s.host }
0
+ assert_equal %w(www.capistrano.test), @config.roles[:web].map { |s| s.host }
0
+ end
0
+
0
+ private
0
+
0
+ def assert_role_equals(list)
0
+ assert_equal list, @config.roles[:app].map { |s| s.host }
0
+ end
0
 end

Comments

    No one has commented yet.