Complexity of Browser#proxy_auth= reduced

This commit is contained in:
erwanlr
2013-03-05 10:34:11 +01:00
parent 2607e91833
commit 1adadcb4bb
2 changed files with 51 additions and 33 deletions

View File

@@ -109,25 +109,18 @@ class Browser
def proxy_auth=(auth)
unless auth.nil?
if auth.is_a?(Hash)
if !auth.include?(:proxy_username) or !auth.include?(:proxy_password)
raise_invalid_proxy_format()
end
if auth.is_a?(Hash) && auth.include?(:proxy_username) && auth.include?(:proxy_password)
@proxy_auth = auth[:proxy_username] + ':' + auth[:proxy_password]
elsif auth.is_a?(String)
if auth.index(':') != nil
@proxy_auth = auth
else
raise_invalid_proxy_auth_format()
end
elsif auth.is_a?(String) && auth.index(':') != nil
@proxy_auth = auth
else
raise_invalid_proxy_auth_format()
raise invalid_proxy_auth_format
end
end
end
def raise_invalid_proxy_auth_format
raise 'Invalid proxy auth format, expected username:password or {proxy_username: username, proxy_password: password}'
def invalid_proxy_auth_format
'Invalid proxy auth format, expected username:password or {proxy_username: username, proxy_password: password}'
end
# TODO reload hydra (if the .load_config is called on a browser object,