Module: CukeModeler::Parsing
- Included in:
- Background, Cell, Comment, DocString, Example, Outline, Row, Scenario, Step, Table, Tag
- Defined in:
- lib/cuke_modeler/parsing.rb
Overview
A module providing source text parsing functionality.
Class Attribute Summary collapse
-
.dialect ⇒ Object
The dialect that will be used to parse snippets of Gherkin text.
Class Method Summary collapse
-
.dialects ⇒ Object
The dialects currently known by the gherkin gem.
-
.parse_text(source_text, filename = 'cuke_modeler_fake_file.feature') ⇒ Object
Parses the Cucumber feature given in source_text and returns a hash representation of its logical structure.
Class Attribute Details
.dialect ⇒ Object
The dialect that will be used to parse snippets of Gherkin text
42 43 44 |
# File 'lib/cuke_modeler/parsing.rb', line 42 def dialect @dialect || 'en' end |
Class Method Details
.dialects ⇒ Object
The dialects currently known by the gherkin gem
47 48 49 50 51 52 53 |
# File 'lib/cuke_modeler/parsing.rb', line 47 def dialects unless @dialects @dialects = Gherkin::DIALECTS end @dialects end |
.parse_text(source_text, filename = 'cuke_modeler_fake_file.feature') ⇒ Object
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
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cuke_modeler/parsing.rb', line 58 def parse_text(source_text, filename = 'cuke_modeler_fake_file.feature') raise(ArgumentError, "Text to parse must be a String but got #{source_text.class}") unless source_text.is_a?(String) begin parsed_result = parsing_method(source_text.encode('UTF-8'), filename) rescue => e raise(ArgumentError, "Error encountered while parsing '#{filename}'\n#{e.class} - #{e.message}") end adapter_class.new.adapt(parsed_result) end |