Sha256: 71eede64ad6e730a2f3a50fe8d8ae1910691092a7b849487952dec3fd2d887f2

Contents?: true

Size: 956 Bytes

Versions: 4

Compression:

Stored size: 956 Bytes

Contents

require 'erb'
require 'pact/doc/interaction_view_model'

module Pact
  module Doc
    module Markdown
      class InteractionRenderer

        attr_reader :interaction

        def initialize interaction, pact
          @interaction = InteractionViewModel.new(interaction, pact)
        end

        def render_summary
          suffix = interaction.has_provider_state? ? " given #{interaction.provider_state}" : ""
          "* [#{interaction.description(true)}](##{interaction.id})#{suffix}\n\n"
        end

        def render_full_interaction
          render('/interaction.erb')
        end

        def render template_file
          ERB.new(template_string(template_file)).result(binding)
        end

        def template_string(template_file)
          File.read( template_contents(template_file) )
        end

        def template_contents(template_file)
          File.dirname(__FILE__) + template_file
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-1.9.4 lib/pact/doc/markdown/interaction_renderer.rb
pact-1.9.3 lib/pact/doc/markdown/interaction_renderer.rb
pact-1.9.2 lib/pact/doc/markdown/interaction_renderer.rb
pact-1.9.1 lib/pact/doc/markdown/interaction_renderer.rb