module Dev::UI

Constants

SpinGroup

Convenience accessor to Dev::UI::Spinner::SpinGroup

VERSION

Public Class Methods

ask(question, **kwargs) click to toggle source

Conviencence Method for Dev::UI::Prompt.ask

Attributes

  • question - question to ask

  • kwargs - arugments for Prompt.ask

# File lib/dev/ui.rb, line 61
def self.ask(question, **kwargs)
  Dev::UI::Prompt.ask(question, **kwargs)
end
confirm(question) click to toggle source

Conviencence Method for Dev::UI::Prompt.confirm

Attributes

  • question - question to confirm

# File lib/dev/ui.rb, line 50
def self.confirm(question)
  Dev::UI::Prompt.confirm(question)
end
fmt(input, enable_color: true) click to toggle source

Conviencence Method to format text using Dev::UI::Formatter.format Check Dev::UI::Formatter::SGR_MAP for available formatting options

Attributes

  • input - input to format

Options

  • enable_color - should color be used? default to true

# File lib/dev/ui.rb, line 91
def self.fmt(input, enable_color: true)
  Dev::UI::Formatter.new(input).format(enable_color: enable_color)
end
frame(*args, &block) click to toggle source

Conviencence Method for Dev::UI::Frame.open

Attributes

  • args - arguments for Frame.open

  • block - block for Frame.open

# File lib/dev/ui.rb, line 102
def self.frame(*args, &block)
  Dev::UI::Frame.open(*args, &block)
end
glyph(handle) click to toggle source

Glyph resolution using Dev::UI::Glyph.lookup Look at the method signature for Glyph.lookup for more details

Attributes

  • handle - handle of the glyph to resolve

# File lib/dev/ui.rb, line 24
def self.glyph(handle)
  Dev::UI::Glyph.lookup(handle)
end
log_output_to(path) { || ... } click to toggle source

Duplicate output to a file path

Attributes

  • path - path to duplicate output to

# File lib/dev/ui.rb, line 134
def self.log_output_to(path)
  if Dev::UI::StdoutRouter.duplicate_output_to
    raise "multiple logs not allowed"
  end
  Dev::UI::StdoutRouter.duplicate_output_to = File.open(path, 'w')
  yield
ensure
  if file_descriptor = Dev::UI::StdoutRouter.duplicate_output_to
    file_descriptor.close
    Dev::UI::StdoutRouter.duplicate_output_to = nil
  end
end
raw() { || ... } click to toggle source

Disable all framing within a block

Attributes

  • block - block in which to disable frames

# File lib/dev/ui.rb, line 153
def self.raw
  prev = Thread.current[:no_devui_frame_inset]
  Thread.current[:no_devui_frame_inset] = true
  yield
ensure
  Thread.current[:no_devui_frame_inset] = prev
end
resolve_color(input) click to toggle source

Color resolution using Dev::UI::Color.lookup Will lookup using Color.lookup if a symbol, otherwise we assume it is a valid color and return it

Attributes

  • input - color to resolve

# File lib/dev/ui.rb, line 35
def self.resolve_color(input)
  case input
  when Symbol
    Dev::UI::Color.lookup(input)
  else
    input
  end
end
resolve_text(input) click to toggle source

Conviencence Method to resolve text using Dev::UI::Formatter.format Check Dev::UI::Formatter::SGR_MAP for available formatting options

Attributes

  • input - input to format

# File lib/dev/ui.rb, line 72
def self.resolve_text(input)
  return input if input.nil?
  Dev::UI::Formatter.new(input).format
end
spinner(*args, &block) click to toggle source

Conviencence Method for Dev::UI::Spinner.spin

Attributes

  • args - arguments for Spinner.open

  • block - block for Spinner.open

# File lib/dev/ui.rb, line 113
def self.spinner(*args, &block)
  Dev::UI::Spinner.spin(*args, &block)
end
with_frame_color(color, &block) click to toggle source

Conviencence Method to override frame color using Dev::UI::Frame.with_frame_color

Attributes

  • color - color to override to

  • block - block for Frame.with_frame_color_override

# File lib/dev/ui.rb, line 124
def self.with_frame_color(color, &block)
  Dev::UI::Frame.with_frame_color_override(color, &block)
end