Class: Quke::ProxyConfiguration
- Inherits:
-
Object
- Object
- Quke::ProxyConfiguration
- Defined in:
- lib/quke/proxy_configuration.rb
Overview
Manages all parallel configuration for Quke.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
The host address for the proxy server.
-
#no_proxy ⇒ Object
readonly
In some cases you may also need to tell the driver not to use the proxy for local or specific connections.
-
#port ⇒ Object
readonly
The port number for the proxy server.
Instance Method Summary collapse
-
#firefox_settings ⇒ Object
Returns a hash of settings specific to initialising a
Selenium::WebDriver::Proxy
instance, which will be created as part of registering the Selenium firefox driver. -
#initialize(data = {}) ⇒ ProxyConfiguration
constructor
A new instance of ProxyConfiguration.
-
#use_proxy? ⇒ Boolean
Return true if the
host
value has been set in the.config.yml
file, else false.
Constructor Details
#initialize(data = {}) ⇒ ProxyConfiguration
Returns a new instance of ProxyConfiguration.
19 20 21 22 23 |
# File 'lib/quke/proxy_configuration.rb', line 19 def initialize(data = {}) @host = (data["host"] || "").downcase.strip @port = (data["port"] || "0").to_s.downcase.strip.to_i @no_proxy = (data["no_proxy"] || "").downcase.strip end |
Instance Attribute Details
#host ⇒ Object (readonly)
The host address for the proxy server
9 10 11 |
# File 'lib/quke/proxy_configuration.rb', line 9 def host @host end |
#no_proxy ⇒ Object (readonly)
In some cases you may also need to tell the driver not to use the proxy for local or specific connections. This returns a comma separated list of addresses of those addresses if set.
17 18 19 |
# File 'lib/quke/proxy_configuration.rb', line 17 def no_proxy @no_proxy end |
#port ⇒ Object (readonly)
The port number for the proxy server
12 13 14 |
# File 'lib/quke/proxy_configuration.rb', line 12 def port @port end |
Instance Method Details
#firefox_settings ⇒ Object
Returns a hash of settings specific to initialising a Selenium::WebDriver::Proxy
instance, which will be created as part of registering the Selenium firefox driver
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/quke/proxy_configuration.rb', line 37 def firefox_settings settings = {} return settings unless use_proxy? settings[:http] = "#{host}:#{port}" settings[:ssl] = settings[:http] settings[:no_proxy] = no_proxy unless no_proxy.empty? settings end |
#use_proxy? ⇒ Boolean
Return true if the host
value has been set in the .config.yml
file, else false.
It is mainly used when determining whether to apply proxy server settings to the different drivers when registering them with Capybara.
30 31 32 |
# File 'lib/quke/proxy_configuration.rb', line 30 def use_proxy? @host != "" end |