Sha256: 557ce04f047e52e8ae620b90d197ee2ed86acfa205aca4fc7fa6a80fa9bd382f

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

module Milestoner
  module Commits
    module Enrichers
      # Enriches commit text by rendering as HTML based on trailer information.
      class Body
        include Milestoner::Import[:settings]

        def initialize(key: "Format", renderer: Renderers::Universal.new, **)
          super(**)
          @key = key
          @renderer = renderer
        end

        def call commit
          commit.trailer_value_for(key)
                .value_or(settings.commit_format)
                .then { |format| renderer.call commit.body, for: format.to_sym }
        end

        private

        attr_reader :key, :renderer
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
milestoner-18.12.0 lib/milestoner/commits/enrichers/body.rb