Class: Pact::Provider::PactURI
- Inherits:
-
Object
- Object
- Pact::Provider::PactURI
- Defined in:
- lib/pact/provider/pact_uri.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #basic_auth? ⇒ Boolean
-
#initialize(uri, options = nil, metadata = nil) ⇒ PactURI
constructor
A new instance of PactURI.
- #password ⇒ Object
- #to_s ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(uri, options = nil, metadata = nil) ⇒ PactURI
Returns a new instance of PactURI.
6 7 8 9 10 |
# File 'lib/pact/provider/pact_uri.rb', line 6 def initialize(uri, = nil, = nil) @uri = uri @options = || {} @metadata = || {} # make sure it's not nil if nil is passed in end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/pact/provider/pact_uri.rb', line 4 def @metadata end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/pact/provider/pact_uri.rb', line 4 def @options end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
4 5 6 |
# File 'lib/pact/provider/pact_uri.rb', line 4 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/pact/provider/pact_uri.rb', line 12 def == other other.is_a?(PactURI) && uri == other.uri && == other. && == other. end |
#basic_auth? ⇒ Boolean
19 20 21 |
# File 'lib/pact/provider/pact_uri.rb', line 19 def basic_auth? !!username && !!password end |
#password ⇒ Object
27 28 29 |
# File 'lib/pact/provider/pact_uri.rb', line 27 def password [:password] end |
#to_s ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/pact/provider/pact_uri.rb', line 23 def username [:username] end |