Class: Selenium::WebDriver::Proxy
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Proxy
- Defined in:
- lib/selenium/webdriver/common/proxy.rb
Constant Summary collapse
- TYPES =
{ :direct => "DIRECT", # Direct connection, no proxy (default on Windows). :manual => "MANUAL", # Manual proxy settings (e.g., for httpProxy). :pac => "PAC", # Proxy autoconfiguration from URL. :auto_detect => "AUTODETECT", # Proxy autodetection (presumably with WPAD). :system => "SYSTEM" # Use system settings (default on Linux). }
Instance Attribute Summary collapse
-
#auto_detect ⇒ Object
Returns the value of attribute auto_detect.
-
#ftp ⇒ Object
Returns the value of attribute ftp.
-
#http ⇒ Object
Returns the value of attribute http.
-
#no_proxy ⇒ Object
Returns the value of attribute no_proxy.
-
#pac ⇒ Object
Returns the value of attribute pac.
-
#ssl ⇒ Object
Returns the value of attribute ssl.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #as_json(opts = nil) ⇒ Object
-
#initialize(opts = {}) ⇒ Proxy
constructor
A new instance of Proxy.
Constructor Details
#initialize(opts = {}) ⇒ Proxy
Returns a new instance of Proxy.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 20 def initialize(opts = {}) opts = opts.dup self.type = opts.delete(:type) if opts.has_key? :type self.ftp = opts.delete(:ftp) if opts.has_key? :ftp self.http = opts.delete(:http) if opts.has_key? :http self.no_proxy = opts.delete(:no_proxy) if opts.has_key? :no_proxy self.ssl = opts.delete(:ssl) if opts.has_key? :ssl self.pac = opts.delete(:pac) if opts.has_key? :pac self.auto_detect = opts.delete(:auto_detect) if opts.has_key? :auto_detect unless opts.empty? raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}" end end |
Instance Attribute Details
#auto_detect ⇒ Object
Returns the value of attribute auto_detect.
12 13 14 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 12 def auto_detect @auto_detect end |
#ftp ⇒ Object
Returns the value of attribute ftp.
12 13 14 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 12 def ftp @ftp end |
#http ⇒ Object
Returns the value of attribute http.
12 13 14 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 12 def http @http end |
#no_proxy ⇒ Object
Returns the value of attribute no_proxy.
12 13 14 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 12 def no_proxy @no_proxy end |
#pac ⇒ Object
Returns the value of attribute pac.
12 13 14 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 12 def pac @pac end |
#ssl ⇒ Object
Returns the value of attribute ssl.
12 13 14 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 12 def ssl @ssl end |
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 12 def type @type end |
Class Method Details
.json_create(data) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 99 def json_create(data) proxy = new proxy.type = data['proxyType'].downcase.to_sym if data.has_key? 'proxyType' proxy.ftp = data['ftpProxy'] if data.has_key? 'ftpProxy' proxy.http = data['httpProxy'] if data.has_key? 'httpProxy' proxy.no_proxy = data['noProxy'] if data.has_key? 'noProxy' proxy.pac = data['proxyAutoconfigUrl'] if data.has_key? 'proxyAutoconfigUrl' proxy.ssl = data['sslProxy'] if data.has_key? 'sslProxy' proxy.auto_detect = data['autodetect'] if data.has_key? 'autodetect' proxy end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
36 37 38 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 36 def ==(other) other.kind_of?(self.class) && as_json == other.as_json end |
#as_json(opts = nil) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/selenium/webdriver/common/proxy.rb', line 83 def as_json(opts = nil) json_result = { "proxyType" => TYPES[type] } json_result["ftpProxy"] = ftp if ftp json_result["httpProxy"] = http if http json_result["noProxy"] = no_proxy if no_proxy json_result["proxyAutoconfigUrl"] = pac if pac json_result["sslProxy"] = ssl if ssl json_result["autodetect"] = auto_detect if auto_detect json_result if json_result.length > 1 end |