Class: Agent::Lock::CLI::Commands::Listing
- Inherits:
-
Object
- Object
- Agent::Lock::CLI::Commands::Listing
- Defined in:
- lib/agent/lock/cli/commands/listing.rb
Overview
The table list prints: one row per lock in this repository.
Notes are a second row under that one, and only when asked for.
The body of a lock is a progress log, and printing it on every
list buried the four facts the row is for.
Constant Summary collapse
- HEADERS =
Column titles, in the order the row is built.
%w[Namespace Holder Scope Status Held].freeze
Instance Method Summary collapse
-
#initialize(records, tree:, stale_minutes:, notes:) ⇒ Listing
constructor
A new instance of Listing.
-
#to_s ⇒ String
The table, or the empty-store sentence.
Constructor Details
#initialize(records, tree:, stale_minutes:, notes:) ⇒ Listing
Returns a new instance of Listing.
25 26 27 28 29 30 |
# File 'lib/agent/lock/cli/commands/listing.rb', line 25 def initialize(records, tree:, stale_minutes:, notes:) @records = records @tree = tree @stale_minutes = stale_minutes @notes = notes end |
Instance Method Details
#to_s ⇒ String
Returns the table, or the empty-store sentence.
33 34 35 36 37 38 |
# File 'lib/agent/lock/cli/commands/listing.rb', line 33 def to_s return "No locks held." if @records.empty? drawn = TTY::Table.new(header: HEADERS, rows: rows).render(:unicode, padding: [0, 1], width: 1_000_000) @notes ? with_notes(drawn) : drawn end |