Class: EncryptedYaml::Configurator
- Inherits:
-
Hash
- Object
- Hash
- EncryptedYaml::Configurator
- Defined in:
- lib/encrypted_yaml/configurator.rb
Overview
represents an encrypted YAML file as a Hash
Instance Method Summary collapse
-
#initialize(filename, options = {}) ⇒ Configurator
constructor
A new instance of Configurator.
-
#reload_config ⇒ EncryptedConfig::Configurator
returns a new copy with the current values in the configuration file.
-
#reload_config! ⇒ Object
reloads the configuration file.
Constructor Details
#initialize(filename, options = {}) ⇒ Configurator
Note:
The options param has some sane defaults:
-
for both key and iv, it will prefer the string blob over the filename
-
if neither the key/iv or filename is defined, it will default to a file named ‘key’ or ‘iv’ in the current directory
Returns a new instance of Configurator.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/encrypted_yaml/configurator.rb', line 17 def initialize(filename, = {}) @key = if [:key] [:key] else keyfile = [:keyfile] || File.dirname(filename) + '/key' File.read keyfile end @iv = if [:iv] [:iv] else ivfile = [:ivfile] || File.dirname(filename) + '/iv' File.read ivfile end @filename = filename load_config end |
Instance Method Details
#reload_config ⇒ EncryptedConfig::Configurator
Note:
does not reload the key or iv
returns a new copy with the current values in the configuration file
39 40 41 42 43 44 |
# File 'lib/encrypted_yaml/configurator.rb', line 39 def reload_config EncryptedYaml::Configurator.new(@filename, { :key => @key, :iv => @iv }) end |
#reload_config! ⇒ Object
Note:
does not reload the key or iv
reloads the configuration file
48 49 50 51 |
# File 'lib/encrypted_yaml/configurator.rb', line 48 def reload_config! self.clear load_config end |