class Pact::Doc::Markdown::InteractionRenderer
Attributes
Public Class Methods
Source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 11 def initialize interaction, pact @interaction = InteractionViewModel.new(interaction, pact) end
Public Instance Methods
Source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 45 def h(text) Rack::Utils.escape_html(text) end
Source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 29 def render template_file ERB.new(template_string(template_file)).result(binding) end
Source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 21 def render_full_interaction if interaction.request == "ASYNC_REQUEST" render("/interaction_async.erb") else render("/interaction.erb") end end
Source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 15 def render_summary formatted_provider_states = h(interaction.formatted_provider_states) suffix = formatted_provider_states.empty? ? "" : " given #{formatted_provider_states}" "* [#{h(interaction.description(true))}](##{interaction.id})#{suffix}\n\n" end
Source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 41 def template_contents(template_file) File.dirname(__FILE__) + template_file end
Source
# File lib/pact/doc/markdown/interaction_renderer.rb, line 37 def template_string(template_file) File.read(template_contents(template_file), external_encoding: Encoding::UTF_8).force_encoding(__ENCODING__) end
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.