Class: Saddler::Reporter::Text
- Inherits:
-
Object
- Object
- Saddler::Reporter::Text
- Defined in:
- lib/saddler/reporter/text.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Method Summary collapse
-
#initialize(output) ⇒ Text
constructor
A new instance of Text.
- #parse_messages(messages) ⇒ Object
- #report(messages, _options) ⇒ Object
Constructor Details
#initialize(output) ⇒ Text
Returns a new instance of Text.
5 6 7 |
# File 'lib/saddler/reporter/text.rb', line 5 def initialize(output) @output = output end |
Instance Method Details
#parse_messages(messages) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/saddler/reporter/text.rb', line 21 def () # TODO: split to class or gem require 'rexml/document' parsed = [] document = REXML::Document.new document.elements.each('/checkstyle/file') do |file_element| file_name = file_element.attribute('name') && file_element.attribute('name').value file_element.elements.each('error') do |error_element| line = error_element.attribute('line') && error_element.attribute('line').value.to_i column = error_element.attribute('column') && error_element.attribute('column').value.to_i severity = error_element.attribute('severity') && error_element.attribute('severity').value = error_element.attribute('message') && error_element.attribute('message').value source = error_element.attribute('source') && error_element.attribute('source').value parsed << { file: file_name, line: line, column: column, severity: severity, message: , source: source } end end parsed end |
#report(messages, _options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/saddler/reporter/text.rb', line 9 def report(, ) = () .each do |msg| severity = msg[:severity] && msg[:severity].upcase line = msg[:line] path = msg[:file] column = msg[:column] = msg[:message] @output.puts "#{path}:#{line}:#{column} #{severity}: #{}" end end |