Class: Raykit::Secrets
- Inherits:
-
Hash
- Object
- Hash
- Raykit::Secrets
- Defined in:
- lib/raykit/secrets.rb
Overview
Provides functionality to record the time execution times
Instance Method Summary collapse
- #hide(text) ⇒ Object
-
#initialize ⇒ Secrets
constructor
A new instance of Secrets.
- #save ⇒ Object
Constructor Details
#initialize ⇒ Secrets
Returns a new instance of Secrets.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/raykit/secrets.rb', line 6 def initialize() if ENV.has_key?('RAYKIT_SECRETS_PATH') secrets_file = ENV['RAYKIT_SECRETS_PATH'] if File.exists?(secrets_file) text = IO.read(secrets_file) if (text.length > 7 ) data = JSON.parse(text) data.each{|key,value| self[key] = value } end end end end |
Instance Method Details
#hide(text) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/raykit/secrets.rb', line 21 def hide(text) hidden=text self.each{|k,v| if(!v.nil? && v.length > 0) hidden=hidden.gsub(v,'****') end } hidden end |
#save ⇒ Object
31 32 33 34 35 36 |
# File 'lib/raykit/secrets.rb', line 31 def save() if ENV.has_key?('RAYKIT_SECRETS_PATH') secrets_file = ENV['RAYKIT_SECRETS_PATH'] File.open(secrets_file,"w") { |f| f.puts self.to_json } end end |