Class: HatiConfig::Encryption::FileKeyProvider
- Inherits:
-
KeyProvider
- Object
- KeyProvider
- HatiConfig::Encryption::FileKeyProvider
- Defined in:
- lib/hati_config/encryption.rb
Overview
FileKeyProvider gets the encryption key from a file.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FileKeyProvider
constructor
A new instance of FileKeyProvider.
- #key ⇒ Object
Methods inherited from KeyProvider
Constructor Details
#initialize(options = {}) ⇒ FileKeyProvider
Returns a new instance of FileKeyProvider.
204 205 206 207 208 |
# File 'lib/hati_config/encryption.rb', line 204 def initialize( = {}) super() @file_path = [:file_path] raise EncryptionError, 'File path not provided' unless @file_path end |
Instance Method Details
#key ⇒ Object
210 211 212 213 214 215 216 |
# File 'lib/hati_config/encryption.rb', line 210 def key raise EncryptionError, "Key file not found: #{@file_path}" unless File.exist?(@file_path) File.read(@file_path).strip rescue SystemCallError => e raise EncryptionError, "Failed to read key file: #{e.}" end |