Class: Lintress::Parser
- Inherits:
-
Object
- Object
- Lintress::Parser
- Defined in:
- lib/lintress/parser.rb
Overview
Parse the response from RuboCop
Instance Attribute Summary collapse
-
#offenses ⇒ Object
readonly
Returns the value of attribute offenses.
Instance Method Summary collapse
-
#initialize(s) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(s) ⇒ Parser
Returns a new instance of Parser.
9 10 11 12 |
# File 'lib/lintress/parser.rb', line 9 def initialize s @offenses = [] @lines = s.lines end |
Instance Attribute Details
#offenses ⇒ Object (readonly)
Returns the value of attribute offenses.
7 8 9 |
# File 'lib/lintress/parser.rb', line 7 def offenses @offenses end |
Instance Method Details
#parse ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lintress/parser.rb', line 14 def parse # remove_pointer_lines @lines.delete_if do |line| line.match?(/^\s+[\^]*$/) || line.match?(/^\^+$/) end # catalogue_offenses # (filename):(line):(column) (char): (reason) @lines.each do |line| ptn = %r{(?<file>[\w/\.]+):(?<line>\d+):(?<col>\d+): \w: (?<reason>.*)} m = line.match ptn next unless m offense = Offense.new m @offenses << offense end end |