Class: Bolt::Outputter
- Inherits:
-
Object
- Object
- Bolt::Outputter
- Defined in:
- lib/bolt/outputter.rb,
lib/bolt/outputter/json.rb,
lib/bolt/outputter/human.rb,
lib/bolt/outputter/logger.rb,
lib/bolt/outputter/rainbow.rb
Defined Under Namespace
Classes: Human, JSON, Logger, Rainbow
Class Method Summary collapse
Instance Method Summary collapse
- #indent(indent, string) ⇒ Object
-
#initialize(color, verbose, trace, spin, stream = $stdout) ⇒ Outputter
constructor
A new instance of Outputter.
- #print_error ⇒ Object
- #print_message ⇒ Object
- #spin ⇒ Object
- #start_spin ⇒ Object
- #stop_spin ⇒ Object
Constructor Details
#initialize(color, verbose, trace, spin, stream = $stdout) ⇒ Outputter
Returns a new instance of Outputter.
18 19 20 21 22 23 24 |
# File 'lib/bolt/outputter.rb', line 18 def initialize(color, verbose, trace, spin, stream = $stdout) @color = color @verbose = verbose @trace = trace @stream = stream @spin = spin end |
Class Method Details
.for_format(format, color, verbose, trace, spin) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bolt/outputter.rb', line 5 def self.for_format(format, color, verbose, trace, spin) case format when 'human' Bolt::Outputter::Human.new(color, verbose, trace, spin) when 'json' Bolt::Outputter::JSON.new(color, verbose, trace, false) when 'rainbow' Bolt::Outputter::Rainbow.new(color, verbose, trace, spin) when nil raise "Cannot use outputter before parsing." end end |
Instance Method Details
#indent(indent, string) ⇒ Object
26 27 28 29 |
# File 'lib/bolt/outputter.rb', line 26 def indent(indent, string) indent = ' ' * indent string.gsub(/^/, indent.to_s) end |
#print_error ⇒ Object
35 36 37 |
# File 'lib/bolt/outputter.rb', line 35 def print_error raise NotImplementedError, "print_error() must be implemented by the outputter class" end |
#print_message ⇒ Object
31 32 33 |
# File 'lib/bolt/outputter.rb', line 31 def raise NotImplementedError, "print_message() must be implemented by the outputter class" end |
#spin ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/bolt/outputter.rb', line 43 def spin start_spin begin yield ensure stop_spin end end |
#start_spin ⇒ Object
39 |
# File 'lib/bolt/outputter.rb', line 39 def start_spin; end |
#stop_spin ⇒ Object
41 |
# File 'lib/bolt/outputter.rb', line 41 def stop_spin; end |