Module: Dex::UI

Defined in:
lib/dex/ui.rb,
lib/dex/ui/box.rb,
lib/dex/ui/ansi.rb,
lib/dex/ui/color.rb,
lib/dex/ui/frame.rb,
lib/dex/ui/glyph.rb,
lib/dex/ui/prompt.rb,
lib/dex/ui/spinner.rb,
lib/dex/ui/progress.rb,
lib/dex/ui/terminal.rb,
lib/dex/ui/formatter.rb,
lib/dex/ui/stdout_router.rb

Defined Under Namespace

Modules: ANSI, Box, Frame, Progress, Prompt, Spinner, StdoutRouter, Terminal Classes: Color, Formatter, Glyph

Constant Summary collapse

SpinGroup =

TODO: this, better

Spinner::SpinGroup

Class Method Summary collapse

Class Method Details

.ask(question, **kwargs) ⇒ Object



36
37
38
# File 'lib/dex/ui.rb', line 36

def self.ask(question, **kwargs)
  Dex::UI::Prompt.ask(question, **kwargs)
end

.confirm(question) ⇒ Object



32
33
34
# File 'lib/dex/ui.rb', line 32

def self.confirm(question)
  Dex::UI::Prompt.confirm(question)
end

.fmt(input, enable_color: true) ⇒ Object



45
46
47
# File 'lib/dex/ui.rb', line 45

def self.fmt(input, enable_color: true)
  Dex::UI::Formatter.new(input).format(enable_color: enable_color)
end

.frame(*args, &block) ⇒ Object



49
50
51
# File 'lib/dex/ui.rb', line 49

def self.frame(*args, &block)
  Dex::UI::Frame.open(*args, &block)
end

.glyph(handle) ⇒ Object

TODO: test



18
19
20
# File 'lib/dex/ui.rb', line 18

def self.glyph(handle)
  Dex::UI::Glyph.lookup(handle)
end

.log_output_to(path) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dex/ui.rb', line 61

def self.log_output_to(path)
  if Dex::UI::StdoutRouter.duplicate_output_to
    raise "multiple logs not allowed"
  end
  Dex::UI::StdoutRouter.duplicate_output_to = File.open(path, 'w')
  yield
ensure
  f = Dex::UI::StdoutRouter.duplicate_output_to
  f.close
  Dex::UI::StdoutRouter.duplicate_output_to = nil
end

.rawObject



73
74
75
76
77
78
79
# File 'lib/dex/ui.rb', line 73

def self.raw
  prev = Thread.current[:no_dexui_frame_inset]
  Thread.current[:no_dexui_frame_inset] = true
  yield
ensure
  Thread.current[:no_dexui_frame_inset] = prev
end

.resolve_color(input) ⇒ Object

TODO: test



23
24
25
26
27
28
29
30
# File 'lib/dex/ui.rb', line 23

def self.resolve_color(input)
  case input
  when Symbol
    Dex::UI::Color.lookup(input)
  else
    input
  end
end

.resolve_text(input) ⇒ Object



40
41
42
43
# File 'lib/dex/ui.rb', line 40

def self.resolve_text(input)
  return input if input.nil?
  Dex::UI::Formatter.new(input).format
end

.spinner(*args, &block) ⇒ Object



53
54
55
# File 'lib/dex/ui.rb', line 53

def self.spinner(*args, &block)
  Dex::UI::Spinner.spin(*args, &block)
end

.with_frame_color(color, &block) ⇒ Object



57
58
59
# File 'lib/dex/ui.rb', line 57

def self.with_frame_color(color, &block)
  Dex::UI::Frame.with_frame_color_override(color, &block)
end