Class: Inspec::Resources::NginxConf

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf_path = nil) ⇒ NginxConf

Returns a new instance of NginxConf.



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

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.



28
29
30
# File 'lib/resources/nginx_conf.rb', line 28

def contents
  @contents
end

Instance Method Details

#httpObject



43
44
45
# File 'lib/resources/nginx_conf.rb', line 43

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

#paramsObject



36
37
38
39
40
41
# File 'lib/resources/nginx_conf.rb', line 36

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

#to_sObject



49
50
51
# File 'lib/resources/nginx_conf.rb', line 49

def to_s
  "nginx_conf #{@conf_path}"
end