Class: SecretConfig::SettingInterpolator

Inherits:
StringInterpolator show all
Defined in:
lib/secret_config/setting_interpolator.rb

Instance Method Summary collapse

Methods inherited from StringInterpolator

#initialize, #parse

Constructor Details

This class inherits a constructor from SecretConfig::StringInterpolator

Instance Method Details

#date(format = "%Y%m%d") ⇒ Object



19
20
21
# File 'lib/secret_config/setting_interpolator.rb', line 19

def date(format = "%Y%m%d")
  Date.today.strftime(format)
end

#env(name) ⇒ Object



27
28
29
# File 'lib/secret_config/setting_interpolator.rb', line 27

def env(name)
  ENV[name]
end

#hostname(format = nil) ⇒ Object



31
32
33
34
35
# File 'lib/secret_config/setting_interpolator.rb', line 31

def hostname(format = nil)
  name = Socket.gethostname
  name = name.split(".")[0] if format == "short"
  name
end

#pidObject



37
38
39
# File 'lib/secret_config/setting_interpolator.rb', line 37

def pid
  $$
end

#random(size = 32) ⇒ Object



41
42
43
# File 'lib/secret_config/setting_interpolator.rb', line 41

def random(size = 32)
  SecureRandom.urlsafe_base64(size)
end

#time(format = "%Y%m%d%H%M%S%L") ⇒ Object



23
24
25
# File 'lib/secret_config/setting_interpolator.rb', line 23

def time(format = "%Y%m%d%H%M%S%L")
  Time.now.strftime(format)
end