Class: Bolt::Outputter

Inherits:
Object
  • Object
show all
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

Direct Known Subclasses

Human, JSON, Logger

Defined Under Namespace

Classes: Human, JSON, Logger, Rainbow

Class Method Summary collapse

Instance Method Summary collapse

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

Raises:

  • (NotImplementedError)

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

Raises:

  • (NotImplementedError)

31
32
33
# File 'lib/bolt/outputter.rb', line 31

def print_message
  raise NotImplementedError, "print_message() must be implemented by the outputter class"
end

#spinObject


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_spinObject


39
# File 'lib/bolt/outputter.rb', line 39

def start_spin; end

#stop_spinObject


41
# File 'lib/bolt/outputter.rb', line 41

def stop_spin; end