Class: Boxafe::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/boxafe/config.rb

Defined Under Namespace

Classes: DSL

Constant Summary collapse

OPTION_KEYS =

TODO: document unmount_delay TODO: add option to chdir, boxes relative to working directory when calling start by default

[ :encfs, :umount, :umount_delay, :notify ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.


10
11
12
13
# File 'lib/boxafe/config.rb', line 10

def initialize options = {}
  @boxes = []
  @options = { encfs: 'encfs', umount: 'umount', umount_delay: 0.5 }.merge options
end

Instance Attribute Details

#boxesObject (readonly)

Returns the value of attribute boxes


8
9
10
# File 'lib/boxafe/config.rb', line 8

def boxes
  @boxes
end

#optionsObject (readonly)

Returns the value of attribute options


8
9
10
# File 'lib/boxafe/config.rb', line 8

def options
  @options
end

Instance Method Details

#configure(file = nil, &block) ⇒ Object


15
16
17
18
19
20
21
# File 'lib/boxafe/config.rb', line 15

def configure file = nil, &block
  DSL.new(self).tap do |dsl|
    dsl.instance_eval File.read(file), file if file
    dsl.instance_eval &block if block
  end
  self
end

#fileObject


27
28
29
# File 'lib/boxafe/config.rb', line 27

def file
  File.expand_path [ @options[:config], ENV['BOXAFE_CONFIG'], "~/.boxafe.rb" ].compact.first
end

#loadObject


23
24
25
# File 'lib/boxafe/config.rb', line 23

def load
  configure file
end