Sha256: 825b85592e23728b572d1cab1ec498e06f8d8bedabdfe1c845c1405da0215052

Contents?: true

Size: 580 Bytes

Versions: 7

Compression:

Stored size: 580 Bytes

Contents

require 'json'

module Pronto
  module Formatter
    class JsonFormatter < Base
      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[:runner] = message.runner if message.runner
          result
        end.to_json
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pronto-0.10.0 lib/pronto/formatter/json_formatter.rb
pronto-0.9.5 lib/pronto/formatter/json_formatter.rb
pronto-0.9.4 lib/pronto/formatter/json_formatter.rb
pronto-0.9.3 lib/pronto/formatter/json_formatter.rb
pronto-0.9.2 lib/pronto/formatter/json_formatter.rb
pronto-0.9.1 lib/pronto/formatter/json_formatter.rb
pronto-0.9.0 lib/pronto/formatter/json_formatter.rb