Class: FluentCommandBuilder::VersionValidator
- Inherits:
-
Object
- Object
- FluentCommandBuilder::VersionValidator
- Defined in:
- lib/fluent_command_builder/version_validator.rb
Instance Attribute Summary collapse
-
#get_version ⇒ Object
writeonly
Sets the attribute get_version.
-
#printer ⇒ Object
Returns the value of attribute printer.
-
#should_abort_on_fatal ⇒ Object
Returns the value of attribute should_abort_on_fatal.
-
#validation_level ⇒ Object
writeonly
Sets the attribute validation_level.
Instance Method Summary collapse
-
#initialize(target_name, &get_version) ⇒ VersionValidator
constructor
A new instance of VersionValidator.
- #validate(expected_version_string, path = nil) ⇒ Object
Constructor Details
#initialize(target_name, &get_version) ⇒ VersionValidator
Returns a new instance of VersionValidator.
10 11 12 13 14 15 16 |
# File 'lib/fluent_command_builder/version_validator.rb', line 10 def initialize(target_name, &get_version) @target_name = target_name @validation_level = :fatal @should_abort_on_fatal = true @printer = FluentCommandBuilder::Printer.new @get_version = get_version end |
Instance Attribute Details
#get_version=(value) ⇒ Object
Sets the attribute get_version
8 9 10 |
# File 'lib/fluent_command_builder/version_validator.rb', line 8 def get_version=(value) @get_version = value end |
#printer ⇒ Object
Returns the value of attribute printer.
8 9 10 |
# File 'lib/fluent_command_builder/version_validator.rb', line 8 def printer @printer end |
#should_abort_on_fatal ⇒ Object
Returns the value of attribute should_abort_on_fatal.
8 9 10 |
# File 'lib/fluent_command_builder/version_validator.rb', line 8 def should_abort_on_fatal @should_abort_on_fatal end |
#validation_level=(value) ⇒ Object
Sets the attribute validation_level
8 9 10 |
# File 'lib/fluent_command_builder/version_validator.rb', line 8 def validation_level=(value) @validation_level = value end |
Instance Method Details
#validate(expected_version_string, path = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fluent_command_builder/version_validator.rb', line 18 def validate(expected_version_string, path=nil) validate_validation_level return if @validation_level == :off p = Path.new path @expected_version_string = expected_version_string @actual_version_string = get_version File.join(p.evaluated_path, @target_name) unless actual_version @printer.print_warning ('unable to determine actual version') return end unless is_valid? = actual_version.first(expected_version.to_a.length) case validation_level when :warn @printer.print_warning when :fatal @printer.print_error abort if @should_abort_on_fatal else # do nothing end end end |