class PoiseProfiler::Config

Configuration wrapper for poise-profiler to combine input from a number of sources.

@since 1.1.0 @api private @example

cfg = Config.new
puts cfg[:profile_memory]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/poise_profiler/config.rb, line 37
def initialize
  super
  gather_from_env
  gather_from_node
end

Private Instance Methods

gather_from_env() click to toggle source

Find configuration data in environment variables. This is the only option on Chef 12.0, 12.1, and 12.2.

@api private

# File lib/poise_profiler/config.rb, line 49
def gather_from_env
  ENV.each do |key, value|
    if key.downcase =~ /^poise(_|-)profiler_(.+)$/
      self[$2] = YAML.safe_load(value)
    end
  end
end
gather_from_node() click to toggle source

Find configuration data in node attributes.

@api private

# File lib/poise_profiler/config.rb, line 60
def gather_from_node
  return unless defined?(Chef.node)
  (Chef.node['poise-profiler'] || {}).each do |key, value|
    self[key] = value
  end
end