Class: Pvectl::Presenters::AptPackage
- Defined in:
- lib/pvectl/presenters/apt_package.rb
Overview
Presenter for APT packages (pending updates and installed versions).
Standard columns highlight the upgrade path; wide columns add metadata useful when triaging updates.
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for standard table output.
-
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
-
#extra_values(model, **_context) ⇒ Array<String>
Returns additional values for wide output.
-
#to_hash(model) ⇒ Hash
Converts AptPackage model to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts AptPackage model to table row values.
Methods inherited from Base
#tags_array, #tags_display, #template_display, #to_description, #to_wide_row, #uptime_human, #wide_columns
Instance Method Details
#columns ⇒ Array<String>
Returns column headers for standard table output.
21 22 23 |
# File 'lib/pvectl/presenters/apt_package.rb', line 21 def columns %w[NODE PACKAGE CURRENT AVAILABLE ORIGIN] end |
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
28 29 30 |
# File 'lib/pvectl/presenters/apt_package.rb', line 28 def extra_columns %w[ARCH SECTION PRIORITY DESCRIPTION] end |
#extra_values(model, **_context) ⇒ Array<String>
Returns additional values for wide output.
52 53 54 55 56 57 58 59 |
# File 'lib/pvectl/presenters/apt_package.rb', line 52 def extra_values(model, **_context) [ model.arch || "-", model.section || "-", model.priority || "-", truncate(model.description, 60) ] end |
#to_hash(model) ⇒ Hash
Converts AptPackage model to hash for JSON/YAML output.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/pvectl/presenters/apt_package.rb', line 65 def to_hash(model) { "node" => model.node, "package" => model.package, "title" => model.title, "current_version" => model.old_version, "available_version" => model.version, "origin" => model.origin, "arch" => model.arch, "section" => model.section, "priority" => model.priority, "description" => model.description, "notify_status" => model.notify_status, "current_state" => model.current_state, "manager_version" => model.manager_version, "running_kernel" => model.running_kernel } end |
#to_row(model, **_context) ⇒ Array<String>
Converts AptPackage model to table row values.
37 38 39 40 41 42 43 44 45 |
# File 'lib/pvectl/presenters/apt_package.rb', line 37 def to_row(model, **_context) [ model.node || "-", model.package || "-", model.old_version || "-", model.version || "-", model.origin || "-" ] end |