Hajime Wakahara
null+****@clear*****
Wed Jan 13 17:22:13 JST 2016
Hajime Wakahara 2014-10-01 18:21:11 +0900 (Wed, 01 Oct 2014) New Revision: 9bf3d89f6c721c14838ec43ca97c2b4f73f3bb36 https://github.com/groonga/groonga-command/commit/9bf3d89f6c721c14838ec43ca97c2b4f73f3bb36 Merged c35ddda: Merge pull request #1 from hadzimme/handle_prefix_path Message: Add prefix path handling Modified files: lib/groonga/command/base.rb lib/groonga/command/format/uri.rb test/command/test-base.rb Modified: lib/groonga/command/base.rb (+3 -2) =================================================================== --- lib/groonga/command/base.rb 2014-09-30 19:23:42 +0900 (f48e183) +++ lib/groonga/command/base.rb 2014-10-01 18:21:11 +0900 (c5b4a97) @@ -40,12 +40,13 @@ module Groonga end attr_reader :name, :arguments - attr_accessor :original_format, :original_source + attr_accessor :original_format, :original_source, :prefix def initialize(name, pair_arguments, ordered_arguments=[]) @name = name @arguments = construct_arguments(pair_arguments, ordered_arguments) @original_format = nil @original_source = nil + @prefix = "d" end def [](name) @@ -80,7 +81,7 @@ module Groonga end def to_uri_format - Format::URI.new(@name, normalized_arguments).path + Format::URI.new(@prefix, @name, normalized_arguments).path end def to_command_format Modified: lib/groonga/command/format/uri.rb (+3 -2) =================================================================== --- lib/groonga/command/format/uri.rb 2014-09-30 19:23:42 +0900 (ca14a1d) +++ lib/groonga/command/format/uri.rb 2014-10-01 18:21:11 +0900 (6590c91) @@ -22,13 +22,14 @@ module Groonga module Command module Format class URI - def initialize(name, arguments) + def initialize(prefix, name, arguments) + @prefix = prefix @name = name @arguments = arguments end def path - path = "/d/#{@name}" + path = "/#{@prefix}/#{@name}" arguments =****@argum***** output_type = arguments.delete(:output_type) path << ".#{output_type}" if output_type Modified: test/command/test-base.rb (+9 -0) =================================================================== --- test/command/test-base.rb 2014-09-30 19:23:42 +0900 (9f0ae82) +++ test/command/test-base.rb 2014-10-01 18:21:11 +0900 (08e9fe6) @@ -57,6 +57,15 @@ class BaseCommandTest < Test::Unit::TestCase assert_equal("/d/select.json?table=Users", select.to_uri_format) end + + def test_prefix + select = Groonga::Command::Base.new("select", + :table => "Users", + :output_type => "json") + select.prefix = "db1" + assert_equal("/db1/select.json?table=Users", + select.to_uri_format) + end end class CovnertToCommandFormatTest < self -------------- next part -------------- HTML����������������������������...Download