class Boxafe::Encfs

Public Class Methods

new(options = {}) click to toggle source
# File lib/boxafe/encfs.rb, line 6
def initialize options = {}
  @options = options
end

Public Instance Methods

command() click to toggle source
# File lib/boxafe/encfs.rb, line 10
def command
  [
    encfs_config,
    Shellwords.escape(@options[:encfs]),
    Shellwords.escape(absolute_root_dir),
    Shellwords.escape(absolute_mount_dir),
    extpass,
    '--',
    volname
  ].compact.join ' '
end

Private Instance Methods

absolute_mount_dir() click to toggle source
# File lib/boxafe/encfs.rb, line 29
def absolute_mount_dir
  File.expand_path @options[:mount], Dir.pwd
end
absolute_root_dir() click to toggle source
# File lib/boxafe/encfs.rb, line 24
def absolute_root_dir
  # TODO: remove Dir.pwd once fakefs is fixed (multiple occurrences in this file)
  File.expand_path @options[:root], Dir.pwd
end
encfs_config() click to toggle source
# File lib/boxafe/encfs.rb, line 47
def encfs_config
  @options[:encfs_config] ? %/ENCFS6_CONFIG=#{Shellwords.escape File.expand_path(@options[:encfs_config], Dir.pwd)}/ : nil
end
extpass() click to toggle source
# File lib/boxafe/encfs.rb, line 37
def extpass
  if @options[:password_file]
    %|--extpass="head -n 1 #{Shellwords.escape File.expand_path(@options[:password_file], Dir.pwd)}"|
  elsif @options[:keychain]
    %*--extpass="security 2>&1 >/dev/null find-generic-password -gl '#{@options[:keychain]}' |grep password|cut -d \\\\\\" -f 2"*
  else
    nil
  end
end
volname() click to toggle source
# File lib/boxafe/encfs.rb, line 33
def volname
  %/-ovolname=#{Shellwords.escape @options[:volume]}/
end