Class: Rutema::Parsers::SpecificationParser
- Inherits:
-
Object
- Object
- Rutema::Parsers::SpecificationParser
- Defined in:
- lib/rutema/core/parser.rb
Overview
Base class for parser implementations
This class itself is not operational but only throws exceptions upon
invocations of its parse_* methods. Its sole purpose is to define a
common interface for parser classes.
Derived classes should implement at least the parse_specification and validate_configuration methods.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
The Configuration instance passed to and used by the initializer.
Instance Method Summary collapse
-
#initialize(configuration) ⇒ SpecificationParser
constructor
Initialize a new instance internally storing and validating the passed Configuration instance.
-
#parse_setup(param) ⇒ Object
Parse a setup specification.
-
#parse_specification(_param) ⇒ Object
Parse a test specification.
-
#parse_teardown(param) ⇒ Object
Parse a teardown specification.
-
#validate_configuration ⇒ Object
Validate the Configuration instance which is stored by the parser internally.
Constructor Details
#initialize(configuration) ⇒ SpecificationParser
Initialize a new instance internally storing and validating the passed Configuration instance
26 27 28 29 30 |
# File 'lib/rutema/core/parser.rb', line 26 def initialize(configuration) @configuration = configuration @configuration ||= {} validate_configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
The Configuration instance passed to and used by the initializer
21 22 23 |
# File 'lib/rutema/core/parser.rb', line 21 def configuration @configuration end |
Instance Method Details
#parse_setup(param) ⇒ Object
Parse a setup specification
This calls #parse_specification by default.
45 46 47 |
# File 'lib/rutema/core/parser.rb', line 45 def parse_setup(param) parse_specification(param) end |
#parse_specification(_param) ⇒ Object
Parse a test specification
The passed argument can either be the path to a test specification file or the test specification itself.
37 38 39 |
# File 'lib/rutema/core/parser.rb', line 37 def parse_specification(_param) raise ParserError, "not implemented. You should derive a parser implementation from SpecificationParser!" end |
#parse_teardown(param) ⇒ Object
Parse a teardown specification
This calls #parse_specification by default.
53 54 55 |
# File 'lib/rutema/core/parser.rb', line 53 def parse_teardown(param) parse_specification(param) end |
#validate_configuration ⇒ Object
Validate the Configuration instance which is stored by the parser internally
To avoid validating the configuration in element_* methods repeatedly, do all configuration validation here
62 63 |
# File 'lib/rutema/core/parser.rb', line 62 def validate_configuration end |