class Hash
Public Instance Methods
obfuscate!(secure_keys = DEFAULT_SECURE_KEYS)
click to toggle source
# File lib/ectoplasm.rb, line 203 def obfuscate! secure_keys = DEFAULT_SECURE_KEYS self.each do |k, v| if v.is_a? Hash v.obfuscate!(secure_keys) elsif secure_keys.any? { |x| k.to_s.downcase.include? x.downcase } self[k] = '*****' end end end
pretty(indent: 0, width: 25)
click to toggle source
# File lib/ectoplasm.rb, line 162 def pretty indent: 0, width: 25 s = '' self .select { |key, value| value != nil || value != '' } .map do |key, value| value = true if value == 'true' value = false if value == 'false' value = '********' if /password|pwd|pass|passwd|secret/ =~ key.to_s if value.is_a? Hash s += key.to_s.cyan.indent(indent) + "\n" s += value.pretty(width: width-indent-2).indent(indent+2) s += "\n" next end s += ' ' * indent if value.is_a? Array list = value.pretty(width: width) if list.split("\n").count > 1 s += key.to_s.cyan + "\n" s += value.pretty(width: width).indent(indent) s += "\n" next end value = list end s += key.to_s.cyan s += ' ' + '.' * (width-key.to_s.length-indent) if width-key.to_s.length > indent s += ': ' s += value.pretty + "\n" end s end