Class: Aias::Validator
- Inherits:
-
Object
- Object
- Aias::Validator
- Defined in:
- lib/aias/validator.rb
Defined Under Namespace
Classes: ValidationResult
Constant Summary collapse
- BINARY_FALLBACK_DIRS =
Common locations where version managers install binary shims. Checked as a fallback when the login shell cannot find the binary.
[ File.("~/.rbenv/shims"), File.("~/.rbenv/bin"), File.("~/.rvm/bin"), File.("~/.asdf/shims"), "/usr/local/bin", "/usr/bin", "/opt/homebrew/bin" ].freeze
Instance Method Summary collapse
-
#initialize(shell: ENV.fetch("SHELL", "/bin/bash"), binary_to_check: "aia", fallback_dirs: BINARY_FALLBACK_DIRS) ⇒ Validator
constructor
A new instance of Validator.
-
#validate(scanner_result) ⇒ Object
Returns a ValidationResult for the given PromptScanner::Result.
Constructor Details
#initialize(shell: ENV.fetch("SHELL", "/bin/bash"), binary_to_check: "aia", fallback_dirs: BINARY_FALLBACK_DIRS) ⇒ Validator
22 23 24 25 26 27 28 29 30 |
# File 'lib/aias/validator.rb', line 22 def initialize( shell: ENV.fetch("SHELL", "/bin/bash"), binary_to_check: "aia", fallback_dirs: BINARY_FALLBACK_DIRS ) @shell = shell @binary_to_check = binary_to_check @fallback_dirs = fallback_dirs end |
Instance Method Details
#validate(scanner_result) ⇒ Object
Returns a ValidationResult for the given PromptScanner::Result.
33 34 35 36 37 38 39 |
# File 'lib/aias/validator.rb', line 33 def validate(scanner_result) errors = [] errors.concat(check_schedule_syntax(scanner_result.schedule)) errors.concat(check_parameters(scanner_result.)) errors.concat(aia_binary_errors) ValidationResult.new(valid?: errors.empty?, errors: errors) end |