Class: FluentCommandBuilder::PathValidator
- Inherits:
-
Object
- Object
- FluentCommandBuilder::PathValidator
- Defined in:
- lib/fluent_command_builder/internal/path_validator.rb
Instance Attribute Summary collapse
-
#printer ⇒ Object
Returns the value of attribute printer.
-
#should_abort_on_fatal ⇒ Object
Returns the value of attribute should_abort_on_fatal.
Instance Method Summary collapse
-
#initialize(command_builder_config) ⇒ PathValidator
constructor
A new instance of PathValidator.
- #validate ⇒ Object
Constructor Details
#initialize(command_builder_config) ⇒ PathValidator
Returns a new instance of PathValidator.
9 10 11 12 13 |
# File 'lib/fluent_command_builder/internal/path_validator.rb', line 9 def initialize(command_builder_config) @c = command_builder_config @printer = Printer.new @should_abort_on_fatal = true end |
Instance Attribute Details
#printer ⇒ Object
Returns the value of attribute printer.
7 8 9 |
# File 'lib/fluent_command_builder/internal/path_validator.rb', line 7 def printer @printer end |
#should_abort_on_fatal ⇒ Object
Returns the value of attribute should_abort_on_fatal.
7 8 9 |
# File 'lib/fluent_command_builder/internal/path_validator.rb', line 7 def should_abort_on_fatal @should_abort_on_fatal end |
Instance Method Details
#validate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fluent_command_builder/internal/path_validator.rb', line 15 def validate validate_validation_level return if validation_level == :off if @c.path p = Path.new @c.path evaluated_path = p.evaluated_path return if File.exist? evaluated_path = %Q[Path for command "#{@c.command_name}", version "#{@c.version}" does not exist. Path: #{evaluated_path}] else return if WickedWitch[@c.command_name] = %Q[Command "#{@c.command_name}" was not found on the PATH.] end case validation_level when :warn @printer.print_warning when :fatal @printer.print_error abort if @should_abort_on_fatal else # do nothing end end |