Class: GpgCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/gpg_encrypt_folder.rb

Instance Method Summary collapse

Instance Method Details

#encrypted_filenameObject



85
86
87
# File 'lib/gpg_encrypt_folder.rb', line 85

def encrypted_filename
  options.destination_folder.join(output_filename)
end

#filename_without_extensionObject



77
78
79
# File 'lib/gpg_encrypt_folder.rb', line 77

def filename_without_extension
  File.basename(file, ".xml")
end

#homedirObject



69
70
71
# File 'lib/gpg_encrypt_folder.rb', line 69

def homedir
  options.homedir && "--homedir \"#{options.homedir}\""
end

#keyringObject



73
74
75
# File 'lib/gpg_encrypt_folder.rb', line 73

def keyring
  "--keyring \"#{options.keyring}\""
end

#output_filenameObject



81
82
83
# File 'lib/gpg_encrypt_folder.rb', line 81

def output_filename
  "#{filename_without_extension}.gpg"
end

#recipientObject



65
66
67
# File 'lib/gpg_encrypt_folder.rb', line 65

def recipient
  options.recipient && "--recipient \"#{options.recipient}\""
end

#to_sObject

Note we skip using a random seed file (normally created at var/ukrdc/gpgkey/random_seed) because we had problems at KCH where the file would become corrupt, breaking the export, and fixable only by deleting the random_seed file and letting gpg re-create one. Using the –no-random-seed-file option the file is not used so we avoid that problem.



58
59
60
61
62
63
# File 'lib/gpg_encrypt_folder.rb', line 58

def to_s
  "gpg --armor --no-default-keyring --trust-model always --no-random-seed-file "\
    "#{keyring} #{homedir} #{recipient} "\
    "-o \"#{encrypted_filename}\" "\
    "--encrypt \"#{file}\""
end