Class: Tay::SpecificationValidator
- Inherits:
-
Object
- Object
- Tay::SpecificationValidator
- Defined in:
- lib/tay/specification_validator.rb
Overview
Takes a Tay::Specification and does sanity checks for missing required fields. It also looks for common mistakes and mutually exclusive flags.
If the output directory is supplied (referencing the compiled extension), the existence of files referenced in the specification will also be checked for their presence.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#on_message ⇒ Object
A proc object that will be called on each message with the type and msg.
-
#spec ⇒ Object
readonly
Pointer to the relevant Tay::Specification.
-
#violent ⇒ Object
If true (default) throw an exception on error.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
-
.validate(specification, output_directory = nil) ⇒ Object
Convenience method to validate a specification.
Instance Method Summary collapse
-
#initialize(specification, output_directory = nil) ⇒ SpecificationValidator
constructor
A new instance of SpecificationValidator.
-
#validate! ⇒ Object
Facade method to call the private validation methods.
Constructor Details
#initialize(specification, output_directory = nil) ⇒ SpecificationValidator
Returns a new instance of SpecificationValidator.
34 35 36 37 38 39 |
# File 'lib/tay/specification_validator.rb', line 34 def initialize(specification, output_directory = nil) @spec = specification @out = output_directory ? Pathname.new(output_directory) : nil @errors = [] @warnings = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
23 24 25 |
# File 'lib/tay/specification_validator.rb', line 23 def errors @errors end |
#on_message ⇒ Object
A proc object that will be called on each message with the type and msg
20 21 22 |
# File 'lib/tay/specification_validator.rb', line 20 def @on_message end |
#spec ⇒ Object (readonly)
Pointer to the relevant Tay::Specification
12 13 14 |
# File 'lib/tay/specification_validator.rb', line 12 def spec @spec end |
#violent ⇒ Object
If true (default) throw an exception on error
16 17 18 |
# File 'lib/tay/specification_validator.rb', line 16 def violent @violent end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
22 23 24 |
# File 'lib/tay/specification_validator.rb', line 22 def warnings @warnings end |
Class Method Details
.validate(specification, output_directory = nil) ⇒ Object
Convenience method to validate a specification. Creates a validator and runs it. Will throw an exception if invalid.
28 29 30 31 32 |
# File 'lib/tay/specification_validator.rb', line 28 def self.validate(specification, output_directory = nil) validator = SpecificationValidator.new(specification, output_directory) validator.violent = true validator.validate! end |
Instance Method Details
#validate! ⇒ Object
Facade method to call the private validation methods. Will return true if there were no warnings or errors
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tay/specification_validator.rb', line 44 def validate! validate_name validate_version validate_icons validate_description check_for_browser_ui_collisions check_file_presence if @out @warnings.empty? && @errors.empty? end |