Class: Roro::Crypto::Exposer
- Inherits:
-
Object
- Object
- Roro::Crypto::Exposer
- Includes:
- FileReflection
- Defined in:
- lib/roro/crypto/exposer.rb
Instance Method Summary collapse
- #expose(environments, directory, ext) ⇒ Object
- #expose_file(file, key) ⇒ Object
-
#initialize ⇒ Exposer
constructor
A new instance of Exposer.
Methods included from FileReflection
#gather_environments, #get_key, #source_files
Constructor Details
Instance Method Details
#expose(environments, directory, ext) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/roro/crypto/exposer.rb', line 20 def expose(environments, directory, ext) if environments.empty? environments = gather_environments(directory, ext) else environments.each { |environment| get_key(environment) } end environments.each do |environment| exposable = source_files(directory, "#{environment}*#{ext}") exposable.each { |file| expose_file(file, get_key(environment)) } end end |
#expose_file(file, key) ⇒ Object
14 15 16 17 18 |
# File 'lib/roro/crypto/exposer.rb', line 14 def expose_file(file, key) encrypted_content = File.read(file) decrypted_content = @cipher.decrypt(encrypted_content, key) @writer.write_to_file(file.split('.enc').first, decrypted_content) end |