Sha256: 574adcbb1a6f81591e66e39926ead3017d4abf871861b09c08094cbcfbfa3000

Contents?: true

Size: 580 Bytes

Versions: 29

Compression:

Stored size: 580 Bytes

Contents

# role = :app
def with_role(role, &block)
  original, ENV['HOSTS'] = ENV['HOSTS'], find_servers(:roles => role).map{|d| d.host}.join(",")
  begin
    yield
  ensure
    ENV['HOSTS'] = original
  end
end

# options = { :user => 'xxxxx', :password => 'xxxxx' }
def with_credentials(options={}, &block)
  original_username, original_password = user, password
  begin
    set :user,     options[:user] || original_username
    set :password, options[:password] || original_password
    yield
  ensure
    set :user,     original_username
    set :password, original_password
  end
end

Version data entries

29 entries across 29 versions & 3 rubygems

Version Path
nesquena-cap-recipes-0.3.15 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.16 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.2 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.3 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.4 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.5 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.7 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.8 lib/cap_recipes/tasks/with_scope.rb
nesquena-cap-recipes-0.3.9 lib/cap_recipes/tasks/with_scope.rb