class Changelog::Notifier::Formatters::ActiveRecord

Format the given release note hash for ActiveRecord as a multiline text

Public Class Methods

new(release_note_hash) click to toggle source
# File lib/changelog/notifier/formatters/active_record.rb, line 13
def initialize(release_note_hash)
  @release_note_hash = release_note_hash
end

Public Instance Methods

format() click to toggle source
# File lib/changelog/notifier/formatters/active_record.rb, line 17
def format
  release_note = description_text + "\n\n"

  Array(@release_note_hash[:changes]).each do |change, logs|
    release_note << "#{change.capitalize}\n#{logs.join("\n")}\n\n"
  end

  # TODO : Avoids adding newlines for the last change ...
  release_note.gsub(/\n\z/, '')
end

Private Instance Methods

description_text() click to toggle source
# File lib/changelog/notifier/formatters/active_record.rb, line 30
def description_text
  "*#{formatted_application_name}* version " \
  "*#{@release_note_hash[:version]}* has just been released by " \
  "*#{@release_note_hash[:author]}* on the " \
  "*#{formatted_release_date}*.\nPlease find bellow the release note:"
end
formatted_application_name() click to toggle source
# File lib/changelog/notifier/formatters/active_record.rb, line 37
def formatted_application_name
  @release_note_hash[:application].gsub(/_/, ' ').titleize
end
formatted_release_date() click to toggle source
# File lib/changelog/notifier/formatters/active_record.rb, line 41
def formatted_release_date
  Date.parse(@release_note_hash[:date]).strftime('%b %d')
end