Class: Pronto::Formatter::JsonFormatter

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#config

Class Method Details

.nameObject



6
7
8
# File 'lib/pronto/formatter/json_formatter.rb', line 6

def self.name
  'json'
end

Instance Method Details

#format(messages, _repo, _patches) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pronto/formatter/json_formatter.rb', line 10

def format(messages, _repo, _patches)
  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[:runner] = message.runner if message.runner
    result
  end.to_json
end