Kouhei Sutou
null+****@clear*****
Wed Oct 25 17:03:22 JST 2017
Kouhei Sutou 2017-10-25 17:03:22 +0900 (Wed, 25 Oct 2017) New Revision: 2d138377f426e853df4bd8b9abf6127baa3baddb https://github.com/ranguba/groonga-client/commit/2d138377f426e853df4bd8b9abf6127baa3baddb Message: index-recreate: add --url option Added files: test/command-line/test-index-recreate.rb Modified files: lib/groonga/client/command-line/groonga-client-index-recreate.rb Modified: lib/groonga/client/command-line/groonga-client-index-recreate.rb (+19 -10) =================================================================== --- lib/groonga/client/command-line/groonga-client-index-recreate.rb 2017-10-25 16:50:46 +0900 (d7319b0) +++ lib/groonga/client/command-line/groonga-client-index-recreate.rb 2017-10-25 17:03:22 +0900 (e29a3df) @@ -24,6 +24,7 @@ module Groonga module CommandLine class GroongaClientIndexRecreate def initialize + @url = nil @protocol = :http @host = "localhost" @port = nil @@ -36,16 +37,17 @@ module Groonga def run(argv) target_indexes = parse_command_line(argv) - @client = Client.new(:protocol => @protocol, - :host => @host, - :port => @port, - :read_timeout => @read_timeout, - :backend => :synchronous) - - runner = Runner.new(@client, target_indexes) - runner.run do - @n_workers.times do - @client.database_unmap + Client.open(:url => @url, + :protocol => @protocol, + :host => @host, + :port => @port, + :read_timeout => @read_timeout, + :backend => :synchronous) do |client| + runner = Runner.new(client, target_indexes) + runner.run do + @n_workers.times do + client.database_unmap + end end end end @@ -60,6 +62,13 @@ module Groonga parser.separator("Connection:") + parser.on("--url=URL", + "URL to connect to Groonga server.", + "If this option is specified,", + "--protocol, --host and --port are ignored.") do |url| + @url = url + end + available_protocols = [:http, :gqtp] parser.on("--protocol=PROTOCOL", [:http, :gqtp], "Protocol to connect to Groonga server.", Added: test/command-line/test-index-recreate.rb (+50 -0) 100644 =================================================================== --- /dev/null +++ test/command-line/test-index-recreate.rb 2017-10-25 17:03:22 +0900 (ac130f0) @@ -0,0 +1,50 @@ +# Copyright (C) 2017 Kouhei Sutou <kou �� clear-code.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +require "groonga/command/parser" + +require "groonga/client" +require "groonga/client/test-helper" +require "groonga/client/command-line/groonga-client-index-recreate" + +class TestCommandLineIndexRecreate < Test::Unit::TestCase + include Groonga::Client::TestHelper + + def groonga_url + @groonga_server_runner.url.to_s + end + + def dump + Groonga::Client.open(:url => groonga_url) do |client| + client.dump.body + end + end + + def index_recreate(*arguments) + command_line = Groonga::Client::CommandLine::GroongaClientIndexRecreate.new + command_line.run(["--url", groonga_url, *arguments]) + end + + def test_no_alias + index_recreate + assert_equal(<<-DUMP.chomp, dump) +config_set alias.column Aliases.real_name + +table_create Aliases TABLE_HASH_KEY ShortText +column_create Aliases real_name COLUMN_SCALAR ShortText + DUMP + end +end -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171025/ea35a4ec/attachment-0001.htm