Class: Pliny::DbSupport::MigrationStatusPresenter
- Inherits:
-
Object
- Object
- Pliny::DbSupport::MigrationStatusPresenter
- Defined in:
- lib/pliny/db_support.rb
Constant Summary collapse
- PADDING =
2
- UP =
"UP".freeze
- DOWN =
"DOWN".freeze
- FILE_MISSING =
"FILE MISSING".freeze
- STATUS_MAP =
{ up: UP, down: DOWN, file_missing: FILE_MISSING }.freeze
- STATUS_OPTIONS =
[ UP, DOWN, FILE_MISSING ].freeze
Instance Attribute Summary collapse
-
#migration_statuses ⇒ Object
readonly
Returns the value of attribute migration_statuses.
Instance Method Summary collapse
- #barrier_row ⇒ Object
- #footer ⇒ Object
- #header ⇒ Object
- #header_row ⇒ Object
-
#initialize(migration_statuses:) ⇒ MigrationStatusPresenter
constructor
A new instance of MigrationStatusPresenter.
- #rows ⇒ Object
- #status_row(migration_status) ⇒ Object
- #statuses ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(migration_statuses:) ⇒ MigrationStatusPresenter
Returns a new instance of MigrationStatusPresenter.
112 113 114 |
# File 'lib/pliny/db_support.rb', line 112 def initialize(migration_statuses:) @migration_statuses = migration_statuses end |
Instance Attribute Details
#migration_statuses ⇒ Object (readonly)
Returns the value of attribute migration_statuses.
110 111 112 |
# File 'lib/pliny/db_support.rb', line 110 def migration_statuses @migration_statuses end |
Instance Method Details
#barrier_row ⇒ Object
144 145 146 |
# File 'lib/pliny/db_support.rb', line 144 def "+#{'-' * (longest_status + PADDING)}+#{'-' * (longest_migration_name + PADDING)}+" end |
#footer ⇒ Object
138 139 140 141 142 |
# File 'lib/pliny/db_support.rb', line 138 def [ ] end |
#header ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/pliny/db_support.rb', line 124 def header [ , header_row, ] end |
#header_row ⇒ Object
148 149 150 |
# File 'lib/pliny/db_support.rb', line 148 def header_row "|#{'STATUS'.center(longest_status + PADDING)}|#{'MIGRATION'.center(longest_migration_name + PADDING)}|" end |
#rows ⇒ Object
120 121 122 |
# File 'lib/pliny/db_support.rb', line 120 def rows header + statuses + end |
#status_row(migration_status) ⇒ Object
152 153 154 |
# 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 ⇒ Object
132 133 134 135 136 |
# File 'lib/pliny/db_support.rb', line 132 def statuses migration_statuses.map { |status| status_row(status) } end |
#to_s ⇒ Object
116 117 118 |
# File 'lib/pliny/db_support.rb', line 116 def to_s rows.join("\n") end |