lib/net/ssh.rb in net-ssh-4.0.0.alpha4 vs lib/net/ssh.rb in net-ssh-4.0.0.beta1

- old
+ new

@@ -69,11 +69,12 @@ :languages, :logger, :paranoid, :password, :port, :proxy, :rekey_blocks_limit,:rekey_limit, :rekey_packet_limit, :timeout, :verbose, :known_hosts, :global_known_hosts_file, :user_known_hosts_file, :host_key_alias, :host_name, :user, :properties, :passphrase, :keys_only, :max_pkt_size, :max_win_size, :send_env, :use_agent, :number_of_password_prompts, - :append_supported_algorithms, :non_interactive, :password_prompt, :agent_socket_factory + :append_supported_algorithms, :non_interactive, :password_prompt, :agent_socket_factory, + :minimum_dh_bits ] # The standard means of starting a new SSH connection. When used with a # block, the connection will be closed when the block terminates, otherwise # the connection will just be returned. The yielded (or returned) value @@ -204,30 +205,25 @@ invalid_options = options.keys - VALID_OPTIONS if invalid_options.any? raise ArgumentError, "invalid option(s): #{invalid_options.join(', ')}" end + assign_defaults(options) + if options.values.include? nil nil_options = options.keys.select { |k| options[k].nil? } raise ArgumentError, "Value(s) have been set to nil: #{nil_options.join(', ')}" end options[:user] = user if user options = configuration_for(host, options.fetch(:config, true)).merge(options) host = options.fetch(:host_name, host) - if !options.key?(:logger) - options[:logger] = Logger.new(STDERR) - options[:logger].level = Logger::FATAL - end - if options[:non_interactive] options[:number_of_password_prompts] = 0 end - options[:password_prompt] ||= Prompt.default(options) - if options[:verbose] options[:logger].level = case options[:verbose] when Fixnum then options[:verbose] when :debug then Logger::DEBUG when :info then Logger::INFO @@ -274,8 +270,17 @@ when false, nil then return {} else Array(use_ssh_config) end Net::SSH::Config.for(host, files) + end + + def self.assign_defaults(options) + if !options[:logger] + options[:logger] = Logger.new(STDERR) + options[:logger].level = Logger::FATAL + end + + options[:password_prompt] ||= Prompt.default(options) end end end