Class: Backup::Encryptor::GPG

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/encryptor/gpg.rb

Constant Summary

Constants included from CLI::Helpers

CLI::Helpers::UTILITY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration::Helpers

#clear_defaults!, #load_defaults!

Methods included from CLI::Helpers

#command_name, #raise_if_command_failed!, #run, #utility

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



16
17
18
19
20
# File 'lib/backup/encryptor/gpg.rb', line 16

def initialize(&block)
  super

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#keyObject

The GPG Public key that’ll be used to encrypt the backup



9
10
11
# File 'lib/backup/encryptor/gpg.rb', line 9

def key
  @key
end

Instance Method Details

#encrypt_with {|"#{ utility(:gpg) } #{ options }", '.gpg'| ... } ⇒ Object

This is called as part of the procedure run by the Packager. It sets up the needed encryption_key_email to pass to the gpg command, then yields the command to use as part of the packaging procedure. Once the packaging procedure is complete, it will return so that any clean-up may be performed after the yield.

Yields:

  • ("#{ utility(:gpg) } #{ options }", '.gpg')


28
29
30
31
32
33
# File 'lib/backup/encryptor/gpg.rb', line 28

def encrypt_with
  log!
  extract_encryption_key_email!

  yield "#{ utility(:gpg) } #{ options }", '.gpg'
end