class ProxyTester::CapybaraProxy

Attributes

host[RW]
port[R]
type[R]
user[RW]

Public Instance Methods

as_phantomjs_arguments() click to toggle source
# File lib/proxy_tester/capybara_proxy.rb, line 37
def as_phantomjs_arguments
  result = []
  result << "--proxy=#{to_connect}" if host || port
  result << "--proxy-type=#{type}" if type
  result << "--proxy-auth=#{user.to_login(cleartext: true)}" if user

  result
end
blank?() click to toggle source
# File lib/proxy_tester/capybara_proxy.rb, line 46
def blank?
  host.blank? and port.blank?
end
port=(value) click to toggle source
# File lib/proxy_tester/capybara_proxy.rb, line 8
def port=(value)
  @port = value.to_i
end
to_connect() click to toggle source
# File lib/proxy_tester/capybara_proxy.rb, line 50
def to_connect
  "#{host}:#{port}".shellescape
end
to_sym() click to toggle source
# File lib/proxy_tester/capybara_proxy.rb, line 25
def to_sym
  return :no_proxy if host.blank? or port.blank?

  result = []

  result << host
  result << port
  result << user.name unless user.blank?

  result.join('_').to_sym
end
type=(value) click to toggle source
# File lib/proxy_tester/capybara_proxy.rb, line 12
def type=(value)
  case value
  when :none
    @type = 'none'
  when :socks5
    @type = 'socks5'
  when :http
    @type = 'http'
  else
    raise Exceptions::ProxyTypeInvalid, JSON.dump(type: value)
  end
end