class Tollgate::Reporter

Constants

FAILED_OUTPUT
Record
STATUSES
SUCCESS_OUTPUT

Attributes

records[R]

Public Class Methods

new() click to toggle source
# File lib/tollgate/reporter.rb, line 11
def initialize
  @records = Tollgate::Reporter::Records.new
end

Public Instance Methods

record(command, status:) click to toggle source
# File lib/tollgate/reporter.rb, line 15
def record(command, status:)
  @records << Record.new(command, status)
end
report(success:) click to toggle source
# File lib/tollgate/reporter.rb, line 25
    def report(success:)
      run_result = success ? SUCCESS_OUTPUT : FAILED_OUTPUT

      <<~OUTPUT
      #{command_statuses.join}
      #{run_result}
      OUTPUT
    end

Private Instance Methods

command_statuses() click to toggle source
# File lib/tollgate/reporter.rb, line 36
    def command_statuses
      @records.map do |record|
        status = STATUSES.fetch(record.status)
        <<~OUTPUT
        #{status}: #{record.command}
        OUTPUT
      end
    end