Kouhei Sutou
null+****@clear*****
Sun Jan 17 18:38:07 JST 2016
Kouhei Sutou 2016-01-17 18:38:07 +0900 (Sun, 17 Jan 2016) New Revision: 26584ae953044af6f71b65e46ef59f2a3561142a https://github.com/ranguba/rroonga/commit/26584ae953044af6f71b65e46ef59f2a3561142a Message: Conf -> Config Modified files: ext/groonga/rb-grn.h ext/groonga/rb-groonga.c lib/groonga/context.rb Renamed files: ext/groonga/rb-grn-config.c (from ext/groonga/rb-grn-conf.c) test/test-config.rb (from test/test-conf.rb) Renamed: ext/groonga/rb-grn-config.c (+18 -13) 78% =================================================================== --- ext/groonga/rb-grn-conf.c 2016-01-15 21:20:47 +0900 (5958b9f) +++ ext/groonga/rb-grn-config.c 2016-01-17 18:38:07 +0900 (aa8e98e) @@ -1,6 +1,6 @@ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - Copyright (C) 2015 Kouhei Sutou <kou �� clear-code.com> + Copyright (C) 2015-2016 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 @@ -21,7 +21,7 @@ #define SELF(object) (RVAL2GRNCONTEXT(object)) /* - * Document-class: Groonga::Conf + * Document-class: Groonga::Config * * This class manages database global configurations. Each * configuration is key and value pair. @@ -37,7 +37,7 @@ * @since 5.0.9 */ static VALUE -rb_grn_conf_initialize (VALUE self, VALUE rb_context) +rb_grn_config_initialize (VALUE self, VALUE rb_context) { rb_iv_set(self, "@context", rb_context); @@ -47,14 +47,14 @@ rb_grn_conf_initialize (VALUE self, VALUE rb_context) /* * Gets a configuration value for key. * - * @overload conf[](key) + * @overload config[](key) * @param [String] key The key. * @return [String, nil] The value associated with `key`. * * @since 5.0.9 */ static VALUE -rb_grn_conf_get (VALUE self, VALUE rb_key) +rb_grn_config_get (VALUE self, VALUE rb_key) { VALUE rb_context; VALUE rb_value; @@ -73,6 +73,8 @@ rb_grn_conf_get (VALUE self, VALUE rb_key) { grn_rc rc; + /* TODO: Replace it with grn_config_get() after Groonga 5.1.2 + * is released.*/ rc = grn_conf_get(context, key, key_size, &value, &value_size); @@ -92,13 +94,13 @@ rb_grn_conf_get (VALUE self, VALUE rb_key) /* * Sets a configuration key and value pair. * - * @overload conf[]=(key, value) + * @overload config[]=(key, value) * @param [String] key The key. * @param [String] value The value to be assigned. * @return [String] `value`. */ static VALUE -rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value) +rb_grn_config_set (VALUE self, VALUE rb_key, VALUE rb_value) { VALUE rb_value_original = rb_value; VALUE rb_context; @@ -121,6 +123,8 @@ rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value) { grn_rc rc; + /* TODO: Replace it with grn_config_set() after Groonga 5.1.2 + * is released.*/ rc = grn_conf_set(context, key, key_size, value, value_size); @@ -132,14 +136,15 @@ rb_grn_conf_set (VALUE self, VALUE rb_key, VALUE rb_value) } void -rb_grn_init_conf (VALUE mGrn) +rb_grn_init_config (VALUE mGrn) { - VALUE cGrnConf; + VALUE cGrnConfig; - cGrnConf = rb_define_class_under(mGrn, "Conf", rb_cObject); + cGrnConfig = rb_define_class_under(mGrn, "Config", rb_cObject); + rb_define_const(mGrn, "Conf", cGrnConfig); - rb_define_method(cGrnConf, "initialize", rb_grn_conf_initialize, 1); + rb_define_method(cGrnConfig, "initialize", rb_grn_config_initialize, 1); - rb_define_method(cGrnConf, "[]", rb_grn_conf_get, 1); - rb_define_method(cGrnConf, "[]=", rb_grn_conf_set, 2); + rb_define_method(cGrnConfig, "[]", rb_grn_config_get, 1); + rb_define_method(cGrnConfig, "[]=", rb_grn_config_set, 2); } Modified: ext/groonga/rb-grn.h (+2 -2) =================================================================== --- ext/groonga/rb-grn.h 2016-01-15 21:20:47 +0900 (22c9bcc) +++ ext/groonga/rb-grn.h 2016-01-17 18:38:07 +0900 (7511e89) @@ -1,6 +1,6 @@ /* -*- coding: utf-8; mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - Copyright (C) 2009-2015 Kouhei Sutou <kou �� clear-code.com> + Copyright (C) 2009-2016 Kouhei Sutou <kou �� clear-code.com> Copyright (C) 2015-2016 Masafumi Yokoyama <yokoyama �� clear-code.com> This library is free software; you can redistribute it and/or @@ -354,7 +354,7 @@ void rb_grn_init_snippet (VALUE mGrn); void rb_grn_init_plugin (VALUE mGrn); void rb_grn_init_normalizer (VALUE mGrn); void rb_grn_init_thread (VALUE mGrn); -void rb_grn_init_conf (VALUE mGrn); +void rb_grn_init_config (VALUE mGrn); VALUE rb_grn_rc_to_exception (grn_rc rc); const char *rb_grn_rc_to_message (grn_rc rc); Modified: ext/groonga/rb-groonga.c (+1 -1) =================================================================== --- ext/groonga/rb-groonga.c 2016-01-15 21:20:47 +0900 (84bbf48) +++ ext/groonga/rb-groonga.c 2016-01-17 18:38:07 +0900 (9afe8d0) @@ -218,5 +218,5 @@ Init_groonga (void) rb_grn_init_plugin(mGrn); rb_grn_init_normalizer(mGrn); rb_grn_init_thread(mGrn); - rb_grn_init_conf(mGrn); + rb_grn_init_config(mGrn); } Modified: lib/groonga/context.rb (+12 -3) =================================================================== --- lib/groonga/context.rb 2016-01-15 21:20:47 +0900 (fea51bb) +++ lib/groonga/context.rb 2016-01-17 18:38:07 +0900 (c560e22) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2010-2015 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2010-2016 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 @@ -347,12 +347,21 @@ module Groonga memory_pool.register(object) end - # @return [Groonga::Conf] The database level configuration sets of + # @return [Groonga::Config] The database level configuration sets of # this context. # # @since 5.0.9 + # @deprecated since 5.1.1. Use {Groonga::Context#config} instead. def conf - @conf ||= Conf.new(self) + config + end + + # @return [Groonga::Config] The database level configuration sets of + # this context. + # + # @since 5.1.1 + def config + @config ||= Config.new(self) end end end Renamed: test/test-config.rb (+5 -5) 76% =================================================================== --- test/test-conf.rb 2016-01-15 21:20:47 +0900 (c099b22) +++ test/test-config.rb 2016-01-17 18:38:07 +0900 (422df4e) @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2015-2016 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 @@ -13,19 +13,19 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -class ConfTest < Test::Unit::TestCase +class ConfigTest < Test::Unit::TestCase include GroongaTestUtils setup :setup_database sub_test_case "#[]" do test "existent" do - context.conf["rroonga.key"] = "value" - assert_equal("value", context.conf["rroonga.key"]) + context.config["rroonga.key"] = "value" + assert_equal("value", context.config["rroonga.key"]) end test "nonexistent" do - assert_nil(context.conf["nonexistent"]) + assert_nil(context.config["nonexistent"]) end end end -------------- next part -------------- HTML����������������������������... Descargar