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
[ :encfs, :umount, :umount_delay ]
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.
9 10 11 12 |
# File 'lib/boxafe/config.rb', line 9 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.
7 8 9 |
# File 'lib/boxafe/config.rb', line 7 def boxes @boxes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/boxafe/config.rb', line 7 def @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 |
#file ⇒ Object
26 27 28 |
# File 'lib/boxafe/config.rb', line 26 def file File. [ @options[:config], ENV['BOXAFE_CONFIG'], "~/.boxafe.rb" ].compact.first end |
#load ⇒ Object
22 23 24 |
# File 'lib/boxafe/config.rb', line 22 def load configure file end |