Sha256: b1b9f5263c680fcd3e987a7e8d861c35a01cb9d9178af868d91efd29928bbebb

Contents?: true

Size: 818 Bytes

Versions: 47

Compression:

Stored size: 818 Bytes

Contents

module Pact
  module Doc
    module Markdown
      class IndexRenderer

        attr_reader :consumer_name
        attr_reader :docs # Hash of pact title => file_name

        def initialize consumer_name, docs
          @consumer_name = consumer_name
          @docs = docs
        end

        def self.call consumer_name, docs
          new(consumer_name, docs).call
        end

        def call
          title + "\n\n" + table_of_contents + "\n"
        end

        private

        def table_of_contents
          docs.collect do | title, file_name |
            item title, file_name
          end.join("\n")
        end

        def title
          "### Pacts for #{consumer_name}"
        end

        def item title, file_name
          "* [#{title}](#{file_name})"
        end

      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
pact-1.22.2 lib/pact/doc/markdown/index_renderer.rb
pact-1.22.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.21.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.20.1 lib/pact/doc/markdown/index_renderer.rb
pact-1.20.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.19.2 lib/pact/doc/markdown/index_renderer.rb
pact-1.19.1 lib/pact/doc/markdown/index_renderer.rb
pact-1.19.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.18.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.17.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.16.1 lib/pact/doc/markdown/index_renderer.rb
pact-1.16.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.15.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.14.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.13.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.12.1 lib/pact/doc/markdown/index_renderer.rb
pact-1.12.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.11.1 lib/pact/doc/markdown/index_renderer.rb
pact-1.11.0 lib/pact/doc/markdown/index_renderer.rb
pact-1.10.0 lib/pact/doc/markdown/index_renderer.rb