Sha256: 0e7f48c9ea6c8b4400e690842ecd7d2fbf624f6cac5090f89e82bdfd04458e07

Contents?: true

Size: 621 Bytes

Versions: 10

Compression:

Stored size: 621 Bytes

Contents

# frozen_string_literal: true

module Milestoner
  module Renderers
    # The primary renderer for multiple input formats as HTML.
    class Universal
      include Import[:input]

      DELEGATES = {asciidoc: Asciidoc.new, markdown: Markdown.new}.freeze

      def initialize(delegates: DELEGATES, **)
        super(**)
        @delegates = delegates
        @default_format = input.commit_format.to_sym
      end

      def call content, for: default_format
        delegates.fetch(binding.local_variable_get(:for)).call content
      end

      private

      attr_reader :delegates, :default_format
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
milestoner-17.11.0 lib/milestoner/renderers/universal.rb
milestoner-17.10.0 lib/milestoner/renderers/universal.rb
milestoner-17.9.0 lib/milestoner/renderers/universal.rb
milestoner-17.6.0 lib/milestoner/renderers/universal.rb
milestoner-17.5.0 lib/milestoner/renderers/universal.rb
milestoner-17.4.0 lib/milestoner/renderers/universal.rb
milestoner-17.3.0 lib/milestoner/renderers/universal.rb
milestoner-17.2.0 lib/milestoner/renderers/universal.rb
milestoner-17.1.0 lib/milestoner/renderers/universal.rb
milestoner-17.0.0 lib/milestoner/renderers/universal.rb