class Inspec::Resources::RabbitmqConfig

Public Class Methods

new(conf_path = nil) click to toggle source
# File lib/inspec/resources/rabbitmq_config.rb, line 20
def initialize(conf_path = nil)
  @conf_path = conf_path || "/etc/rabbitmq/rabbitmq.config"
  @content = read_file_content(@conf_path, allow_empty: true)
end

Public Instance Methods

params(*opts) click to toggle source
# File lib/inspec/resources/rabbitmq_config.rb, line 25
def params(*opts)
  opts.inject(read_params) do |res, nxt|
    res.respond_to?(:key) ? res[nxt] : nil
  end
end
to_s() click to toggle source
# File lib/inspec/resources/rabbitmq_config.rb, line 31
def to_s
  "rabbitmq_config #{@conf_path}"
end

Private Instance Methods

read_content() click to toggle source
# File lib/inspec/resources/rabbitmq_config.rb, line 37
def read_content
  return @content if defined?(@content)

  @content = read_file_content(@conf_path, allow_empty: true)
end
read_params() click to toggle source
# File lib/inspec/resources/rabbitmq_config.rb, line 43
def read_params
  return @params if defined?(@params)
  return @params = {} if read_content.nil?

  @params = ErlangConfigFile.parse(read_content)
rescue Parslet::ParseFailed
  raise "Cannot parse RabbitMQ config: \"#{read_content}\""
end