Sha256: add6a47b55087a3cd4beab4f4bd40dff705d43fb73da50c13c3587306231a13f

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

module CommitFormat
  class Formatter
    def initialize(commits)
      @commits = commits
    end

    def formatted_commits
      @commits.map { |commit| format_commit(commit) }
    end

    private

    def format_commit(commit)
      formatted_commit =
        commit.lines.map do |line|
          # Prepend another `#` characters to make headings one level lower
          if line.start_with?("##")
            "##{line}"
          else
            line
          end
        end.join
      # Start subject with a heading
      "## #{formatted_commit}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
commit_format-0.1.0 lib/commit_format/formatter.rb