module Ulock

Constants

EXCLUDE_EXTENSIONS
PROMPT
VERSION

Public Class Methods

decrypt_file(encrypted_filename) click to toggle source
# File lib/ulock.rb, line 35
def decrypt_file(encrypted_filename)
  dest_filename = encrypted_filename.gsub('.gpg', '')
  `gpg -d #{encrypted_filename} > #{dest_filename}`
end
decrypt_multiple(filenames) click to toggle source
# File lib/ulock.rb, line 40
def decrypt_multiple(filenames)
  bar = TTY::ProgressBar.new("Decrypting :filename [:bar]", total: filenames.length * 5)
  filenames.each do |file|
    decrypt_file file
    bar.advance 5, filename: file
  end
  bar.finish
end
encrypt_file(filename, recipient) click to toggle source
# File lib/ulock.rb, line 31
def encrypt_file(filename, recipient)
  `gpg -r #{recipient} -e #{filename}`
end
encrypt_multiple(filenames, recipient) click to toggle source
# File lib/ulock.rb, line 49
def encrypt_multiple(filenames, recipient)
  bar = TTY::ProgressBar.new("Encrypting :filename [:bar]", total: filenames.length * 5)
  filenames.each do |file|
    bar.advance 5, filename: file
    encrypt_file file, recipient
  end
  bar.finish
end
encrypted_files() click to toggle source
# File lib/ulock.rb, line 12
def encrypted_files
  files('**/*.gpg')
end
files(glob) click to toggle source
# File lib/ulock.rb, line 8
def files(glob)
  Dir.glob(glob).reject { |f| File.directory?(f) }
end
missing_decrypted_version() click to toggle source
# File lib/ulock.rb, line 21
def missing_decrypted_version
  of = other_files
  encrypted_files.select { |filename| !of.include?(filename.gsub(/.gpg/, '')) }
end
missing_encrypted_version() click to toggle source
# File lib/ulock.rb, line 26
def missing_encrypted_version
  ef = encrypted_files
  other_files.select { |filename| !ef.include?(filename + '.gpg') }
end
other_files() click to toggle source
# File lib/ulock.rb, line 16
def other_files
  glb = "**/*[!.gpg,#{EXCLUDE_EXTENSIONS.join(",")}]"
  files(glb) 
end