Sha256: 3dff714e0856f4ba9a7bd91ddbca6042ed377d32390e6530218d190bb19b0943
Contents?: true
Size: 821 Bytes
Versions: 7
Compression:
Stored size: 821 Bytes
Contents
require 'stringio' require 'gherkin/formatter/json_formatter' require 'gherkin' module CucumberAnalytics # A module providing source text parsing functionality. module Parsing class << self # Parses the Cucumber feature given in *source_text* and returns an array # containing the hash representation of its logical structure. 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 JSON.parse(io.string) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems