Class: Pronto::JavaCheckstyle::Parsing
- Inherits:
-
Object
- Object
- Pronto::JavaCheckstyle::Parsing
- Defined in:
- lib/pronto/ProntoJavaCheckstyle/Parsing.rb
Constant Summary collapse
- TYPE_WARNINGS =
{ "Warning" => :warning, "Info" => :info, "Error" => :error }
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Parsing
constructor
A new instance of Parsing.
- #parse ⇒ Object
Constructor Details
#initialize(path) ⇒ Parsing
Returns a new instance of Parsing.
15 16 17 |
# File 'lib/pronto/ProntoJavaCheckstyle/Parsing.rb', line 15 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/pronto/ProntoJavaCheckstyle/Parsing.rb', line 7 def path @path end |
Instance Method Details
#parse ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pronto/ProntoJavaCheckstyle/Parsing.rb', line 19 def parse lint_result = File.open(@path) { |f| Nokogiri::XML(f) } lint_result.xpath("//issue").flat_map do |issue| issue.xpath(".//location").map do |location| { path: location.attribute("file").try(:value), line: location.attribute("line").try(:value).to_i, level: TYPE_WARNINGS[issue.attribute("severity").value], message: (issue) } end end rescue => e raise "Error while parsing file: #{@path}\n#{e.}" end |