class Pact::Provider::PactURI
Attributes
metadata[R]
options[R]
uri[R]
Public Class Methods
new(uri, options = nil, metadata = nil)
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 6 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
Public Instance Methods
==(other)
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 12 def == other other.is_a?(PactURI) && uri == other.uri && options == other.options && metadata == other.metadata end
basic_auth?()
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 19 def basic_auth? !!username && !!password end
password()
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 27 def password options[:password] end
to_s()
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 31 def to_s if basic_auth? && http_or_https_uri? begin URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s rescue URI::InvalidComponentError URI(@uri).tap { |x| x.userinfo="*****:*****"}.to_s end elsif personal_access_token? && http_or_https_uri? URI(@uri).tap { |x| x.userinfo="*****"}.to_s else uri end end
username()
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 23 def username options[:username] end
Private Instance Methods
http_or_https_uri?()
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 49 def http_or_https_uri? uri.start_with?('http://', 'https://') end
personal_access_token?()
click to toggle source
# File lib/pact/provider/pact_uri.rb, line 45 def personal_access_token? !!username && !password end