Sha256: 175cf31fff12501422a04f11badbc617e9a9c3dc3ac578d0b1e338e3ef2d6b38

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

require 'crack'

module PreCommit
  module Message
    ##
    # Responsible for extract error messages from terminal output
    class Extractor
      EMPTY = { 'checkstyle' => { 'file' => [] } }

      ##
      # Extract data from a XML formatted +output+
      #
      # @param output [String] Xml formatted ouput
      # @return [Hash]
      def extract(output)
        return EMPTY if output.nil? || output.empty?
        Crack::XML.parse(xml_content(output))
      end

      private

      def xml_content(raw_output)
        raw_output[/<(.*)>/m]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
java-checkstyle-1.0.0 lib/plugins/pre_commit/message/extractor.rb
java-checkstyle-0.0.2 lib/plugins/pre_commit/message/extractor.rb