simplify key assignment in conf

This commit is contained in:
Dominik Richter 2015-10-02 22:29:40 +02:00
parent 5825b4d6d4
commit 7d27b62794

View file

@ -12,11 +12,14 @@ module Vulcano
# Resolve target configuration in URI-scheme into
# all respective fields and merge with existing configuration.
# e.g. ssh://bob@remote => backend: ssh, user: bob, host: remote
def self.target_config(config = nil)
def self.target_config(config = nil) # rubocop:disable Metrics/AbcSize
conf = config.nil? ? {} : config.dup
# in case the user specified a key-file, register it that way
key = conf['key']
conf['key_file'] = key if !key.nil? and File.file?(key)
if !key.nil? and File.file?(key)
conf['key_file'] = key
end
return conf if conf['target'].to_s.empty?