Class: Periphery::CheckstyleParser::Listener

Inherits:
Object
  • Object
show all
Includes:
REXML::StreamListener
Defined in:
lib/periphery/checkstyle_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeListener

Returns a new instance of Listener.



16
17
18
19
# File 'lib/periphery/checkstyle_parser.rb', line 16

def initialize
  @current_file = nil
  @results = []
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



14
15
16
# File 'lib/periphery/checkstyle_parser.rb', line 14

def results
  @results
end

Instance Method Details

#tag_end(name) ⇒ Object



37
38
39
# File 'lib/periphery/checkstyle_parser.rb', line 37

def tag_end(name)
  @current_file = nil if name == "file"
end

#tag_start(name, attrs) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/periphery/checkstyle_parser.rb', line 21

def tag_start(name, attrs)
  case name
  when "file"
    @current_file = relative_path(attrs["name"])
  when "error"
    if @current_file
      @results << ScanResult.new(
        @current_file,
        attrs["line"].to_i,
        attrs["column"].to_i,
        attrs["message"]
      )
    end
  end
end