Sha256: 618c2765cf5ee6496a1ce5ad2e73548232ea80b9d4ade27acf15faba88f83487
Contents?: true
Size: 1.02 KB
Versions: 17
Compression:
Stored size: 1.02 KB
Contents
# encoding: utf-8 module ProxyTester class HttpProxy private attr_reader :user public attr_reader :host, :port def initialize(connection_string) match = connection_string_pattern.match(connection_string) || {} raise Exceptions::ProxyConnectionStringInvalid, JSON.dump(connection_string: connection_string) if match[:host].blank? raise Exceptions::ProxyConnectionStringInvalid, JSON.dump(connection_string: connection_string) if match[:port].blank? @host = match[:host] @port = match[:port] end def use_user(user) @user = user end def to_string(options = {}) result = [] result << 'http://' if user and options[:cleartext] == true result << "#{user.name}:#{user.password}@" elsif user result << "#{user.name}:#{'*' * 4}@" if user end result << "#{host}:#{port}" result.join end private def connection_string_pattern /(?<host>[[:alnum:]._-]+):(?<port>\d+{1,5})/ end end end
Version data entries
17 entries across 17 versions & 1 rubygems