Class: GpgCommand

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

Instance Method Summary collapse

Instance Method Details

#encrypted_filenameObject



87
88
89
# File 'lib/gpg_encrypt_folder.rb', line 87

def encrypted_filename
  options.destination_folder.join(output_filename)
end

#filename_without_extensionObject



79
80
81
# File 'lib/gpg_encrypt_folder.rb', line 79

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

#homedirObject



71
72
73
# File 'lib/gpg_encrypt_folder.rb', line 71

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

#keyringObject



75
76
77
# File 'lib/gpg_encrypt_folder.rb', line 75

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

#output_filenameObject



83
84
85
# File 'lib/gpg_encrypt_folder.rb', line 83

def output_filename
  "#{filename_without_extension}.gpg"
end

#recipientObject



67
68
69
# File 'lib/gpg_encrypt_folder.rb', line 67

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.



60
61
62
63
64
65
# File 'lib/gpg_encrypt_folder.rb', line 60

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