Kouhei Sutou
null+****@clear*****
Thu Oct 26 10:54:56 JST 2017
Kouhei Sutou 2017-10-26 10:54:56 +0900 (Thu, 26 Oct 2017) New Revision: 2041ee5bad88c3f336ba1717d6a10e684f0ea707 https://github.com/ranguba/groonga-client/commit/2041ee5bad88c3f336ba1717d6a10e684f0ea707 Message: Reduce scope Modified files: lib/groonga/client/command-line/groonga-client.rb Modified: lib/groonga/client/command-line/groonga-client.rb (+24 -23) =================================================================== --- lib/groonga/client/command-line/groonga-client.rb 2017-10-25 17:59:24 +0900 (e5f4d8d) +++ lib/groonga/client/command-line/groonga-client.rb 2017-10-26 10:54:56 +0900 (a5b1a14) @@ -45,34 +45,35 @@ module Groonga def run(argv) command_file_paths = parse_command_line(argv) - @client = Client.new(:url => @url, - :protocol => @protocol, - :host => @host, - :port => @port, - :read_timeout => @read_timeout, - :chunk => @chunk, - :backend => :synchronous) - runner = Runner.new(@client, @runner_options) - - if command_file_paths.empty? - $stdin.each_line do |line| - runner << line - end - else - command_file_paths.each do |command_file_path| - File.open(command_file_path) do |command_file| - last_line = nil - command_file.each_line do |line| - last_line = line - runner << line + Client.open(:url => @url, + :protocol => @protocol, + :host => @host, + :port => @port, + :read_timeout => @read_timeout, + :chunk => @chunk, + :backend => :synchronous) do |client| + runner = Runner.new(client, @runner_options) + + if command_file_paths.empty? + $stdin.each_line do |line| + runner << line + end + else + command_file_paths.each do |command_file_path| + File.open(command_file_path) do |command_file| + last_line = nil + command_file.each_line do |line| + last_line = line + runner << line end - if last_line and !last_line.end_with?("\n") - runner << "\n" + if last_line and !last_line.end_with?("\n") + runner << "\n" + end end end end + runner.finish end - runner.finish true end -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171026/11574ee9/attachment-0001.htm