Class: Inspec::Resources::ChronyConf

Inherits:
Object
  • Object
show all
Includes:
FileReader
Defined in:
lib/inspec/resources/chrony_conf.rb

Instance Method Summary collapse

Methods included from FileReader

#read_file_content

Constructor Details

#initialize(path = nil) ⇒ ChronyConf

Returns a new instance of ChronyConf.



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

def initialize(path = nil)
  @conf_path = path || "/etc/chrony.conf"
  @content = read_file_content(@conf_path)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/inspec/resources/chrony_conf.rb', line 29

def method_missing(name)
  param = read_params[name.to_s]
  # extract first value if we have only one value in array
  return param[0] if param.is_a?(Array) && (param.length == 1)

  param
end

Instance Method Details

#resource_idObject



37
38
39
# File 'lib/inspec/resources/chrony_conf.rb', line 37

def resource_id
  @conf_path || "chrony_conf"
end

#to_sObject



41
42
43
# File 'lib/inspec/resources/chrony_conf.rb', line 41

def to_s
  "chrony.conf"
end