Class: InspecTools::CSVTool

Inherits:
Object show all
Defined in:
lib/inspec_tools/csv.rb

Overview

Methods for converting from CSV to various formats

Instance Method Summary collapse

Constructor Details

#initialize(csv, mapping, name, verbose = false) ⇒ CSVTool

Returns a new instance of CSVTool.



12
13
14
15
16
17
18
# File 'lib/inspec_tools/csv.rb', line 12

def initialize(csv, mapping, name, verbose = false)
  @name = name
  @csv = csv
  @mapping = Utils::MappingValidator.validate(mapping)
  @verbose = verbose
  @csv.shift if @mapping['skip_csv_header']
end

Instance Method Details

#to_inspec(control_name_prefix: nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/inspec_tools/csv.rb', line 20

def to_inspec(control_name_prefix: nil)
  @controls = []
  @profile = {}
  @cci_xml = Utils::CciXml.get_cci_list('U_CCI_List.xml')
  
  parse_controls(control_name_prefix)
  @profile['controls'] = @controls
  @profile['sha256'] = Digest::SHA256.hexdigest(@profile.to_s)
  @profile
end