Class: Boxafe::Box
- Inherits:
-
Object
- Object
- Boxafe::Box
- Defined in:
- lib/boxafe/box.rb
Defined Under Namespace
Classes: DSL
Constant Summary collapse
- OPTION_KEYS =
[ :name, :root, :mount, :volume, :encfs_config, :keychain, :password_file ]
Instance Method Summary collapse
- #command ⇒ Object
- #configure(options = {}, &block) ⇒ Object
-
#initialize(options = {}) ⇒ Box
constructor
A new instance of Box.
- #mount ⇒ Object
- #mount_options ⇒ Object
- #mounted? ⇒ Boolean
- #name ⇒ Object
- #unmount ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Box
Returns a new instance of Box.
9 10 11 12 13 |
# File 'lib/boxafe/box.rb', line 9 def initialize = {} raise OptionError.new("The :name option is required", :name) unless [:name] @options = @validator = Validator.new raise_first: true end |
Instance Method Details
#command ⇒ Object
19 20 21 |
# File 'lib/boxafe/box.rb', line 19 def command encfs.command end |
#configure(options = {}, &block) ⇒ Object
46 47 48 49 50 |
# File 'lib/boxafe/box.rb', line 46 def configure = {}, &block @options.merge! DSL.new(@options).instance_eval &block if block self end |
#mount ⇒ Object
23 24 25 26 27 |
# File 'lib/boxafe/box.rb', line 23 def mount @validator.validate ensure_mount_point system command end |
#mount_options ⇒ Object
40 41 42 43 44 |
# File 'lib/boxafe/box.rb', line 40 def .merge(@options).tap do || [:keychain] = @options[:name] if [:keychain] == true end end |
#mounted? ⇒ Boolean
36 37 38 |
# File 'lib/boxafe/box.rb', line 36 def mounted? File.directory? [:mount] end |
#name ⇒ Object
15 16 17 |
# File 'lib/boxafe/box.rb', line 15 def name @options[:name] end |
#unmount ⇒ Object
29 30 31 32 33 34 |
# File 'lib/boxafe/box.rb', line 29 def unmount = result = system "#{[:umount]} #{[:mount]}" sleep [:umount_delay] if [:umount_delay] and [:umount_delay] > 0 result end |