lib/sprinkle/actors/ssh.rb in sprinkle-0.7.1.1 vs lib/sprinkle/actors/ssh.rb in sprinkle-0.7.2

- old
+ new

@@ -42,11 +42,11 @@ class SSHCommandFailure < StandardError #:nodoc: attr_accessor :details end - class SSHConnectionCache + class SSHConnectionCache #:nodoc: def initialize; @cache={}; end def start(host, user, opts={}) key="#{host}#{user}#{opts.to_s}" @cache[key] ||= Net::SSH.start(host,user,opts) end @@ -62,16 +62,16 @@ end # Define a whole host of roles at once # # This is depreciated - you should be using role instead. - def roles(roles) + def roles(roles) #:nodoc: @roles = roles end # Determines if there are any servers for the given roles - def servers_for_role?(roles) + def servers_for_role?(roles) #:nodoc: roles=Array(roles) roles.any? { |r| @roles.keys.include? (r) } end # Define a role and add servers to it @@ -106,15 +106,15 @@ # Set this to true to prepend 'sudo' to every command. def use_sudo(value=true) @options[:use_sudo] = value end - def sudo? + def sudo? #:nodoc: @options[:use_sudo] end - def sudo_command + def sudo_command #:nodoc: "sudo" end def setup_gateway #:nodoc: @gateway ||= Net::SSH::Gateway.new(@options[:gateway], @options[:user]) if @options[:gateway] @@ -144,11 +144,11 @@ @installer = nil end protected - def raise_error(e) + def raise_error(e) #:nodoc: raise Sprinkle::Errors::RemoteCommandFailure.new(@installer, e.details, e) end def process(name, commands, roles, opts = {}) #:nodoc: setup_gateway @@ -163,11 +163,11 @@ success = execute_on_host(commands, host) return false unless success end end - def prepare_commands(commands) + def prepare_commands(commands) #:nodoc: return commands unless sudo? commands.map do |command| next command if command.is_a?(Symbol) command.match(/^#{sudo_command}/) ? command : "#{sudo_command} #{command}" end @@ -253,10 +253,10 @@ else raise e end end - def ssh_session(host) + def ssh_session(host) #:nodoc: if @gateway gateway.ssh(host, @options[:user]) else @connection_cache.start(host, @options[:user],:password => @options[:password], :keys => @options[:keys]) end