summaryrefslogtreecommitdiff
path: root/lib/net/ssh/config.rb
diff options
context:
space:
mode:
authordelano <delano@delanotes.com>2014-02-19 08:59:46 -0500
committerdelano <delano@delanotes.com>2014-02-19 08:59:46 -0500
commit6fc2b4d782a45ead3cf2ca14b3c3fad1d738acc2 (patch)
tree2eabb9ccaafe629cf13bed4dda8a1d5f01155906 /lib/net/ssh/config.rb
parent2eafb0a159046674bb76b640be26862ace92c74d (diff)
downloadnet-ssh-6fc2b4d782a45ead3cf2ca14b3c3fad1d738acc2.tar.gz
Version bump to 2.8.1 with fixes for #145 and #146
Diffstat (limited to 'lib/net/ssh/config.rb')
-rw-r--r--lib/net/ssh/config.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/net/ssh/config.rb b/lib/net/ssh/config.rb
index fab681b..4798344 100644
--- a/lib/net/ssh/config.rb
+++ b/lib/net/ssh/config.rb
@@ -48,7 +48,7 @@ module Net; module SSH
def default_files
@@default_files
end
-
+
def default_auth_methods
@@default_auth_methods
end
@@ -58,7 +58,7 @@ module Net; module SSH
# #default_files), translates the resulting hash into the options
# recognized by Net::SSH, and returns them.
def for(host, files=default_files)
- hash = translate(files.inject({}) { |settings, file|
+ hash = translate(files.inject({}) { |settings, file|
load(file, host, settings)
})
end
@@ -74,14 +74,14 @@ module Net; module SSH
return settings unless File.readable?(file)
settings[:auth_methods] ||= default_auth_methods.clone
-
+
globals = {}
matched_host = nil
multi_host = []
seen_host = false
IO.foreach(file) do |line|
next if line =~ /^\s*(?:#.*)?$/
-
+
if line =~ /^\s*(\S+)\s*=(.*)$/
key, value = $1, $2
else
@@ -93,14 +93,14 @@ module Net; module SSH
key.downcase!
value = $1 if value =~ /^"(.*)"$/
-
+
value = case value.strip
when /^\d+$/ then value.to_i
when /^no$/i then false
when /^yes$/i then true
else value
end
-
+
if key == 'host'
# Support "Host host1 host2 hostN".
# See http://github.com/net-ssh/net-ssh/issues#issue/6
@@ -122,9 +122,9 @@ module Net; module SSH
end
end
end
-
+
settings = globals.merge(settings) if globals
-
+
return settings
end
@@ -134,7 +134,6 @@ module Net; module SSH
# the returned hash will have Symbols for keys.
def translate(settings)
settings.inject({}) do |hash, (key, value)|
- hash[:auth_methods] ||= settings[:auth_methods] || default_auth_methods.clone
case key
when 'bindaddress' then
hash[:bind_address] = value