Module: CukeModeler::Parsing
- Included in:
- Background, Cell, Comment, DocString, Example, Outline, Row, Rule, Scenario, Step, Table, Tag
- Defined in:
- lib/cuke_modeler/parsing.rb
Overview
A module providing source text parsing functionality.
Class Attribute Summary collapse
-
.dialect ⇒ String
The dialect that will be used to parse snippets of Gherkin text.
Class Method Summary collapse
-
.dialects ⇒ Hash
The dialects currently known by the cucumber-gherkin gem.
-
.parse_text(source_text, filename = 'cuke_modeler_fake_file.feature') ⇒ Hash
Parses the Cucumber feature given in source_text and returns a Hash representation of its logical structure.
Class Attribute Details
.dialect ⇒ String
The dialect that will be used to parse snippets of Gherkin text
36 37 38 |
# File 'lib/cuke_modeler/parsing.rb', line 36 def dialect @dialect || 'en' end |
Class Method Details
.dialects ⇒ Hash
The dialects currently known by the cucumber-gherkin gem. See Gherkin::DIALECTS.
46 47 48 |
# File 'lib/cuke_modeler/parsing.rb', line 46 def dialects Gherkin::DIALECTS end |
.parse_text(source_text, filename = 'cuke_modeler_fake_file.feature') ⇒ Hash
Parses the Cucumber feature given in source_text and returns a Hash representation of its logical structure. This is a standardized AST that should remain consistent across different versions of ‘cucumber-gherkin`
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cuke_modeler/parsing.rb', line 63 def parse_text(source_text, filename = 'cuke_modeler_fake_file.feature') unless source_text.is_a?(String) raise(ArgumentError, "Text to parse must be a String but got #{source_text.class}") end begin parsed_result = parsing_method(source_text.encode('UTF-8'), filename) rescue => e raise(ArgumentError, "Error encountered while parsing '#{filename}'\n#{e.class} - #{e.}") end adapter_class.new.adapt(parsed_result) end |