Class: Everywhere::UI::Status
- Inherits:
-
Object
- Object
- Everywhere::UI::Status
- Defined in:
- lib/everywhere/ui.rb
Overview
A single self-rewriting line for waits that produce no output — chiefly
every platform build, which can sit for many minutes while GitHub finds a
hosted macOS runner. Without it the CLI looks hung.
On a TTY it redraws in place with a spinner frame. When stdout is a pipe
(CI, | tee) carriage returns would pile up, so it degrades to one plain
line every HEADLESS_INTERVAL seconds. Callers MUST clear before writing
anything else — update tracks whether a line is currently on screen so
clear is cheap and idempotent.
NOTE: this writes to its io: directly, NOT through Console, so it is not
serialized against other writers. That's fine for its one caller
(every platform build, single-threaded) — do not reuse it concurrently.
Constant Summary collapse
Instance Method Summary collapse
-
#clear ⇒ Object
Wipe the current line so normal output lands on a clean row.
-
#initialize(io: $stdout) ⇒ Status
constructor
A new instance of Status.
- #update(text) ⇒ Object
Constructor Details
#initialize(io: $stdout) ⇒ Status
Returns a new instance of Status.
135 136 137 138 139 140 141 |
# File 'lib/everywhere/ui.rb', line 135 def initialize(io: $stdout) @io = io @tty = io.tty? && !ENV["NO_COLOR"] @frame = 0 @drawn = false @last_headless = nil end |
Instance Method Details
#clear ⇒ Object
Wipe the current line so normal output lands on a clean row. No-op when nothing is drawn (including the whole headless path).
156 157 158 159 160 161 162 |
# File 'lib/everywhere/ui.rb', line 156 def clear return unless @drawn @io.print("\r\e[2K") @io.flush @drawn = false end |