Class: CircleCI::CLI::Printer::StepPrinter
- Inherits:
-
Object
- Object
- CircleCI::CLI::Printer::StepPrinter
- Defined in:
- lib/circleci/cli/printer/step_printer.rb
Instance Method Summary collapse
-
#initialize(steps, pretty: true) ⇒ StepPrinter
constructor
A new instance of StepPrinter.
-
#to_s ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Constructor Details
#initialize(steps, pretty: true) ⇒ StepPrinter
Returns a new instance of StepPrinter.
7 8 9 10 |
# File 'lib/circleci/cli/printer/step_printer.rb', line 7 def initialize(steps, pretty: true) @steps = steps @pretty = pretty end |
Instance Method Details
#to_s ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/circleci/cli/printer/step_printer.rb', line 12 def to_s # rubocop:disable Metrics/AbcSize, Metrics/MethodLength if @pretty Terminal::Table.new do |t| @steps .group_by(&:type) .each do |key, steps| t << :separator t << [{ value: key.green, alignment: :center, colspan: 2 }] steps.each { |s| print_actions(t, s) } end end.to_s else @steps.group_by(&:type).map do |_, steps| steps.map do |step| step.actions.map do |a| "#{colorize_by_status(a.name.slice(0..120), a.status)}\n#{"#{a.log}\n" if a.failed? && a.log}" end end.flatten.join('') end.join("\n") end end |