Sha256: 7434e98681faeb7cb6c17b427853e3b0c642564222f182fa4583a65409567857
Contents?: true
Size: 1000 Bytes
Versions: 11
Compression:
Stored size: 1000 Bytes
Contents
# encoding: utf-8 module ProxyTester class CapybaraProxy attr_accessor :host, :user attr_reader :port, :type def port=(value) @port = value.to_i end 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 def to_sym return :no_proxy if host.blank? or port.blank? "#{host}_#{port}".to_sym end def as_phantomjs_arguments result = [] result << "--proxy=#{proxy_string}" if host || port result << "--proxy-type=#{type}" if type result << "--proxy-auth=#{user_string}" if user result end def blank? host.blank? and port.blank? end private def proxy_string "#{host}:#{port}".shellescape end def user_string user.to_string(cleartext: true).shellescape end end end
Version data entries
11 entries across 11 versions & 1 rubygems