Class: GemContribute::Output::Standard
- Inherits:
-
Object
- Object
- GemContribute::Output::Standard
- Defined in:
- lib/gem_contribute/output/standard.rb
Overview
Semantic output abstraction for CLI verbs (per ADR-0012). Wraps stdout/stderr behind verb-shaped methods so the look-and-feel can evolve independently of the service layer.
‘#warn` and `#error` both write to stderr without prefixing — the caller’s message already carries its own framing (“Note: …”, “warning: …”, “fix failed: …”). The semantic split exists so a later styling pass (color, severity icons) has somewhere to hang.
‘#progress` has two forms:
* No block — equivalent to #info. Use when there's nothing to
wrap, e.g. you're announcing intent before a sequence of calls.
* Block form — runs the block while showing a tty-spinner in
interactive terminals. In non-TTY contexts (CI, piped output,
test StringIOs) it falls back to a plain line + yield. The
block's return value is the method's return value.
Instance Method Summary collapse
- #error(message) ⇒ Object
- #info(message) ⇒ Object
-
#initialize(out: $stdout, err: $stderr) ⇒ Standard
constructor
A new instance of Standard.
- #progress(message) ⇒ Object
- #warn(message) ⇒ Object
Constructor Details
#initialize(out: $stdout, err: $stderr) ⇒ Standard
Returns a new instance of Standard.
25 26 27 28 |
# File 'lib/gem_contribute/output/standard.rb', line 25 def initialize(out: $stdout, err: $stderr) @out = out @err = err end |
Instance Method Details
#error(message) ⇒ Object
45 46 47 |
# File 'lib/gem_contribute/output/standard.rb', line 45 def error() @err.puts() end |
#info(message) ⇒ Object
30 31 32 |
# File 'lib/gem_contribute/output/standard.rb', line 30 def info() @out.puts() end |
#progress(message) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/gem_contribute/output/standard.rb', line 34 def progress(, &) return @out.puts() unless block_given? return puts_and_yield(, &) unless interactive? spin(, &) end |
#warn(message) ⇒ Object
41 42 43 |
# File 'lib/gem_contribute/output/standard.rb', line 41 def warn() @err.puts() end |