Class: Roro::Crypto::KeyWriter
- Inherits:
-
Object
- Object
- Roro::Crypto::KeyWriter
- Includes:
- FileReflection
- Defined in:
- lib/roro/crypto/key_writer.rb
Overview
Key writer Writes keys arguments for environments, directory and extension where environments are the names of the keys to be generated, directory is the destination folders the keys will be wrtten in and extension is the extension of the key file.
Instance Method Summary collapse
-
#initialize ⇒ KeyWriter
constructor
A new instance of KeyWriter.
- #write_keyfile(environment, extension = '.key') ⇒ Object
- #write_keyfiles(environments = [], directory = nil, extension = nil) ⇒ Object
Methods included from FileReflection
#gather_environments, #get_key, #source_files
Constructor Details
Instance Method Details
#write_keyfile(environment, extension = '.key') ⇒ Object
20 21 22 23 |
# File 'lib/roro/crypto/key_writer.rb', line 20 def write_keyfile(environment, extension = '.key') destination = "#{@mise}/keys/#{environment}#{extension}" @writer.write_to_file(destination, @cipher.generate_key) end |
#write_keyfiles(environments = [], directory = nil, extension = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/roro/crypto/key_writer.rb', line 25 def write_keyfiles(environments = [], directory = nil, extension = nil) @writer.write_to_file("#{@mise}/keys/.keep", '') directory ||= @mise extension ||= '.key' if environments.empty? environments = gather_environments(directory, '.env').uniq end environments.uniq.each { |environment| write_keyfile(environment, extension) } end |