class Periphery::CheckstyleParser::Listener

Attributes

results[R]

Public Class Methods

new() click to toggle source
# File lib/periphery/checkstyle_parser.rb, line 16
def initialize
  @current_file = nil
  @results = []
end

Public Instance Methods

tag_end(name) click to toggle source
# File lib/periphery/checkstyle_parser.rb, line 37
def tag_end(name)
  @current_file = nil if name == "file"
end
tag_start(name, attrs) click to toggle source
# 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

Private Instance Methods

relative_path(path, base = Pathname.getwd) click to toggle source
# File lib/periphery/checkstyle_parser.rb, line 43
def relative_path(path, base = Pathname.getwd)
  Pathname.new(path).relative_path_from(base).to_s
end