Class: Inspec::Resources::NginxConfServer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, parent) ⇒ NginxConfServer

Returns a new instance of NginxConfServer.



181
182
183
184
# File 'lib/resources/nginx_conf.rb', line 181

def initialize(params, parent)
  @parent = parent
  @params = params || {}
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



180
181
182
# File 'lib/resources/nginx_conf.rb', line 180

def params
  @params
end

#parentObject (readonly)

Returns the value of attribute parent.



180
181
182
# File 'lib/resources/nginx_conf.rb', line 180

def parent
  @parent
end

Instance Method Details

#to_sObject Also known as: inspect



191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/resources/nginx_conf.rb', line 191

def to_s
  server = ''
  name = Array(params['server_name']).flatten.first
  unless name.nil?
    server += name
    listen = Array(params['listen']).flatten.first
    server += ":#{listen}" unless listen.nil?
  end

  # go two levels up: 1. to the http entry and 2. to the root nginx conf
  @parent.parent.to_s + ", server #{server}"
end