Class: Inspec::Resources::PostfixConf

Inherits:
IniConfig show all
Defined in:
lib/inspec/resources/postfix_conf.rb

Instance Attribute Summary

Attributes inherited from JsonConfig

#params, #raw_content

Instance Method Summary collapse

Methods inherited from JsonConfig

#method_missing, #value

Methods included from FileReader

#read_file_content

Methods included from ObjectTraverser

#extract_value

Constructor Details

#initialize(*opts) ⇒ PostfixConf

Allow user to specify a custom configuration path, use default Postfix configuration path if no custom path is provided



11
12
13
14
15
16
17
18
19
# File 'lib/inspec/resources/postfix_conf.rb', line 11

def initialize(*opts)
  @params = {}
  if opts.length == 1
    @raw_content = load_raw_content(opts[0])
  else
    @raw_content = load_raw_content("/etc/postfix/main.cf")
  end
  @params = parse(@raw_content)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Inspec::Resources::JsonConfig

Instance Method Details

#parse(content) ⇒ Object



21
22
23
# File 'lib/inspec/resources/postfix_conf.rb', line 21

def parse(content)
  SimpleConfig.new(content).params
end

#resource_idObject



25
26
27
# File 'lib/inspec/resources/postfix_conf.rb', line 25

def resource_id
  "Postfix Conf"
end

#to_sObject



29
30
31
# File 'lib/inspec/resources/postfix_conf.rb', line 29

def to_s
  "Postfix Mail Transfer Agent"
end