Module: Smol::Output
- Extended by:
- Output
- Included in:
- CLI, Command, ConfigDisplay, Output, REPL
- Defined in:
- lib/smol/output.rb
Instance Method Summary collapse
- #banner(text) ⇒ Object
- #check_result(name, result) ⇒ Object
- #debug(text) ⇒ Object
- #desc(text) ⇒ Object
- #failure(text) ⇒ Object
- #header(text) ⇒ Object
- #hint(text) ⇒ Object
- #info(text) ⇒ Object
- #label(text) ⇒ Object
- #nl ⇒ Object
- #out ⇒ Object
- #success(text) ⇒ Object
- #table(rows, headers: nil, indent: 0) ⇒ Object
- #verbose(text) ⇒ Object
- #warning(text) ⇒ Object
Instance Method Details
#banner(text) ⇒ Object
12 13 14 |
# File 'lib/smol/output.rb', line 12 def (text) out.puts text.red end |
#check_result(name, result) ⇒ Object
64 65 66 67 68 |
# File 'lib/smol/output.rb', line 64 def check_result(name, result) status = result.passed? ? "pass".green.bold : "fail".red.bold out.puts "#{status}: #{name}" out.puts " #{result.message}" end |
#debug(text) ⇒ Object
58 59 60 61 62 |
# File 'lib/smol/output.rb', line 58 def debug(text) return unless Smol.debug? out.puts "[debug] #{text}".dim end |
#desc(text) ⇒ Object
20 21 22 |
# File 'lib/smol/output.rb', line 20 def desc(text) out.puts text.dim end |
#failure(text) ⇒ Object
36 37 38 |
# File 'lib/smol/output.rb', line 36 def failure(text) out.puts text.red.bold end |
#header(text) ⇒ Object
16 17 18 |
# File 'lib/smol/output.rb', line 16 def header(text) out.puts text.bold end |
#hint(text) ⇒ Object
44 45 46 |
# File 'lib/smol/output.rb', line 44 def hint(text) out.puts text.dim end |
#info(text) ⇒ Object
28 29 30 |
# File 'lib/smol/output.rb', line 28 def info(text) out.puts text end |
#label(text) ⇒ Object
48 49 50 |
# File 'lib/smol/output.rb', line 48 def label(text) out.puts text.yellow end |
#nl ⇒ Object
24 25 26 |
# File 'lib/smol/output.rb', line 24 def nl out.puts end |
#out ⇒ Object
8 9 10 |
# File 'lib/smol/output.rb', line 8 def out Smol.output end |
#success(text) ⇒ Object
32 33 34 |
# File 'lib/smol/output.rb', line 32 def success(text) out.puts text.green.bold end |
#table(rows, headers: nil, indent: 0) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/smol/output.rb', line 70 def table(rows, headers: nil, indent: 0) return if rows.empty? all_rows = headers ? [headers] + rows : rows col_widths = table_column_widths(all_rows) prefix = " " * indent if headers header_line = table_format_row(headers, col_widths) out.puts "#{prefix}#{header_line}".bold out.puts "#{prefix}#{"-" * header_line.length}" end rows.each do |row| out.puts "#{prefix}#{table_format_row(row, col_widths)}" end end |
#verbose(text) ⇒ Object
52 53 54 55 56 |
# File 'lib/smol/output.rb', line 52 def verbose(text) return unless Smol.verbose? out.puts text.dim end |
#warning(text) ⇒ Object
40 41 42 |
# File 'lib/smol/output.rb', line 40 def warning(text) out.puts text.yellow end |