class Pact::Doc::Markdown::InteractionRenderer
Attributes
interaction[R]
Public Class Methods
new(interaction, pact)
click to toggle source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 11 def initialize interaction, pact @interaction = InteractionViewModel.new(interaction, pact) end
Public Instance Methods
render(template_file)
click to toggle source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 24 def render template_file ERB.new(template_string(template_file)).result(binding) end
render_full_interaction()
click to toggle source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 20 def render_full_interaction render('/interaction.erb') end
render_summary()
click to toggle source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 15 def render_summary suffix = interaction.has_provider_state? ? " given #{interaction.provider_state}" : "" "* [#{interaction.description(true)}](##{interaction.id})#{suffix}\n\n" end
template_contents(template_file)
click to toggle source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 36 def template_contents(template_file) File.dirname(__FILE__) + template_file end
template_string(template_file)
click to toggle source
The template file is written with only ASCII range characters, so we can read as UTF-8. But rendered strings must have same encoding as script encoding because it will joined to strings which are produced by string literal.
# File lib/pact/doc/markdown/interaction_renderer.rb, line 32 def template_string(template_file) File.read(template_contents(template_file), external_encoding: Encoding::UTF_8).force_encoding(__ENCODING__) end