Class: Boxafe::Config
- Inherits:
-
Object
- Object
- Boxafe::Config
- 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
-
#boxes ⇒ Object
readonly
Returns the value of attribute boxes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #configure(file = nil, &block) ⇒ Object
- #file ⇒ Object
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #load ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
10 11 12 13 |
# File 'lib/boxafe/config.rb', line 10 def initialize = {} @boxes = [] @options = { encfs: 'encfs', umount: 'umount', umount_delay: 0.5 }.merge end |
Instance Attribute Details
#boxes ⇒ Object (readonly)
Returns the value of attribute boxes.
8 9 10 |
# File 'lib/boxafe/config.rb', line 8 def boxes @boxes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/boxafe/config.rb', line 8 def @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 |
#file ⇒ Object
27 28 29 |
# File 'lib/boxafe/config.rb', line 27 def file File. [ @options[:config], ENV['BOXAFE_CONFIG'], "~/.boxafe.rb" ].compact.first end |
#load ⇒ Object
23 24 25 |
# File 'lib/boxafe/config.rb', line 23 def load configure file end |