class Boxafe::Box
Constants
- OPTION_KEYS
Public Class Methods
new(options = {})
click to toggle source
# File lib/boxafe/box.rb, line 9 def initialize options = {} raise OptionError.new("The :name option is required", :name) unless options[:name] @options = options @validator = Validator.new raise_first: true end
Public Instance Methods
command()
click to toggle source
# File lib/boxafe/box.rb, line 19 def command encfs.command end
configure(options = {})
click to toggle source
# File lib/boxafe/box.rb, line 47 def configure options = {}, &block @options.merge! options DSL.new(@options).instance_eval &block if block self end
mount()
click to toggle source
# File lib/boxafe/box.rb, line 23 def mount @validator.validate mount_options ensure_mount_point system command end
mount_options()
click to toggle source
# File lib/boxafe/box.rb, line 41 def mount_options default_mount_options.merge(@options).tap do |options| options[:keychain] = @options[:name] if options[:keychain] == true end end
mounted?()
click to toggle source
# File lib/boxafe/box.rb, line 36 def mounted? # TODO: check if it's possible to differentiate between an empty mounted directory and an unmounted directory File.directory?(mount_options[:mount]) && !Dir.entries(mount_options[:mount]).reject{ |e| e.match(/^\.{1,2}$/) }.empty? end
name()
click to toggle source
# File lib/boxafe/box.rb, line 15 def name @options[:name] end
unmount()
click to toggle source
# File lib/boxafe/box.rb, line 29 def unmount options = mount_options result = system "#{options[:umount]} #{options[:mount]}" sleep options[:umount_delay] if options[:umount_delay] and options[:umount_delay] > 0 result end
Private Instance Methods
default_mount_options()
click to toggle source
# File lib/boxafe/box.rb, line 63 def default_mount_options name = @options[:name] { # TODO: change default root and mount dirs depending on host os root: "~/Dropbox/#{name}", mount: "/Volumes/#{name}", volume: name } end
encfs()
click to toggle source
# File lib/boxafe/box.rb, line 59 def encfs Boxafe::Encfs.new mount_options end
ensure_mount_point()
click to toggle source
# File lib/boxafe/box.rb, line 55 def ensure_mount_point FileUtils.mkdir_p mount_options[:mount] end