Module: Spidr::Settings::Proxy
- Included in:
- Spidr, Spidr::SessionCache
- Defined in:
- lib/spidr/settings/proxy.rb
Overview
Methods for configuring a proxy.
Instance Method Summary collapse
-
#disable_proxy! ⇒ Object
Disables the proxy settings used by all newly created Agent objects.
-
#proxy ⇒ Spidr::Proxy
Proxy information used by all newly created Agent objects by default.
-
#proxy=(new_proxy) ⇒ Spidr::Proxy
Sets the proxy information used by Agent objects.
Instance Method Details
#disable_proxy! ⇒ Object
Disables the proxy settings used by all newly created Agent objects.
71 72 73 74 |
# File 'lib/spidr/settings/proxy.rb', line 71 def disable_proxy! @proxy = Spidr::Proxy.new return true end |
#proxy ⇒ Spidr::Proxy
Proxy information used by all newly created Agent objects by default.
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.
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 |