Class: Shhh::EncryptedFile
- Inherits:
-
Object
- Object
- Shhh::EncryptedFile
- Includes:
- Shhh
- Defined in:
- lib/shhh/encrypted_file.rb
Overview
This class provides a convenience wrapper for opening and reading encrypted files as they were regular files, and then possibly writing changes to them later.
Constant Summary
Constants included from Shhh
Instance Attribute Summary collapse
-
#app_args ⇒ Object
readonly
Returns the value of attribute app_args.
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#key_id ⇒ Object
readonly
Returns the value of attribute key_id.
-
#key_type ⇒ Object
readonly
Returns the value of attribute key_type.
Instance Method Summary collapse
-
#initialize(file:, key_id:, key_type:) ⇒ EncryptedFile
constructor
A new instance of EncryptedFile.
- #read ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(file:, key_id:, key_type:) ⇒ EncryptedFile
Returns a new instance of EncryptedFile.
16 17 18 19 20 21 22 |
# File 'lib/shhh/encrypted_file.rb', line 16 def initialize(file:, key_id:, key_type:) @file = file @key_id = key_id @key_type = key_type.to_sym @app_args = { file: file, key_type => key_id, decrypt: true } @application = Shhh::Application.new(self.app_args) end |
Instance Attribute Details
#app_args ⇒ Object (readonly)
Returns the value of attribute app_args.
14 15 16 |
# File 'lib/shhh/encrypted_file.rb', line 14 def app_args @app_args end |
#application ⇒ Object (readonly)
Returns the value of attribute application.
14 15 16 |
# File 'lib/shhh/encrypted_file.rb', line 14 def application @application end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
14 15 16 |
# File 'lib/shhh/encrypted_file.rb', line 14 def file @file end |
#key_id ⇒ Object (readonly)
Returns the value of attribute key_id.
14 15 16 |
# File 'lib/shhh/encrypted_file.rb', line 14 def key_id @key_id end |
#key_type ⇒ Object (readonly)
Returns the value of attribute key_type.
14 15 16 |
# File 'lib/shhh/encrypted_file.rb', line 14 def key_type @key_type end |
Instance Method Details
#read ⇒ Object
24 25 26 27 |
# File 'lib/shhh/encrypted_file.rb', line 24 def read @content = application.execute! unless @content @content end |
#write ⇒ Object
29 30 31 |
# File 'lib/shhh/encrypted_file.rb', line 29 def write Shhh::Application.new(file: file, key_type => key_id, encrypt: true, output: file).execute end |