Class: Reviewer::Output
- Inherits:
-
Object
- Object
- Reviewer::Output
- Defined in:
- lib/reviewer/output.rb,
lib/reviewer/output/printer.rb,
lib/reviewer/output/formatting.rb
Overview
Console display infrastructure — primitives for styled terminal output. Domain-specific display logic lives in each concept’s Formatter class.
Defined Under Namespace
Modules: AnsiStyles, Formatting Classes: Printer
Constant Summary collapse
- DEFAULT_CONSOLE_WIDTH =
120- DIVIDER =
'─'- RAKE_ABORTED_TEXT =
"rake aborted!\n"
Instance Attribute Summary collapse
-
#printer ⇒ Object
readonly
Returns the value of attribute printer.
Class Method Summary collapse
-
.scrub(text) ⇒ String
Removes unhelpful rake exit status noise from stderr.
Instance Method Summary collapse
-
#clear ⇒ void
Clears the terminal screen (no-op when output is not a TTY).
-
#divider ⇒ void
Prints a horizontal rule spanning the console width.
-
#help(message) ⇒ void
Prints an unformatted help message.
-
#initialize(printer = Printer.new) ⇒ Output
constructor
Creates an instance of Output to print Reviewer activity and results to the console.
-
#newline ⇒ void
Prints a blank line.
-
#unfiltered(value) ⇒ void
Writes raw output directly without formatting.
Constructor Details
#initialize(printer = Printer.new) ⇒ Output
Creates an instance of Output to print Reviewer activity and results to the console
32 33 34 |
# File 'lib/reviewer/output.rb', line 32 def initialize(printer = Printer.new) @printer = printer end |
Instance Attribute Details
#printer ⇒ Object (readonly)
Returns the value of attribute printer.
26 27 28 |
# File 'lib/reviewer/output.rb', line 26 def printer @printer end |
Class Method Details
.scrub(text) ⇒ String
Removes unhelpful rake exit status noise from stderr
19 20 21 22 23 24 |
# File 'lib/reviewer/output.rb', line 19 def self.scrub(text) text = text.to_s return '' if text.empty? text.include?(RAKE_ABORTED_TEXT) ? text.split(RAKE_ABORTED_TEXT).first : text end |
Instance Method Details
#clear ⇒ void
This method returns an undefined value.
Clears the terminal screen (no-op when output is not a TTY)
40 41 42 |
# File 'lib/reviewer/output.rb', line 40 def clear system('clear') if printer.tty? end |
#divider ⇒ void
This method returns an undefined value.
Prints a horizontal rule spanning the console width
50 51 52 53 |
# File 'lib/reviewer/output.rb', line 50 def divider newline printer.print(:muted, DIVIDER * console_width) end |
#help(message) ⇒ void
This method returns an undefined value.
Prints an unformatted help message
58 59 60 |
# File 'lib/reviewer/output.rb', line 58 def help() printer.puts(:default, ) end |
#newline ⇒ void
This method returns an undefined value.
Prints a blank line
46 |
# File 'lib/reviewer/output.rb', line 46 def newline = printer.puts(:default, '') |
#unfiltered(value) ⇒ void
This method returns an undefined value.
Writes raw output directly without formatting
65 66 67 |
# File 'lib/reviewer/output.rb', line 65 def unfiltered(value) printer.write_raw(value) end |