class Inspec::Resources::PostgresIdentConf

def filter_comments(data)

def filter_comments(data)
  content = []
  data.each do |line|
    line.chomp!
    content << line unless line.match(/^\s*#/) || line.empty?
  end
  content
end

def initialize(ident_conf_path = nil)

def initialize(ident_conf_path = nil)
  @conf_file = ident_conf_path || File.join(inspec.postgres.conf_dir, "pg_ident.conf")
  @content = nil
  @params = nil
  read_content
end

def parse_conf(content)

def parse_conf(content)
  content.map do |line|
    parse_line(line)
  end.compact
end

def parse_line(line)

def parse_line(line)
  x = line.split(/\s+/)
  {
    "map_name" => x[0],
    "system_username" => x[1],
    "pg_username" => x[2],
  }
end

def read_content

def read_content
  @content = ""
  @params = {}
  @content = filter_comments(read_file(@conf_file))
  @params = parse_conf(@content)
end

def read_file(conf_file = @conf_file)

def read_file(conf_file = @conf_file)
  read_file_content(conf_file, allow_empty: true).lines
end

def to_s

def to_s
  "PostgreSQL Ident Config #{@conf_file}"
end