class Pliny::DbSupport::MigrationStatusPresenter

Constants

DOWN
FILE_MISSING
PADDING
STATUS_MAP
STATUS_OPTIONS
UP

Attributes

migration_statuses[R]

Public Class Methods

new(migration_statuses:) click to toggle source
# File lib/pliny/db_support.rb, line 112
def initialize(migration_statuses:)
  @migration_statuses = migration_statuses
end

Public Instance Methods

barrier_row() click to toggle source
# File lib/pliny/db_support.rb, line 144
def barrier_row
  "+#{'-' * (longest_status + PADDING)}+#{'-' * (longest_migration_name + PADDING)}+"
end
header() click to toggle source
# File lib/pliny/db_support.rb, line 124
def header
  [
    barrier_row,
    header_row,
    barrier_row
  ]
end
header_row() click to toggle source
# File lib/pliny/db_support.rb, line 148
def header_row
  "|#{'STATUS'.center(longest_status + PADDING)}|#{'MIGRATION'.center(longest_migration_name + PADDING)}|"
end
rows() click to toggle source
# File lib/pliny/db_support.rb, line 120
def rows
  header + statuses + footer
end
status_row(migration_status) click to toggle source
# File lib/pliny/db_support.rb, line 152
def status_row(migration_status)
  "|#{STATUS_MAP[migration_status.status].center(longest_status + PADDING)}|#{' ' * (PADDING / 2)}#{migration_status.filename.ljust(longest_migration_name)}#{' ' * (PADDING / 2)}|"
end
statuses() click to toggle source
# File lib/pliny/db_support.rb, line 132
def statuses
  migration_statuses.map { |status|
    status_row(status)
  }
end
to_s() click to toggle source
# File lib/pliny/db_support.rb, line 116
def to_s
  rows.join("\n")
end

Private Instance Methods

longest_migration_name() click to toggle source
# File lib/pliny/db_support.rb, line 158
def longest_migration_name
  @longest_migration_name ||= migration_statuses.map(&:filename).max_by(&:length).length
end
longest_status() click to toggle source
# File lib/pliny/db_support.rb, line 162
def longest_status
  STATUS_OPTIONS.max_by(&:length).length
end