Class: Pronto::AndroidLint::OutputParser
- Inherits:
-
Object
- Object
- Pronto::AndroidLint::OutputParser
- Defined in:
- lib/pronto/android_lint/output_parser.rb
Constant Summary collapse
- TYPE_WARNINGS =
{ "Warning" => :warning, "Info" => :info }
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ OutputParser
constructor
A new instance of OutputParser.
- #parse ⇒ Object
Constructor Details
#initialize(path) ⇒ OutputParser
Returns a new instance of OutputParser.
14 15 16 |
# File 'lib/pronto/android_lint/output_parser.rb', line 14 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/pronto/android_lint/output_parser.rb', line 7 def path @path end |
Instance Method Details
#parse ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pronto/android_lint/output_parser.rb', line 18 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 |