Sha256: e2781f51c635498db1e71ff8f9bfb65f10b137cfdb39178bd6ab83e9e5ce8f10

Contents?: true

Size: 841 Bytes

Versions: 15

Compression:

Stored size: 841 Bytes

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
      end

      def username
        options[:username]
      end

      def password
        options[:password]
      end

      def to_s
        if basic_auth? && uri.start_with?('http://', 'https://')
          URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s
        else
          uri
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pact-1.55.4 lib/pact/provider/pact_uri.rb
pact-1.55.3 lib/pact/provider/pact_uri.rb
pact-1.55.2 lib/pact/provider/pact_uri.rb
pact-1.55.1 lib/pact/provider/pact_uri.rb
pact-1.55.0 lib/pact/provider/pact_uri.rb
pact-1.54.0 lib/pact/provider/pact_uri.rb
pact-1.53.0 lib/pact/provider/pact_uri.rb
pact-1.52.0 lib/pact/provider/pact_uri.rb
pact-1.51.1 lib/pact/provider/pact_uri.rb
pact-1.51.0 lib/pact/provider/pact_uri.rb
pact-1.50.1 lib/pact/provider/pact_uri.rb
pact-1.50.0 lib/pact/provider/pact_uri.rb
pact-1.49.3 lib/pact/provider/pact_uri.rb
pact-1.49.2 lib/pact/provider/pact_uri.rb
pact-1.49.1 lib/pact/provider/pact_uri.rb