Class: Backup::Encryptor::GPG
Instance Attribute Summary collapse
-
#encryption_key_id ⇒ Object
Contains the GPG encryption key id which’ll be extracted from the public key file.
-
#key ⇒ Object
The GPG Public key that’ll be used to encrypt the backup.
-
#tmp_file ⇒ Object
Contains the temporary file with the public key.
Instance Method Summary collapse
-
#initialize(&block) ⇒ GPG
constructor
Creates a new instance of Backup::Encryptor::GPG and sets the key to the provided GPG key.
-
#perform! ⇒ Object
Performs the encrypting of the backup file and will remove the unencrypted backup file, as well as the temp file.
Methods inherited from Base
Methods included from Configuration::Helpers
#clear_defaults!, #getter_methods, #load_defaults!, #setter_methods
Methods included from CLI
Constructor Details
#initialize(&block) ⇒ GPG
Creates a new instance of Backup::Encryptor::GPG and sets the key to the provided GPG key. To enhance the DSL the user may use tabs and spaces to indent the multi-line key string since we gsub() every preceding ‘space’ and ‘tab’ on each line
28 29 30 31 32 33 34 |
# File 'lib/backup/encryptor/gpg.rb', line 28 def initialize(&block) load_defaults! instance_eval(&block) if block_given? @key = key.gsub(/^(\s|\t)+/, '') end |
Instance Attribute Details
#encryption_key_id ⇒ Object
Contains the GPG encryption key id which’ll be extracted from the public key file
17 18 19 |
# File 'lib/backup/encryptor/gpg.rb', line 17 def encryption_key_id @encryption_key_id end |
#key ⇒ Object
The GPG Public key that’ll be used to encrypt the backup
13 14 15 |
# File 'lib/backup/encryptor/gpg.rb', line 13 def key @key end |
#tmp_file ⇒ Object
Contains the temporary file with the public key
21 22 23 |
# File 'lib/backup/encryptor/gpg.rb', line 21 def tmp_file @tmp_file end |
Instance Method Details
#perform! ⇒ Object
Performs the encrypting of the backup file and will remove the unencrypted backup file, as well as the temp file
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/backup/encryptor/gpg.rb', line 39 def perform! log! write_tmp_file! extract_encryption_key_id! run("#{ utility(:gpg) } #{ } -o '#{ Backup::Model.file }.gpg' '#{ Backup::Model.file }'") rm(Backup::Model.file) tmp_file.unlink Backup::Model.extension += '.gpg' end |