Sha256: 9442ab054bd337341b1aefec361deec7341efa579736eae59a99c74094dfd0a9

Contents?: true

Size: 570 Bytes

Versions: 69

Compression:

Stored size: 570 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.close
puts JSON.pretty_generate(JSON.parse(io.string))

Version data entries

69 entries across 68 versions & 4 rubygems

Version Path
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/gherkin-2.9.0/examples/parse_and_output_json.rb
resque-pool-0.3.0 vendor/bundle/ruby/1.8/gems/gherkin-2.9.3/examples/parse_and_output_json.rb
frameworks-capybara-0.2.0.rc6 vendor/bundle/ruby/1.8/gems/gherkin-2.9.3/examples/parse_and_output_json.rb
frameworks-capybara-0.2.0.rc5 vendor/bundle/ruby/1.8/gems/gherkin-2.9.3/examples/parse_and_output_json.rb
frameworks-capybara-0.2.0.rc4 vendor/bundle/ruby/1.8/gems/gherkin-2.9.3/examples/parse_and_output_json.rb
frameworks-capybara-0.2.0.rc3 vendor/bundle/ruby/1.8/gems/gherkin-2.9.3/examples/parse_and_output_json.rb
frameworks-capybara-0.2.0.rc2 vendor/bundle/ruby/1.8/gems/gherkin-2.9.3/examples/parse_and_output_json.rb
resque-pool-0.3.0.beta.2 vendor/bundle/ruby/1.8/gems/gherkin-2.9.0/examples/parse_and_output_json.rb
gherkin-2.9.3 examples/parse_and_output_json.rb
gherkin-2.9.3-x86-mswin32 examples/parse_and_output_json.rb
gherkin-2.9.3-x86-mingw32 examples/parse_and_output_json.rb
gherkin-2.9.3-java examples/parse_and_output_json.rb
gherkin-2.9.2 examples/parse_and_output_json.rb
gherkin-2.9.2-x86-mswin32 examples/parse_and_output_json.rb
gherkin-2.9.2-x86-mingw32 examples/parse_and_output_json.rb
gherkin-2.9.2-java examples/parse_and_output_json.rb
gherkin-2.9.1 examples/parse_and_output_json.rb
gherkin-2.9.1-x86-mswin32 examples/parse_and_output_json.rb
gherkin-2.9.1-x86-mingw32 examples/parse_and_output_json.rb
gherkin-2.9.1-java examples/parse_and_output_json.rb