class MetaCommit::Changelog::Formatters::KeepAChangelogVerReportBuilder

Class builds messages with release changes according to [Keep a Changelog](keepachangelog.com/en/1.0.0/) specification @attr [String] version @attr [String] date @attr [Array<String>] added_changes Changes from “Added” section @attr [Array<String>] changed_changes Changes from “Changed” section @attr [Array<String>] deprecated_changes Changes from “Deprecated” section @attr [Array<String>] removed_changes Changes from “Removed” section @attr [Array<String>] fixed_changes Changes from “Fixed” section @attr [Array<String>] security_changes Changes from “Security” section

Attributes

added_changes[R]

attr_reader :version, :date

changed_changes[R]

attr_reader :version, :date

deprecated_changes[R]

attr_reader :version, :date

fixed_changes[R]

attr_reader :version, :date

removed_changes[R]

attr_reader :version, :date

security_changes[R]

attr_reader :version, :date

Public Class Methods

new(version, date) click to toggle source
# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 16
def initialize(version, date)
  @version=version
  @date=date
  @added_changes, @changed_changes, @deprecated_changes, @removed_changes, @fixed_changes, @security_changes = [], [], [], [], [], []
end

Public Instance Methods

add_to_added(change) click to toggle source

@param [String] change

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 23
def add_to_added(change)
  @added_changes.push(change)
end
add_to_changed(change) click to toggle source

@param [String] change

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 28
def add_to_changed(change)
  @changed_changes.push(change)
end
add_to_deprecated(change) click to toggle source

@param [String] change

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 33
def add_to_deprecated(change)
  @deprecated_changes.push(change)
end
add_to_fixed(change) click to toggle source

@param [String] change

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 43
def add_to_fixed(change)
  @fixed_changes.push(change)
end
add_to_removed(change) click to toggle source

@param [String] change

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 38
def add_to_removed(change)
  @removed_changes.push(change)
end
add_to_security(change) click to toggle source

@param [String] change

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 48
def add_to_security(change)
  @security_changes.push(change)
end
build() click to toggle source

@return [String] Report with version changes

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 111
def build
  result = [version_entry]
  result += [added_changes_group_entry] unless @added_changes.empty?
  result += [changed_changes_group_entry] unless @changed_changes.empty?
  result += [deprecated_changes_group_entry] unless @deprecated_changes.empty?
  result += [removed_changes_group_entry] unless @removed_changes.empty?
  result += [fixed_changes_group_entry] unless @fixed_changes.empty?
  result += [security_changes_group_entry] unless @security_changes.empty?
  result.join("\n")
end

Private Instance Methods

added_changes_group_entry() click to toggle source

@return [String] List of added changes with header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 69
def added_changes_group_entry
  changes_group_entry('Added', @added_changes)
end
changed_changes_group_entry() click to toggle source

@return [String] List of changed changes with header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 76
def changed_changes_group_entry
  changes_group_entry('Changed', @changed_changes)
end
changes_group_entry(type, changes) click to toggle source

@return [String] List of changes with type header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 60
def changes_group_entry(type, changes)
  header = ["### #{type}"]
  list = changes.map { |change| "- #{change}" }
  ([header] + list).uniq.join("\n")
end
deprecated_changes_group_entry() click to toggle source

@return [String] List of deprecated changes with header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 83
def deprecated_changes_group_entry
  changes_group_entry('Deprecated', @deprecated_changes)
end
fixed_changes_group_entry() click to toggle source

@return [String] List of fixed changes with header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 97
def fixed_changes_group_entry
  changes_group_entry('Fixed', @fixed_changes)
end
removed_changes_group_entry() click to toggle source

@return [String] List of removed changes with header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 90
def removed_changes_group_entry
  changes_group_entry('Removed', @removed_changes)
end
security_changes_group_entry() click to toggle source

@return [String] List of security changes with header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 104
def security_changes_group_entry
  changes_group_entry('Security', @security_changes)
end
version_entry() click to toggle source

@return [String] Version header

# File lib/meta_commit/changelog/formatters/keep_a_changelog_ver_report_builder.rb, line 53
def version_entry
  "## [#{@version}] - #{@date}"
end