-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrule_references.rb
More file actions
32 lines (28 loc) · 884 Bytes
/
rule_references.rb
File metadata and controls
32 lines (28 loc) · 884 Bytes
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
# frozen_string_literal: true
require 'openscap_results_parser/xml_file'
require 'openscap_results_parser/rule_reference'
module OpenscapParser
# Methods related to finding and saving rule references
module RuleReferences
def self.included(base)
base.class_eval do
def rule_reference_strings
@rule_reference_strings ||= rule_references.map do |rr|
"#{rr.label}#{rr.href}"
end
end
def rule_references
@rule_references ||= rule_reference_nodes.map do |node|
OpenscapParser::RuleReference.new(parsed_xml: node)
end.uniq do |reference|
[reference.label, reference.href]
end
end
alias :references :rule_references
def rule_reference_nodes(xpath = ".//Rule/reference")
xpath_nodes(xpath)
end
end
end
end
end