class Util::PrepareData
Attributes
transformed_data[R]
Public Class Methods
new(clean_text)
click to toggle source
# File lib/utilities/parser.rb, line 333 def initialize(clean_text) @parser = ControlParser.new @attributes = [] data = parse(clean_text) @transformed_data = Trans.new.apply(data) add_cis end
Public Instance Methods
add_cis()
click to toggle source
# File lib/utilities/parser.rb, line 355 def add_cis @transformed_data&.map do |ctrl| if !ctrl[:cis] && ctrl[:ref] references = ctrl[:ref].split("\n") references.each do |ref| match = ref.scan(/(?<=#)\d+\.\d+/).map(&:inspect).join(',').delete('"').tr(',', ' ') ctrl[:cis] = match.split unless match.empty? end ctrl[:cis] = 'No CIS Control' unless ctrl[:cis] elsif !ctrl[:cis] && !ctrl[:ref] ctrl[:cis] = 'No CIS Control' elsif ctrl[:cis] && ctrl[:ref] ctrl[:cis] = ctrl[:cis].scan(/^\d+[.\d+]*/) end end end
convert_str(value)
click to toggle source
# File lib/utilities/parser.rb, line 351 def convert_str(value) value.to_s end
parse(clean_text)
click to toggle source
# File lib/utilities/parser.rb, line 345 def parse(clean_text) @parser.parse(clean_text) rescue Parslet::ParseFailed => e puts e.parse_failure_cause.ascii_tree end