Sha256: ae206dc6ff6d1872517f8914f2cd2da79f06e191260c3836dd058359278bbaa0

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

module Nexmo
  module OAS
    module Renderer
      module Presenters
        class ApiSpecification

          def initialize(document_name:, code_language: nil)
            @document_name = document_name
            @code_language = code_language
          end

          def side_navigation
            "api/#{@document_name}"
          end

          def document_path
            "_api/#{@document_name}.md"
          end

          def document
            @document ||= File.read(document_path)
          end

          def frontmatter
            @frontmatter ||= YAML.safe_load(document)
          end

          def side_navigation_title
            @side_navigation_title ||= frontmatter.fetch('api')
          end

          def document_title
            @document_title ||= "#{side_navigation_title} > #{frontmatter.fetch('title')}"
          end

          def content
            options = {}
            options.merge(code_language: @code_language) if @code_language
            @content ||= MarkdownPipeline.new(options).call(document)
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
nexmo-oas-renderer-0.7.1 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.7.0 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.6.6 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.6.5 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.6.4 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.6.3 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.6.2 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.6.1 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.5.6 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.5.5 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.5.4 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.5.2 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.5.1 lib/nexmo/oas/renderer/presenters/api_specification.rb
nexmo-oas-renderer-0.5.0 lib/nexmo/oas/renderer/presenters/api_specification.rb