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

[ :encfs, :umount, :umount_delay ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



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

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.



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

def boxes
  @boxes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

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



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

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



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

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

#loadObject



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

def load
  configure file
end