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



187
188
189
# File 'lib/bolt/outputter/human.rb', line 187

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

#replace_data_type(params) ⇒ Object

This method replaces data types tha have the name ‘Data’ with the string ‘Any’ This was a problem when using ‘bolt task show <task_name>’



25
26
27
28
29
# File 'lib/bolt/outputter.rb', line 25

def replace_data_type(params)
  params.map do |_, v|
    v['type'] = 'Any' if v['type'].to_s == 'Data'
  end
end