Sha256: 27e28e4416d1bee0a08dc165a25746aae418acaeb860c3794f45a066c9e59ce8

Contents?: true

Size: 569 Bytes

Versions: 42

Compression:

Stored size: 569 Bytes

Contents

require 'gherkin/parser/parser'
require 'gherkin/formatter/json_formatter'
require 'stringio'
require 'json'

# This example reads a couple of features and outputs them as JSON.

io = StringIO.new
formatter = Gherkin::Formatter::JSONFormatter.new(io)
parser = Gherkin::Parser::Parser.new(formatter)

sources = ["features/native_lexer.feature", "features/escaped_pipes.feature"]
sources.each do |s|
  path = File.expand_path(File.dirname(__FILE__) + '/../' + s)
  parser.parse(IO.read(path), path, 0)
end

formatter.done
puts JSON.pretty_generate(JSON.parse(io.string))

Version data entries

42 entries across 40 versions & 5 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/1.8/gems/gherkin-2.11.1/examples/parse_and_output_json.rb
candlepin-api-0.4.0 bundle/ruby/gems/gherkin-2.11.1/examples/parse_and_output_json.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/gherkin-2.11.1/examples/parse_and_output_json.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/gherkin-2.11.6/examples/parse_and_output_json.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/gherkin-2.11.6/examples/parse_and_output_json.rb
gherkin-2.11.6 examples/parse_and_output_json.rb
gherkin-2.11.6-x86-mswin32 examples/parse_and_output_json.rb
gherkin-2.11.6-x86-mingw32 examples/parse_and_output_json.rb
gherkin-2.11.6-java examples/parse_and_output_json.rb
gherkin-2.11.5 examples/parse_and_output_json.rb
gherkin-2.11.5-x86-mswin32 examples/parse_and_output_json.rb
gherkin-2.11.5-x86-mingw32 examples/parse_and_output_json.rb
gherkin-2.11.5-java examples/parse_and_output_json.rb
gherkin-2.11.4 examples/parse_and_output_json.rb
gherkin-2.11.4-x86-mswin32 examples/parse_and_output_json.rb
gherkin-2.11.4-x86-mingw32 examples/parse_and_output_json.rb
gherkin-2.11.4-java examples/parse_and_output_json.rb
gherkin-2.11.3 examples/parse_and_output_json.rb
gherkin-2.11.3-x86-mswin32 examples/parse_and_output_json.rb
gherkin-2.11.3-x86-mingw32 examples/parse_and_output_json.rb