Module: Dev::UI
- Defined in:
- lib/dev/ui.rb,
lib/dev/ui/box.rb,
lib/dev/ui/ansi.rb,
lib/dev/ui/color.rb,
lib/dev/ui/frame.rb,
lib/dev/ui/glyph.rb,
lib/dev/ui/prompt.rb,
lib/dev/ui/spinner.rb,
lib/dev/ui/version.rb,
lib/dev/ui/progress.rb,
lib/dev/ui/terminal.rb,
lib/dev/ui/formatter.rb,
lib/dev/ui/spinner/async.rb,
lib/dev/ui/stdout_router.rb,
lib/dev/ui/interactive_prompt.rb,
lib/dev/ui/spinner/spin_group.rb
Defined Under Namespace
Modules: ANSI, Box, Frame, Prompt, Spinner, StdoutRouter, Terminal Classes: Color, Formatter, Glyph, InteractivePrompt, Progress
Constant Summary collapse
- SpinGroup =
Convenience accessor to
Dev::UI::Spinner::SpinGroup Spinner::SpinGroup
- VERSION =
"0.1.1"
Class Method Summary collapse
-
.ask(question, **kwargs) ⇒ Object
Conviencence Method for
Dev::UI::Prompt.ask. -
.confirm(question) ⇒ Object
Conviencence Method for
Dev::UI::Prompt.confirm. -
.fmt(input, enable_color: true) ⇒ Object
Conviencence Method to format text using
Dev::UI::Formatter.formatCheckDev::UI::Formatter::SGR_MAPfor available formatting options. -
.frame(*args, &block) ⇒ Object
Conviencence Method for
Dev::UI::Frame.open. -
.glyph(handle) ⇒ Object
Glyph resolution using
Dev::UI::Glyph.lookupLook at the method signature forGlyph.lookupfor more details. -
.log_output_to(path) ⇒ Object
Duplicate output to a file path.
-
.raw ⇒ Object
Disable all framing within a block.
-
.resolve_color(input) ⇒ Object
Color resolution using
Dev::UI::Color.lookupWill lookup usingColor.lookupif a symbol, otherwise we assume it is a valid color and return it. -
.resolve_text(input) ⇒ Object
Conviencence Method to resolve text using
Dev::UI::Formatter.formatCheckDev::UI::Formatter::SGR_MAPfor available formatting options. -
.spinner(*args, &block) ⇒ Object
Conviencence Method for
Dev::UI::Spinner.spin. -
.with_frame_color(color, &block) ⇒ Object
Conviencence Method to override frame color using
Dev::UI::Frame.with_frame_color.
Class Method Details
.ask(question, **kwargs) ⇒ Object
Conviencence Method for Dev::UI::Prompt.ask
Attributes
-
question- question to ask -
kwargs- arugments forPrompt.ask
62 63 64 |
# File 'lib/dev/ui.rb', line 62 def self.ask(question, **kwargs) Dev::UI::Prompt.ask(question, **kwargs) end |
.confirm(question) ⇒ Object
Conviencence Method for Dev::UI::Prompt.confirm
Attributes
-
question- question to confirm
51 52 53 |
# File 'lib/dev/ui.rb', line 51 def self.confirm(question) Dev::UI::Prompt.confirm(question) end |
.fmt(input, enable_color: true) ⇒ Object
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
92 93 94 |
# File 'lib/dev/ui.rb', line 92 def self.fmt(input, enable_color: true) Dev::UI::Formatter.new(input).format(enable_color: enable_color) end |
.frame(*args, &block) ⇒ Object
Conviencence Method for Dev::UI::Frame.open
Attributes
-
args- arguments forFrame.open -
block- block forFrame.open
103 104 105 |
# File 'lib/dev/ui.rb', line 103 def self.frame(*args, &block) Dev::UI::Frame.open(*args, &block) end |
.glyph(handle) ⇒ Object
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
25 26 27 |
# File 'lib/dev/ui.rb', line 25 def self.glyph(handle) Dev::UI::Glyph.lookup(handle) end |
.log_output_to(path) ⇒ Object
Duplicate output to a file path
Attributes
-
path- path to duplicate output to
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/dev/ui.rb', line 135 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 ⇒ Object
Disable all framing within a block
Attributes
-
block- block in which to disable frames
154 155 156 157 158 159 160 |
# File 'lib/dev/ui.rb', line 154 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) ⇒ Object
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
36 37 38 39 40 41 42 43 |
# File 'lib/dev/ui.rb', line 36 def self.resolve_color(input) case input when Symbol Dev::UI::Color.lookup(input) else input end end |
.resolve_text(input) ⇒ Object
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
73 74 75 76 |
# File 'lib/dev/ui.rb', line 73 def self.resolve_text(input) return input if input.nil? Dev::UI::Formatter.new(input).format end |
.spinner(*args, &block) ⇒ Object
Conviencence Method for Dev::UI::Spinner.spin
Attributes
-
args- arguments forSpinner.open -
block- block forSpinner.open
114 115 116 |
# File 'lib/dev/ui.rb', line 114 def self.spinner(*args, &block) Dev::UI::Spinner.spin(*args, &block) end |
.with_frame_color(color, &block) ⇒ Object
Conviencence Method to override frame color using Dev::UI::Frame.with_frame_color
Attributes
-
color- color to override to -
block- block forFrame.with_frame_color_override
125 126 127 |
# File 'lib/dev/ui.rb', line 125 def self.with_frame_color(color, &block) Dev::UI::Frame.with_frame_color_override(color, &block) end |