Method: PDK::Report::Event#to_text

Defined in:
lib/pdk/report/event.rb

#to_textString

Renders the event in a clang style text format.

Returns:

  • (String)

    The rendered event.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/pdk/report/event.rb', line 107

def to_text
  return message if rspec_puppet_coverage?

  location = [file, line, column].compact.join(':')
  location = nil if location.empty?

  # TODO: maybe add trace
  if source == 'rspec'
    header = [severity, source, location, message].compact.join(': ')
    result = [header, "  #{test}"]
    context = context_lines
    unless context.nil?
      result << '  Failure/Error:'
      result.concat(context)
      result << "\n"
    end

    result.compact.join("\n")
  else
    output = ['pdk']
    output << "(#{severity.upcase}):" unless severity.nil?
    output << "#{source}:" unless source.nil?
    output << message unless message.nil?
    output << "(#{location})" unless location.nil?

    output.join(' ')
  end
end