Module: CucumberAnalytics::Parsing
- Defined in:
- lib/cucumber_analytics/parsing.rb
Overview
A module providing source text parsing functionality.
Class Method Summary collapse
-
.parse_text(source_text) ⇒ Object
Parses the Cucumber feature given in source_text and returns an array containing the hash representation of its logical structure.
Class Method Details
.parse_text(source_text) ⇒ Object
Parses the Cucumber feature given in source_text and returns an array containing the hash representation of its logical structure.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cucumber_analytics/parsing.rb', line 17 def parse_text(source_text) raise(ArgumentError, "Cannot parse #{source_text.class} objects. Strings only.") unless source_text.is_a?(String) io = StringIO.new formatter = Gherkin::Formatter::JSONFormatter.new(io) parser = Gherkin::Parser::Parser.new(formatter) parser.parse(source_text, 'fake_file.txt', 0) formatter.done MultiJson.load(io.string) end |