Class: PreCommit::Message::Extractor

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/pre_commit/message/extractor.rb

Overview

Responsible for extract error messages from terminal output

Instance Method Summary collapse

Instance Method Details

#extract(terminal_output) ⇒ Domain::Checkstyle

Extract data from a XML formatted terminal_output

Parameters:

  • terminal_output (String)

    XML formatted terminal ouput

Returns:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/plugins/pre_commit/message/extractor.rb', line 17

def extract(terminal_output)
  if blank?(terminal_output) ||
     blank?(xml_content_of(terminal_output))
    return Domain::Checkstyle.good
  end

  xml_data = Crack::XML.parse(xml_content_of(terminal_output))
  files = xml_data['checkstyle']['file']

  Domain::Checkstyle.new(extract_bad_file(files))
end