Class: Boxafe::Validator
- Inherits:
-
Object
- Object
- Boxafe::Validator
- Defined in:
- lib/boxafe/validator.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Validator
constructor
A new instance of Validator.
- #validate(options = {}) ⇒ Object
- #validate_global_options(options = {}) ⇒ Object
- #validate_mount_options(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Validator
Returns a new instance of Validator.
6 7 8 |
# File 'lib/boxafe/validator.rb', line 6 def initialize = {} @raise_first = [:raise_first] end |
Instance Method Details
#validate(options = {}) ⇒ Object
10 11 12 |
# File 'lib/boxafe/validator.rb', line 10 def validate = {} () + () end |
#validate_global_options(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/boxafe/validator.rb', line 14 def = {} errors = [] encfs_bin, umount_bin = [:encfs], [:umount] add "could not find encfs binary '#{encfs_bin}'; is it in the PATH?", :encfs, errors unless Which.which encfs_bin add "could not find umount binary '#{umount_bin}'; is it in the PATH?", :umount, errors unless Which.which umount_bin errors end |
#validate_mount_options(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/boxafe/validator.rb', line 25 def = {} errors = [] validate_file :root, 'root directory', [:root], errors, required: true validate_file :mount, 'mount directory', [:mount], errors, required: true, presence: false validate_file :password_file, 'password file', [:password_file], errors, file: true validate_file :config_file, 'config file', [:config_file], errors, file: true if [:password_file] and [:keychain] add "cannot use both a password file and the keychain", :keychain, errors end errors end |