class Inspec::Resources::PostgresIdentConf
Attributes
conf_file[R]
params[R]
Public Class Methods
new(ident_conf_path = nil)
click to toggle source
# File lib/inspec/resources/postgres_ident_conf.rb, line 21 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
Public Instance Methods
to_s()
click to toggle source
# File lib/inspec/resources/postgres_ident_conf.rb, line 35 def to_s "PostgreSQL Ident Config #{@conf_file}" end
Private Instance Methods
filter_comments(data)
click to toggle source
# File lib/inspec/resources/postgres_ident_conf.rb, line 41 def filter_comments(data) content = [] data.each do |line| line.chomp! content << line unless line.match(/^\s*#/) || line.empty? end content end
parse_conf(content)
click to toggle source
# File lib/inspec/resources/postgres_ident_conf.rb, line 57 def parse_conf(content) content.map do |line| parse_line(line) end.compact end
parse_line(line)
click to toggle source
# File lib/inspec/resources/postgres_ident_conf.rb, line 63 def parse_line(line) x = line.split(/\s+/) { "map_name" => x[0], "system_username" => x[1], "pg_username" => x[2], } end
read_content()
click to toggle source
# File lib/inspec/resources/postgres_ident_conf.rb, line 50 def read_content @content = "" @params = {} @content = filter_comments(read_file(@conf_file)) @params = parse_conf(@content) end
read_file(conf_file = @conf_file)
click to toggle source
# File lib/inspec/resources/postgres_ident_conf.rb, line 72 def read_file(conf_file = @conf_file) read_file_content(conf_file, allow_empty: true).lines end