Sha256: 5b56b5d07d87cfca9b3b2df07ee30a03f52277b33afecdcdc8a8bbdb545aef18

Contents?: true

Size: 625 Bytes

Versions: 2

Compression:

Stored size: 625 Bytes

Contents

require 'gherkin/formatter/json_formatter'
require 'gherkin/parser/parser'

module Gherkin::Formatter
  class JSONFormatter
    def to_hash
      @feature_hash
    end
  end
end

module Nuker
  class ParsesFeatures
    def parse text
      io = StringIO.new
      formatter = Gherkin::Formatter::JSONFormatter.new(io)
      parser = Gherkin::Parser::Parser.new(formatter, false, 'root')
      begin
        parser.parse(text, nil, 0)
      rescue Exception => e
        raise FeatureParseException.new
      end
      hash = formatter.to_hash
      hash
    end
  end

  class FeatureParseException < StandardError
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nuker-2.0.0 lib/nuker/parses_features.rb
nuker-1.0.0 lib/nuker/parses_features.rb