Class: Cucumber::Core::Gherkin::Parser
- Inherits:
-
Object
- Object
- Cucumber::Core::Gherkin::Parser
- Defined in:
- lib/cucumber/core/gherkin/parser.rb
Instance Method Summary collapse
- #document(document) ⇒ Object
- #done ⇒ Object
-
#initialize(receiver) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(receiver) ⇒ Parser
Returns a new instance of Parser.
16 17 18 |
# File 'lib/cucumber/core/gherkin/parser.rb', line 16 def initialize(receiver) @receiver = receiver end |
Instance Method Details
#document(document) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cucumber/core/gherkin/parser.rb', line 20 def document(document) parser = ::Gherkin::Parser.new scanner = ::Gherkin::TokenScanner.new(document.body) core_builder = AstBuilder.new(document.uri) if document.body.strip.empty? return receiver.feature Ast::NullFeature.new end begin result = parser.parse(scanner) receiver.feature core_builder.feature(result) rescue *PARSER_ERRORS => e raise Core::Gherkin::ParseError.new("#{document.uri}: #{e.}") end end |
#done ⇒ Object
38 39 40 41 |
# File 'lib/cucumber/core/gherkin/parser.rb', line 38 def done receiver.done self end |