-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest_result.rb
More file actions
60 lines (47 loc) · 1.4 KB
/
test_result.rb
File metadata and controls
60 lines (47 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require 'openscap_results_parser/rule_results'
module OpenscapParser
class TestResult < XmlNode
include OpenscapParser::RuleResults
def target
@target ||= parsed_xml.at_xpath('target') &&
parsed_xml.at_xpath('target').text || ''
end
alias :host :target
def target_fact_nodes
@target_fact_nodes ||= parsed_xml.xpath('target-facts/fact')
end
def platform_nodes
@platform_nodes ||= parsed_xml.xpath('platform')
end
def title
@title ||= parsed_xml.at_xpath('title') &&
parsed_xml.at_xpath('title').text || ''
end
def identity
@identity ||= parsed_xml.at_xpath('identity') &&
parsed_xml.at_xpath('identity').text || ''
end
def profile_id
@profile_id ||= parsed_xml.at_xpath('profile') &&
parsed_xml.at_xpath('profile')['idref'] || ''
end
def benchmark_id
@benchmark_id ||= parsed_xml.at_xpath('benchmark') &&
parsed_xml.at_xpath('benchmark')['id'] || ''
end
def set_value_nodes
@set_value_nodes ||= parsed_xml.xpath('set-value')
end
def score
@score ||= parsed_xml.at_xpath('score') &&
parsed_xml.at_xpath('score').text.to_f
end
def start_time
@start_time ||= DateTime.parse(parsed_xml['start-time'])
end
def end_time
@end_time ||= DateTime.parse(parsed_xml['end-time'])
end
end
end