class Pact::Doc::Markdown::ConsumerContractRenderer

Attributes

consumer_contract[R]

Public Class Methods

call(consumer_contract) click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 14
def self.call consumer_contract
  new(consumer_contract).call
end
new(consumer_contract) click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 10
def initialize consumer_contract
  @consumer_contract = consumer_contract
end

Public Instance Methods

call() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 18
def call
  title + summaries_title + summaries + interactions_title + full_interactions
end

Private Instance Methods

consumer_name() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 54
def consumer_name
  h(markdown_escape consumer_contract.consumer.name)
end
full_interactions() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 46
def full_interactions
  interaction_renderers.collect(&:render_full_interaction).join
end
h(text) click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 66
def h(text)
  Rack::Utils.escape_html(text)
end
interaction_renderers() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 30
def interaction_renderers
  @interaction_renderers ||= sorted_interactions.collect{|interaction| InteractionRenderer.new interaction, @consumer_contract}
end
interactions_title() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 38
def interactions_title
  "### Interactions\n\n"
end
markdown_escape(string) click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 62
def markdown_escape string
  string.gsub("*","\\*").gsub("_","\\_")
end
provider_name() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 58
def provider_name
  h(markdown_escape consumer_contract.provider.name)
end
sorted_interactions() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 50
def sorted_interactions
  SortInteractions.call(consumer_contract.interactions)
end
summaries() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 42
def summaries
  interaction_renderers.collect(&:render_summary).join
end
summaries_title() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 34
def summaries_title
  "### Requests from #{consumer_name} to #{provider_name}\n\n"
end
title() click to toggle source
# File lib/pact/doc/markdown/consumer_contract_renderer.rb, line 26
def title
  "# A pact between #{consumer_name} and #{provider_name}\n\n"
end