Sha256: ac2f08dd660d55ffe35059cb4851408f5ff6aa25ab05534ff07ba644e8100bbf
Contents?: true
Size: 983 Bytes
Versions: 1
Compression:
Stored size: 983 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.shellescape end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
proxy_tester-0.0.1 | lib/proxy_tester/capybara_proxy.rb |