Module: Buildozer::Dsl::Compiler::Validator
- Defined in:
- lib/buildozer/dsl/compiler/validator.rb
Class Method Summary collapse
- .validate_architecture(architecture) ⇒ Object
-
.validate_definition(definition) ⇒ Object
Receive a dsl definition and validates that it is well-formed.
-
.validate_fragment(fragment) ⇒ Object
Receive a dsl fragment and validates that it is well-formed.
-
.validate_package(package) ⇒ Object
Receive a dsl package and validates that it is well-formed.
Class Method Details
.validate_architecture(architecture) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/buildozer/dsl/compiler/validator.rb', line 56 def self.validate_architecture(architecture) if architecture == :auto or (architecture.kind_of?(String) and not architecture == "") return end raise InvalidDslPackage, "Invalid package, architecture must be :auto or a non-empty String, currently [#{architecture}]" end |
.validate_definition(definition) ⇒ Object
Receive a dsl definition and validates that it is well-formed.
For now, exceptions are raised when something is wrong.
27 28 29 30 31 32 |
# File 'lib/buildozer/dsl/compiler/validator.rb', line 27 def self.validate_definition(definition) = definition.() if not .has_key?(:packages) or [:packages].empty?() raise InvalidDslDefinition, "Invalid definition, must have a least one 'package'" end end |
.validate_fragment(fragment) ⇒ Object
Receive a dsl fragment and validates that it is well-formed. A dsl fragment is any valid dsl class that can be compiled.
For now, exceptions are raised when something is wrong.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/buildozer/dsl/compiler/validator.rb', line 11 def self.validate_fragment(fragment) if not fragment.kind_of?(Fragment) or not fragment.respond_to?(:type) raise InvalidDslFragment, "Cannot compile, the argument received is not a dsl fragment" end compiler = "compile_#{fragment.type()}" if not Compiler.respond_to?(compiler) raise InvalidDslFragment, "Does not know how to compile fragment [#{fragment.type()}]" end end |
.validate_package(package) ⇒ Object
Receive a dsl package and validates that it is well-formed.
For now, exceptions are raised when something is wrong.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/buildozer/dsl/compiler/validator.rb', line 39 def self.validate_package(package) = package.() if not .has_key?(:version) raise InvalidDslPackage, "Invalid package, must have a 'version'" end if not .has_key?(:url) raise InvalidDslPackage, "Invalid package, must have an 'url'" end if .has_key?(:architecture) architecture = [:architecture] validate_architecture(architecture) end end |