Class: VagrantPlugins::ProxyConf::UserinfoURI

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/vagrant-proxyconf/userinfo_uri.rb

Overview

Helper class that strips userinfo from the URI to separate attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ UserinfoURI

Returns a new instance of UserinfoURI.

Parameters:

  • uri (String)

    the URI including optional userinfo



17
18
19
20
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 17

def initialize(uri)
  @set = !!uri
  @uri = URI.parse(uri || '')
end

Instance Attribute Details

#hostString (readonly)

Returns the host.

Returns:

  • (String)

    the host



14
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 14

def_delegators :@uri, :host, :port

#portString (readonly)

Returns the port.

Returns:

  • (String)

    the port



14
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 14

def_delegators :@uri, :host, :port

Instance Method Details

#passString

Returns the password.

Returns:

  • (String)

    the password



40
41
42
43
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 40

def pass
  return URI.decode(@uri.password) if @uri.password
  @uri.password
end

#uriString Also known as: to_s

Returns the URI without userinfo.

Returns:

  • (String)

    the URI without userinfo



23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 23

def uri
  if !@set
    nil
  elsif @uri.to_s.empty?
    ""
  else
    "#{@uri.scheme}://#{host}:#{port}"
  end
end

#userString

Returns the username.

Returns:

  • (String)

    the username



34
35
36
37
# File 'lib/vagrant-proxyconf/userinfo_uri.rb', line 34

def user
  return URI.decode(@uri.user) if @uri.user
  @uri.user
end