Class: Bolt::Outputter

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/outputter.rb,
lib/bolt/outputter/json.rb,
lib/bolt/outputter/human.rb

Direct Known Subclasses

Human, JSON

Defined Under Namespace

Classes: Human, JSON

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color, trace, stream = $stdout) ⇒ Outputter

Returns a new instance of Outputter.



16
17
18
19
20
# File 'lib/bolt/outputter.rb', line 16

def initialize(color, trace, stream = $stdout)
  @color = color
  @trace = trace
  @stream = stream
end

Class Method Details

.for_format(format, color, trace) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/bolt/outputter.rb', line 5

def self.for_format(format, color, trace)
  case format
  when 'human'
    Bolt::Outputter::Human.new(color, trace)
  when 'json'
    Bolt::Outputter::JSON.new(color, trace)
  when nil
    raise "Cannot use outputter before parsing."
  end
end

Instance Method Details



223
224
225
# File 'lib/bolt/outputter/human.rb', line 223

def print_message(message)
  @stream.puts(message)
end