Method: Inspec::Resources::InetdConf#read_params

Defined in:
lib/resources/inetd_conf.rb

#read_paramsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/resources/inetd_conf.rb', line 29

def read_params
  return @params if defined?(@params)

  # read the file
  file = inspec.file(@conf_path)
  if !file.file?
    skip_resource "Can't find file \"#{@conf_path}\""
    return @params = {}
  end

  content = file.content
  if content.empty? && file.size > 0
    skip_resource "Can't read file \"#{@conf_path}\""
    return @params = {}
  end
  # parse the file
  conf = SimpleConfig.new(
    content,
    assignment_re: /^\s*(\S+?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s*$/,
    key_vals: 6,
    multiple_values: false,
  )
  @params = conf.params
end