require 'pact/consumer_contract' require 'pact/reification' require 'redcarpet' require 'pact/doc/markdown/consumer_contract_renderer' require 'pact_broker/api/pact_broker_urls' module PactBroker module Api module Renderers class HtmlPactRenderer def self.call pact new(pact).call end def initialize pact @json_content = pact.json_content @pact = pact end def call " #{head} #{pact_metadata}#{html} " end private def head " " end def pact_metadata "
" end def published_date @pact.updated_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 markdown Pact::Doc::Markdown::ConsumerContractRenderer.call consumer_contract 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) end end end end end