Sha256: 38b94fcc53eaa1336498c16526396cc95bbd9350c88ca9c44a75144ccc5060ca

Contents?: true

Size: 849 Bytes

Versions: 4

Compression:

Stored size: 849 Bytes

Contents

module Pact
  module Doc

    class DocFile

      def initialize consumer_contract, dir, interactions_renderer, file_extension
        @dir = dir
        @consumer_contract = consumer_contract
        @interactions_renderer = interactions_renderer
        @file_extension = file_extension
      end

      def write
        File.open(path, "w") { |io|  io << doc_file_contents }
      end

      def title
        consumer_contract.provider.name
      end

      def name
        "#{consumer_contract.consumer.name} - #{consumer_contract.provider.name}#{file_extension}"
      end

      private

      attr_reader :dir, :consumer_contract, :interactions_renderer, :file_extension


      def path
        File.join(dir, name)
      end

      def doc_file_contents
        interactions_renderer.call(consumer_contract)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-1.1.0 lib/pact/doc/doc_file.rb
pact-1.1.0.rc5 lib/pact/doc/doc_file.rb
pact-1.1.0.rc4 lib/pact/doc/doc_file.rb
pact-1.1.0.rc3 lib/pact/doc/doc_file.rb