8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/text_to_checkstyle/converter.rb', line 8
def self.convert(text, options = {})
fail NoInputError if !text || text.empty?
logger.info(text: text)
doc = REXML::Document.new
doc.add REXML::XMLDecl.new
checkstyle = doc.add_element 'checkstyle'
name = options[:name] || FILE_NAME
file = checkstyle.add_element 'file', 'name' => name
line = options[:line] || ERROR_LINE
column = options[:column] || ERROR_COLUMN
severity = options[:severity] || ERROR_SEVERITY
message = text
source = options[:source] || ERROR_SOURCE
file.add_element 'error',
'line' => line,
'column' => column,
'severity' => severity,
'message' => message,
'source' => source
doc.to_s
end
|