Class: Pronto::Formatter::TextFormatter

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

Instance Method Summary collapse

Instance Method Details

#format(messages, _) ⇒ Object


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

def format(messages, _)
  messages.map do |message|
    level = message.level[0].upcase
    line = message.line
    lineno = line.new_lineno if line
    path = message.path
    commit_sha = message.commit_sha[0..6] if message.commit_sha

    location = (path.nil? && lineno.nil?) ? commit_sha : "#{path}:#{lineno}"
    "#{location} #{level}: #{message.msg}"
  end
end