Sha256: 2515ac9490154ac3c57296d9771bb86a7ea0c28a47c16c476030f6e4e83ae52c

Contents?: true

Size: 774 Bytes

Versions: 4

Compression:

Stored size: 774 Bytes

Contents

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

module Pact
  module Provider
    class PactSource

      attr_reader :uri

      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 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.merge(verbose: true))
        Pact::Hal::Entity.new(uri, pact_hash, http_client)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-1.45.0 lib/pact/provider/pact_source.rb
pact-1.44.1 lib/pact/provider/pact_source.rb
pact-1.44.0 lib/pact/provider/pact_source.rb
pact-1.43.1 lib/pact/provider/pact_source.rb