Class: Pronto::Formatter::JsonFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/formatter/json_formatter.rb

Instance Method Summary collapse

Instance Method Details

#format(messages, _) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/pronto/formatter/json_formatter.rb', line 6

def format(messages, _)
  messages.map do |message|
    lineno = message.line.new_lineno if message.line

    result = { level: message.level[0].upcase, message: message.msg }
    result[:path] = message.path if message.path
    result[:line] = lineno if lineno
    result[:commit_sha] = message.commit_sha if message.commit_sha
    result
  end.to_json
end