Class: Reek::Configuration::SchemaValidator
- Inherits:
-
Object
- Object
- Reek::Configuration::SchemaValidator
- Defined in:
- lib/reek/configuration/schema_validator.rb
Overview
Schema validator module.
Instance Method Summary collapse
-
#error_message(errors) ⇒ Object
private
:reek:UtilityFunction.
-
#initialize(configuration) ⇒ SchemaValidator
constructor
A new instance of SchemaValidator.
- #validate ⇒ Object
Constructor Details
#initialize(configuration) ⇒ SchemaValidator
Returns a new instance of SchemaValidator.
12 13 14 15 16 |
# File 'lib/reek/configuration/schema_validator.rb', line 12 def initialize(configuration) @configuration = configuration config_directories = configuration['directories']&.keys || [] @validator = Reek::Configuration::Schema.schema(config_directories) end |
Instance Method Details
#error_message(errors) ⇒ Object (private)
:reek:UtilityFunction
30 31 32 33 34 35 |
# File 'lib/reek/configuration/schema_validator.rb', line 30 def (errors) = errors.map do |error| "[/#{error.path.join('/')}] #{error.text}." end.join("\n") "\n#{}" end |
#validate ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/reek/configuration/schema_validator.rb', line 18 def validate result = @validator.call(@configuration) return if result.success? raise Errors::ConfigFileError, (result.errors) rescue NoMethodError raise Errors::ConfigFileError, 'unrecognized configuration data' end |