class Leeroy::Env
Constants
- ENV_DEFAULTS
- ENV_EXTRAS
- S3_PREFIXES
constants
Attributes
defaults[R]
attr_reader :default, :profile
profile[R]
attr_reader :default, :profile
Public Class Methods
new(options = {}, env = ENV)
click to toggle source
Calls superclass method
# File lib/leeroy/env.rb, line 56 def initialize(options = {}, env = ENV) begin logger.debug "initializing #{self.class}" logger.debug "options: #{options.inspect}" @defaults = options[:default] @profile = options[:profile] if self.defaults unfiltered = ENV_DEFAULTS extras = ENV_EXTRAS else unfiltered = env extras = {} end filtered = _filterEnv(unfiltered).merge(extras) logger.debug "filtered: #{filtered.inspect}" self.dump_properties = filtered.keys.sort.collect { |x| x.to_sym } super(filtered) rescue StandardError => e raise e end end
Public Instance Methods
to_s()
click to toggle source
# File lib/leeroy/env.rb, line 83 def to_s _prettyPrint end
Private Instance Methods
_filterEnv(env, prefix = 'LEEROY_')
click to toggle source
# File lib/leeroy/env.rb, line 109 def _filterEnv(env, prefix = 'LEEROY_') begin logger.debug("filtering env by prefix '#{prefix}'") env.select { |k,v| k.start_with?(prefix) } rescue StandardError => e raise e end end
_prettyPrint()
click to toggle source
# File lib/leeroy/env.rb, line 89 def _prettyPrint if self.profile formatstr = 'export %s=%s' header = '# environment variables for leeroy configuration' else formatstr = '%s=%s' header = nil end if self.defaults formatstr = '# '.concat(formatstr) end properties = self.dump_properties.collect {|x| x.to_s}.sort.collect {|x| sprintf(formatstr, x, self.fetch(x))} properties.unshift(header) unless header.nil? properties.join("\n") end