Sha256: a6be5c91c266fbf4e22ae9b4f510cc7e1f5edbed19cddad534e6117f65b8d951
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
module Pronto module Credo class OutputParser attr_reader :output, :file TYPE_WARNINGS = { 'R' => :info, 'W' => :warning, 'C' => :info, 'D' => :info, 'F' => :info, 'A' => :info } def initialize(file, output) @file = file @output = output end def parse output.lines.map do |line| line_parts = line.split(':') next unless file.start_with?(line_parts[0]) offence_in_line = line_parts[1] column_line = nil if line_parts[2].to_i == 0 offence_level = TYPE_WARNINGS[line_parts[2].strip] offence_message = line_parts[3..-1].join(':').strip else offence_level = TYPE_WARNINGS[line_parts[3].strip] column_line = line_parts[2].to_i offence_message = line_parts[4..-1].join(':').strip end { line: offence_in_line.to_i, column: column_line, level: offence_level, message: offence_message } end.compact end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pronto-credo-0.0.7 | lib/pronto/credo/output_parser.rb |
pronto-credo-0.0.6 | lib/pronto/credo/output_parser.rb |
pronto-credo-0.0.5 | lib/pronto/credo/output_parser.rb |