test/tool.rb in avro-1.10.2 vs test/tool.rb in avro-1.11.0

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the @@ -19,11 +20,11 @@ require 'uri' require 'logger' class GenericResponder < Avro::IPC::Responder def initialize(proto, msg, datum) - proto_json = open(proto).read + proto_json = File.open(proto).read super(Avro::Protocol.parse(proto_json)) @msg = msg @datum = datum end @@ -60,18 +61,18 @@ end def send_message(uri, proto, msg, datum) uri = URI.parse(uri) trans = Avro::IPC::HTTPTransceiver.new(uri.host, uri.port) - proto_json = open(proto).read + proto_json = File.open(proto).read requestor = Avro::IPC::Requestor.new(Avro::Protocol.parse(proto_json), trans) p requestor.request(msg, datum) end def file_or_stdin(f) - f == "-" ? STDIN : open(f) + f == "-" ? STDIN : File.open(f) end def main if ARGV.size == 0 puts "Usage: #{$0} [dump|rpcreceive|rpcsend]" @@ -98,13 +99,13 @@ uri, proto, msg = ARGV[1,3] datum = nil if ARGV.size > 4 case ARGV[4] when "-file" - Avro::DataFile.open(ARGV[5]) {|f| - f.each{|e| datum = e; break } - } + Avro::DataFile.open(ARGV[5]) do |f| + datum = f.first + end when "-data" puts "JSON Decoder not yet implemented." return 1 else puts usage_str @@ -122,10 +123,10 @@ uri, proto, msg = ARGV[1,3] datum = nil if ARGV.size > 4 case ARGV[4] when "-file" - Avro::DataFile.open(ARGV[5]){|f| f.each{|e| datum = e; break } } + Avro::DataFile.open(ARGV[5]){ |f| datum = f.first } when "-data" puts "JSON Decoder not yet implemented" return 1 else puts usage_str