class HubStore::Ui

Constants

FORMAT

Attributes

spinner[R]

Public Class Methods

new() click to toggle source
# File lib/hub_store/ui.rb, line 8
def initialize
  @spinner = TTY::Spinner.new(FORMAT, format: :dots_3, hide_cursor: true, interval: 20)
end

Public Instance Methods

info(progname, &block) click to toggle source
# File lib/hub_store/ui.rb, line 12
def info(progname, &block)
  case progname
  when HubLink::START
    start block.call
  when HubLink::FINISH
    stop block.call
  else
    update block.call
  end
end
start(msg) click to toggle source
# File lib/hub_store/ui.rb, line 23
def start(msg)
  spinner.update(title: format(msg), status: nil)
  spinner.auto_spin
end
stop(msg) click to toggle source
# File lib/hub_store/ui.rb, line 32
def stop(msg)
  spinner.update(status: nil)
  spinner.success("(#{format msg, :green})")
end
update(msg) click to toggle source
# File lib/hub_store/ui.rb, line 28
def update(msg)
  spinner.update(status: msg)
end

Private Instance Methods

format(msg, options = []) click to toggle source
# File lib/hub_store/ui.rb, line 41
def format(msg, options = [])
  options << :bold if msg.start_with?("*")
  pastel.decorate msg, *options
end
pastel() click to toggle source
# File lib/hub_store/ui.rb, line 46
def pastel
  @_pastel ||= Pastel.new
end