Sha256: e64a0b4c80a15dae9646552e56ea70cf2ff0c6ecaf287ff52ecf46cb072909a3

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

require 'pact/consumer_contract'
require 'pact/reification'
require 'redcarpet'

module PactBroker
  module Api
    module Renderers
      class HtmlPactRenderer

        def self.call json_content
          new(json_content).call
        end

        def initialize json_content
          @json_content = json_content
        end

        def call
          "<html><head>#{head}</head><body>#{html}</body></html>"
        end

        private

        def head
          '<link rel="stylesheet" type="text/css" href="/stylesheets/github.css">'
        end

        def markdown
          Pact::Doc::Markdown::InteractionsRenderer.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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact_broker-1.0.0 lib/pact_broker/api/renderers/html_pact_renderer.rb
pact_broker-1.0.0.alpha3 lib/pact_broker/api/renderers/html_pact_renderer.rb
pact_broker-1.0.0.alpha2 lib/pact_broker/api/renderers/html_pact_renderer.rb
pact_broker-1.0.0.alpha1 lib/pact_broker/api/renderers/html_pact_renderer.rb