class Ulock::Interface
Public Class Methods
new(recipient=nil)
click to toggle source
# File lib/ulock.rb, line 60 def initialize(recipient=nil) @recipient = recipient end
Public Instance Methods
any?()
click to toggle source
# File lib/ulock.rb, line 94 def any? Ulock.missing_encrypted_version.any? || Ulock.missing_decrypted_version.any? end
decrypt(filename)
click to toggle source
# File lib/ulock.rb, line 117 def decrypt(filename) PROMPT.say "decrypting #{encrypted_filename} to #{encrypted_filename.gsub('.gpg', '')}" Ulock.decrypt_file(filename) end
encrypt(filename)
click to toggle source
# File lib/ulock.rb, line 111 def encrypt(filename) get_recipient! PROMPT.say "adding an encrypted version of #{filename} (r: #{recipient})" Ulock.encrypt_file(filename, @recipient) end
fix_all()
click to toggle source
# File lib/ulock.rb, line 104 def fix_all get_recipient! PROMPT.say "Encrypting and Decrypting all the files" Ulock.encrypt_multiple(Ulock.missing_encrypted_version, @recipient) Ulock.decrypt_multiple(Ulock.missing_decrypted_version) end
get_recipient!()
click to toggle source
# File lib/ulock.rb, line 98 def get_recipient! if !@recipient @recipient = PROMPT.ask("Encryption recipient: ") end end
interactive()
click to toggle source
# File lib/ulock.rb, line 130 def interactive get_recipient! to_encrypt = prompt_encrypt to_decrypt = prompt_decrypt Ulock.encrypt_multiple(to_encrypt, @recipient) Ulock.decrypt_multiple(to_decrypt) end
shorthelp()
click to toggle source
# File lib/ulock.rb, line 85 def shorthelp if any? PROMPT.say "#{$0} fix all #encrypt and decrypt all", color: :red PROMPT.say "#{$0} interactive #encrypt and decrypt interactively", color: :red end PROMPT.say "#{$0} --help #for more", color: :red end
status()
click to toggle source
# File lib/ulock.rb, line 64 def status ef = Ulock.missing_decrypted_version if ef.any? PROMPT.say "#{ef.count} files to be decrypted:", color: :bright_magenta PROMPT.say ef.join("\n"), color: :magenta puts "\n" else PROMPT.say "No files to be decrypted" end df = Ulock.missing_encrypted_version if df.any? PROMPT.say "#{df.count} files to be encrypted: \r", color: :bright_blue PROMPT.say df.join("\n"), color: :blue puts "\n" else PROMPT.say "No files to be encrypted" end end
Private Instance Methods
prompt_decrypt()
click to toggle source
# File lib/ulock.rb, line 126 def prompt_decrypt PROMPT.multi_select "Select files for decryption", Ulock.missing_decrypted_version end
prompt_encrypt()
click to toggle source
# File lib/ulock.rb, line 122 def prompt_encrypt PROMPT.multi_select "Select files for encryption", Ulock.missing_encrypted_version end