capper 2.0.0.rc1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -120,6 +120,31 @@ ensure
120
120
  ENV[name] = saved
121
121
  end
122
122
 
123
+ # make sure a block and all commands within are only executed for servers
124
+ # matching the specified role even if ROLES or HOSTS is specified on the
125
+ # command line, in which case capistrano matches all servers by default. *sigh*
126
+ def ensure_role(role, &block)
127
+ if task = current_task
128
+ servers = find_servers_for_task(task)
129
+ else
130
+ servers = find_servers
131
+ end
132
+
133
+ servers = servers.select do |server|
134
+ self.roles[role.to_sym].include?(server)
135
+ end
136
+
137
+ return if servers.empty?
138
+
139
+ original, ENV['HOSTS'] = ENV['HOSTS'], servers.map { |s| s.host }.join(',')
140
+
141
+ begin
142
+ yield
143
+ ensure
144
+ ENV['HOSTS'] = original
145
+ end
146
+ end
147
+
123
148
  # logs the command then executes it locally.
124
149
  # returns the command output as a string
125
150
  def run_locally(cmd)
@@ -1,3 +1,3 @@
1
1
  module Capper
2
- VERSION = "2.0.0.rc1"
2
+ VERSION = "2.0.0.rc2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capper
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
4
+ version: 2.0.0.rc2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: