Sha256: fbe96fffba0bcc31f1302c26c4ea4565690f16a75504675b40ecf2073a0aa650
Contents?: true
Size: 1.84 KB
Versions: 1
Compression:
Stored size: 1.84 KB
Contents
#!/usr/bin/env ruby $VERBOSE=nil # Shut up JRuby warnings on Travis $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"../lib")) require 'optparse' require 'json' require 'cucumber/messages' require 'gherkin' require 'gherkin/stream/subprocess_message_stream' options = { include_source: true, include_gherkin_document: true, include_pickles: true, json: false } OptionParser.new do |opts| opts.on("--[no-]source", "Don't print source messages") do |v| options[:include_source] = v end opts.on("--[no-]ast", "Don't print ast messages") do |v| options[:include_gherkin_document] = v end opts.on("--[no-]pickles", "Don't print pickle messages") do |v| options[:include_pickles] = v end opts.on("--json", "Print messages as JSON") do |v| options[:json] = v end end.parse! def process_messages(messages, options) messages.each do |message| if options[:json] json = message.class.encode_json(message) ob = JSON.parse(json) remove_empties(ob) puts JSON.generate(ob) else message.write_delimited_to(STDOUT) end end end def remove_empties(ob) if Hash === ob ob.each do |key, value| if value == [] ob.delete(key) else remove_empties(value) end end elsif Array === ob ob.each do |value| remove_empties(value) end end end gherkin_executable = ENV['GHERKIN_EXECUTABLE'] if ARGV.empty? # Read protobuf from STDIN messages = Cucumber::Messages::ProtobufIoEnumerator.call(STDIN) elsif gherkin_executable # Read protobuf from STDIN messages = Gherkin::Stream::SubprocessMessageStream.new( gherkin_executable, ARGV, options[:include_source], options[:include_gherkin_document], options[:include_pickles] ).messages else messages = Gherkin.from_paths( ARGV, options ) end process_messages(messages, options)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gherkin-8.1.1 | bin/gherkin |