Class: Everywhere::Dock::Info

Inherits:
Dock
  • Object
show all
Defined in:
lib/everywhere/dock/info.rb

Overview

The pinned footer for every preview.

Same machinery as the dev dock — it owns the terminal through Console and repaints around every write (see Dock::Screen) — but what it pins is a handful of facts rather than a set of running targets: the share link, the URL to type in by hand and the pairing token. Preview prints those once and then relays the dev server's log, which used to bury them within seconds; the whole point of the command is that someone can still see how to connect five minutes in.

It carries no state of its own to spin, so the base class's ticker only ever redraws it on a resize.

Defined Under Namespace

Classes: Null

Constant Summary collapse

KEYS =
[
  ["s", "show the QR"],
  ["r", "restart server"],
  ["q", "quit"]
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items = [], io: $stdout, keys: true, size: nil) ⇒ Info

Returns a new instance of Info.



32
33
34
35
# File 'lib/everywhere/dock/info.rb', line 32

def initialize(items = [], io: $stdout, keys: true, size: nil)
  super([], io: io, keys: keys, size: size)
  @items = items
end

Class Method Details

.open(items = [], io: $stdout, keys: true, size: nil) ⇒ Object



26
27
28
29
30
# File 'lib/everywhere/dock/info.rb', line 26

def self.open(items = [], io: $stdout, keys: true, size: nil)
  return Null.new unless drawable?(io, size)

  new(items, io: io, keys: keys, size: size).tap(&:install)
end

Instance Method Details

#keys?Boolean

Whether the keymap in the footer is a promise we can keep — the caller owns the key loop, so it has to know whether to read stdin at all.

Returns:

  • (Boolean)


39
# File 'lib/everywhere/dock/info.rb', line 39

def keys? = @keys

#show(items) ⇒ Object

Replace the facts and repaint now. A quick tunnel that dropped comes back on a different hostname, so the footer must not outlive its URL.



43
44
45
46
47
# File 'lib/everywhere/dock/info.rb', line 43

def show(items)
  @items = items
  @dirty = true
  refresh
end