Sha256: e355eb4008ca7b5882e464d170db3932d8a2d8026f85843c1e4a05fc3d312bf3

Contents?: true

Size: 977 Bytes

Versions: 20

Compression:

Stored size: 977 Bytes

Contents

require 'pact/consumer_contract/pact_file'
require 'pact/hal/http_client'
require 'pact/hal/entity'
require 'pact/consumer_contract'

module Pact
  module Provider
    class PactSource

      attr_reader :uri # PactURI class

      def initialize uri
        @uri = uri
      end

      def pact_json
        @pact_json ||= Pact::PactFile.read(uri.uri, uri.options)
      end

      def pact_hash
        @pact_hash ||= JSON.load(pact_json, nil, { max_nesting: 50 })
      end

      def pending?
        uri.metadata[:pending]
      end

      def consumer_contract
        @consumer_contract ||= Pact::ConsumerContract.from_json(pact_json)
      end

      def hal_entity
        http_client_keys = [:username, :password, :token]
        http_client_options = uri.options.reject{ |k, _| !http_client_keys.include?(k) }
        http_client = Pact::Hal::HttpClient.new(http_client_options)
        Pact::Hal::Entity.new(uri, pact_hash, http_client)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
pact-1.66.1 lib/pact/provider/pact_source.rb
pact-1.66.0 lib/pact/provider/pact_source.rb
pact-1.65.3 lib/pact/provider/pact_source.rb
pact-1.65.2 lib/pact/provider/pact_source.rb
pact-1.65.1 lib/pact/provider/pact_source.rb
pact-1.65.0 lib/pact/provider/pact_source.rb
pact-1.64.0 lib/pact/provider/pact_source.rb
pact-1.63.0 lib/pact/provider/pact_source.rb
pact-1.62.0 lib/pact/provider/pact_source.rb
pact-1.61.0 lib/pact/provider/pact_source.rb
pact-1.60.0 lib/pact/provider/pact_source.rb
pact-1.59.0 lib/pact/provider/pact_source.rb
pact-1.58.0 lib/pact/provider/pact_source.rb
pact-1.57.0 lib/pact/provider/pact_source.rb
pact-1.56.0 lib/pact/provider/pact_source.rb
pact-1.55.7 lib/pact/provider/pact_source.rb
pact-1.55.6 lib/pact/provider/pact_source.rb
pact-1.55.5 lib/pact/provider/pact_source.rb
pact-1.55.4 lib/pact/provider/pact_source.rb
pact-1.55.3 lib/pact/provider/pact_source.rb