Kouhei Sutou
null+****@clear*****
Thu Jan 30 17:34:36 JST 2014
Kouhei Sutou 2014-01-30 17:34:36 +0900 (Thu, 30 Jan 2014) New Revision: c02e2963b87a84660cd1aeb3342574d0d178d740 https://github.com/droonga/fluent-plugin-droonga/commit/c02e2963b87a84660cd1aeb3342574d0d178d740 Message: catalog: add input_adapter.plugins to specify input plugin related information TODO: Document it. Modified files: lib/droonga/catalog/base.rb lib/droonga/catalog/version1.rb sample/cluster/catalog.json test/unit/catalog/test_version1.rb Modified: lib/droonga/catalog/base.rb (+6 -1) =================================================================== --- lib/droonga/catalog/base.rb 2014-01-30 17:24:46 +0900 (74c0326) +++ lib/droonga/catalog/base.rb 2014-01-30 17:34:36 +0900 (3d3205b) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Droonga Project +# Copyright (C) 2013-2014 Droonga Project # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -16,6 +16,7 @@ require "digest/sha1" require "zlib" require "droonga/message_processing_error" +require "droonga/input_adapter_options" module Droonga module Catalog @@ -134,6 +135,10 @@ module Droonga end end + def input_adapter_options + InputAdapterOptions.new(@data["input_adapter"]) + end + private def compute_total_weight(dataset) dataset["ring"].reduce(0) do |result, zone| Modified: lib/droonga/catalog/version1.rb (+11 -1) =================================================================== --- lib/droonga/catalog/version1.rb 2014-01-30 17:24:46 +0900 (a07e32e) +++ lib/droonga/catalog/version1.rb 2014-01-30 17:34:36 +0900 (76f5277) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Droonga Project +# Copyright (C) 2013-2014 Droonga Project # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,6 +18,16 @@ require "droonga/catalog/base" module Droonga module Catalog class Version1 < Base + def initialize(*args) + super + normalize_input_adapter + end + + private + def normalize_input_adapter + @data["input_adapter"] ||= {} + @data["input_adapter"]["plugins"] ||= @options["plugins"] + end end end end Modified: sample/cluster/catalog.json (+3 -0) =================================================================== --- sample/cluster/catalog.json 2014-01-30 17:24:46 +0900 (1f7fd96) +++ sample/cluster/catalog.json 2014-01-30 17:34:36 +0900 (6cc1954) @@ -40,5 +40,8 @@ }, "options": { "plugins": ["groonga"] + }, + "input_adapter": { + "plugins": ["groonga"] } } Modified: test/unit/catalog/test_version1.rb (+53 -0) =================================================================== --- test/unit/catalog/test_version1.rb 2014-01-30 17:24:46 +0900 (3a5820d) +++ test/unit/catalog/test_version1.rb 2014-01-30 17:34:36 +0900 (914de93) @@ -101,4 +101,57 @@ class CatalogTest < Test::Unit::TestCase end end end + + class InputAdapterOptionsTest < self + def setup + end + + def options(data) + minimum_data = { + "datasets" => [], + } + catalog = create_catalog(minimum_data.merge(data), "base-path") + catalog.input_adapter_options + end + + class PluginsTest < self + def plugins(data) + options(data).plugins + end + + def test_nothing + assert_equal([], plugins({})) + end + + def test_options + data = { + "options" => { + "plugins" => ["groonga"], + } + } + assert_equal(["groonga"], plugins(data)) + end + + def test_input_adapter + data = { + "input_adapter" => { + "plugins" => ["groonga"], + } + } + assert_equal(["groonga"], plugins(data)) + end + + def test_options_and_input_adapter + data = { + "options" => { + "plugins" => ["basic"], + }, + "input_adapter" => { + "plugins" => ["groonga"], + } + } + assert_equal(["groonga"], plugins(data)) + end + end + end end -------------- next part -------------- HTML����������������������������...Download