Class: Inspec::Resources::NginxConf

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
FindFiles
Defined in:
lib/resources/nginx_conf.rb

Constant Summary

Constants included from FindFiles

FindFiles::TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FindFiles

#find_files, #find_files_or_error

Constructor Details

#initialize(conf_path = nil) ⇒ NginxConf

Returns a new instance of NginxConf.



33
34
35
36
37
# File 'lib/resources/nginx_conf.rb', line 33

def initialize(conf_path = nil)
  @conf_path = conf_path || '/etc/nginx/nginx.conf'
  @contents = {}
  return skip_resource 'The `nginx_conf` resource is currently not supported on Windows.' if inspec.os.windows?
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



31
32
33
# File 'lib/resources/nginx_conf.rb', line 31

def contents
  @contents
end

Instance Method Details

#httpObject



46
47
48
# File 'lib/resources/nginx_conf.rb', line 46

def http
  NginxConfHttp.new(params['http'], self)
end

#paramsObject



39
40
41
42
43
44
# File 'lib/resources/nginx_conf.rb', line 39

def params
  @params ||= parse_nginx(@conf_path)
rescue StandardError => e
  skip_resource e.message
  @params = {}
end

#to_sObject



52
53
54
# File 'lib/resources/nginx_conf.rb', line 52

def to_s
  "nginx_conf #{@conf_path}"
end