Sha256: b143073bbcb441bf2dfe4bcf497f8ab6e035da76e2ced771718322d059b22052
Contents?: true
Size: 1.11 KB
Versions: 5
Compression:
Stored size: 1.11 KB
Contents
module Pact module Provider class PactURI attr_reader :uri, :options, :metadata def initialize (uri, options = nil, metadata = nil) @uri = uri @options = options || {} @metadata = metadata || {} # make sure it's not nil if nil is passed in end def == other other.is_a?(PactURI) && uri == other.uri && options == other.options && metadata == other.metadata end def basic_auth? !!username && !!password end def username options[:username] end def password options[:password] end def to_s if basic_auth? && http_or_https_uri? URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s elsif personal_access_token? && http_or_https_uri? URI(@uri).tap { |x| x.userinfo="*****"}.to_s else uri end end private def personal_access_token? !!username && !password end private def http_or_https_uri? uri.start_with?('http://', 'https://') end end end end
Version data entries
5 entries across 5 versions & 1 rubygems