"
end
def title
"Pact between #{@pact.consumer.name} and #{@pact.provider.name}"
end
def published_date
@pact.created_at.to_time.localtime.to_datetime.strftime("%a %d %b %Y, %l:%M%P %:z")
end
def json_url
PactBroker::Api::PactBrokerUrls.hal_browser_url pact_url
end
def pact_url
PactBroker::Api::PactBrokerUrls.pact_url '', @pact
end
def tags
if @pact.consumer_version_tag_names.any?
" (#{@pact.consumer_version_tag_names.join(", ")})"
else
""
end
end
def markdown
Pact::Doc::Markdown::ConsumerContractRenderer.call consumer_contract
rescue NotAPactError
heading = "### A contract between #{@pact.consumer.name} and #{@pact.provider.name}"
warning = "_Note: this contract could not be parsed to a Pact, showing raw content instead._"
pretty_json = JSON.pretty_generate(@pact.content_hash)
"#{heading}\n#{warning}\n```json\n#{pretty_json}\n```\n"
end
def html
Redcarpet::Markdown.new(Redcarpet::Render::HTML, :fenced_code_blocks => true, :lax_spacing => true).render(markdown)
end
def consumer_contract
Pact::ConsumerContract.from_json(@json_content)
rescue => e
logger.warn "#{e.class} #{e.message} #{e.backtrace.join("\n")}"
logger.warn "Could not parse the following content to a Pact, showing raw content instead: #{@json_content}"
raise NotAPactError
end
end
end
end
end