Module: Spidr::Settings::Proxy

Included in:
Spidr, Spidr::SessionCache
Defined in:
lib/spidr/settings/proxy.rb

Overview

Methods for configuring a proxy.

Since:

  • 0.6.0

Instance Method Summary collapse

Instance Method Details

#disable_proxy!Object

Disables the proxy settings used by all newly created Agent objects.

Since:

  • 0.6.0



71
72
73
74
# File 'lib/spidr/settings/proxy.rb', line 71

def disable_proxy!
  @proxy = Spidr::Proxy.new
  return true
end

#proxySpidr::Proxy

Proxy information used by all newly created Agent objects by default.

Returns:

Since:

  • 0.6.0



21
22
23
# File 'lib/spidr/settings/proxy.rb', line 21

def proxy
  @proxy ||= Spidr::Proxy.new
end

#proxy=(new_proxy) ⇒ Spidr::Proxy

Sets the proxy information used by Agent objects.

Parameters:

  • new_proxy (Spidr::Proxy, Hash, URI::HTTP, String, nil)

    The new proxy information.

Options Hash (new_proxy):

  • :host (String)

    The host-name of the proxy.

  • :port (Integer) — default: COMMON_PROXY_PORT

    The port of the proxy.

  • :user (String)

    The user to authenticate with the proxy as.

  • :password (String)

    The password to authenticate with the proxy.

Returns:

Since:

  • 0.6.0



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/spidr/settings/proxy.rb', line 46

def proxy=(new_proxy)
  @proxy = case new_proxy
           when Spidr::Proxy
             new_proxy
           when Hash
             Spidr::Proxy.new(**new_proxy)
           when String, URI::HTTP
             proxy_uri = URI(new_proxy)

             Spidr::Proxy.new(
                host:     proxy_uri.host,
                port:     proxy_uri.port,
                user:     proxy_uri.user,
                password: proxy_uri.password
             )
           when nil
             Spidr::Proxy.new
           else
             raise(TypeError,"#{self.class}#{__method__} only accepts Spidr::Proxy, URI::HTTP, Hash, or nil")
           end
end