Kouhei Sutou
null+****@clear*****
Fri Feb 7 17:30:16 JST 2014
Kouhei Sutou 2014-02-07 17:30:16 +0900 (Fri, 07 Feb 2014) New Revision: 588068ac5ea022908b918c7ceb3fee86b1cee882 https://github.com/droonga/fluent-plugin-droonga/commit/588068ac5ea022908b918c7ceb3fee86b1cee882 Message: Don't require plugin name for each adapter Before: require "droonga/adapter" module Droonga module Plugins module MyPlugin class Adapter < Droonga::Adapter plugin.name = "my-plugin" end end end end After: require "droonga/plugin" # <- Add require "droonga/adapter" module Droonga module Plugins module MyPlugin Plugin.registry.register("my-plugin", self) # <- Add class Adapter < Droonga::Adapter # no plugin.name = "my-plugin" end end end end Modified files: lib/droonga/adapter_runner.rb lib/droonga/pluggable.rb lib/droonga/plugins/crud.rb lib/droonga/plugins/error.rb lib/droonga/plugins/groonga.rb lib/droonga/plugins/groonga/generic.rb lib/droonga/plugins/groonga/select.rb Modified: lib/droonga/adapter_runner.rb (+2 -4) =================================================================== --- lib/droonga/adapter_runner.rb 2014-02-07 17:18:11 +0900 (d5f193e) +++ lib/droonga/adapter_runner.rb 2014-02-07 17:30:16 +0900 (4153335) @@ -95,10 +95,8 @@ module Droonga def collect_adapter_classes(plugins) adapter_classes = [] plugins.each do |plugin_name| - Adapter.sub_classes.each do |adapter_class| - next unless adapter_class.plugin.name == plugin_name - adapter_classes << adapter_class - end + sub_classes = Plugin.registry.find_sub_classes(plugin_name, Adapter) + adapter_classes.concat(sub_classes) end adapter_classes end Modified: lib/droonga/pluggable.rb (+0 -16) =================================================================== --- lib/droonga/pluggable.rb 2014-02-07 17:18:11 +0900 (974670d) +++ lib/droonga/pluggable.rb 2014-02-07 17:30:16 +0900 (d695923) @@ -17,22 +17,6 @@ require "droonga/plugin/metadata/plugin" module Droonga module Pluggable - class << self - def extended(pluggable_class) - super - pluggable_class.class_variable_set(:@@sub_classes, []) - end - end - - def sub_classes - class_variable_get(:@@sub_classes) - end - - def inherited(sub_class) - super - sub_classes << sub_class - end - def plugin Plugin::Metadata::Plugin.new(self) end Modified: lib/droonga/plugins/crud.rb (+3 -1) =================================================================== --- lib/droonga/plugins/crud.rb 2014-02-07 17:18:11 +0900 (19ec412) +++ lib/droonga/plugins/crud.rb 2014-02-07 17:30:16 +0900 (e0f143d) @@ -13,13 +13,15 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +require "droonga/plugin" require "droonga/adapter" module Droonga module Plugins module CRUD + Plugin.registry.register("crud", self) + class Adapter < Droonga::Adapter - plugin.name = "crud" message.input_pattern = ["type", :equal, "add"] message.output_pattern = ["body.success", :exist?] Modified: lib/droonga/plugins/error.rb (+3 -1) =================================================================== --- lib/droonga/plugins/error.rb 2014-02-07 17:18:11 +0900 (e9719f6) +++ lib/droonga/plugins/error.rb 2014-02-07 17:30:16 +0900 (110ac9a) @@ -13,13 +13,15 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +require "droonga/plugin" require "droonga/adapter" module Droonga module Plugins module Error + Plugin.registry.register("error", self) + class Adapter < Droonga::Adapter - plugin.name = "error" message.output_pattern = ["body.errors", :exist?] def adapt_output(output_message) Modified: lib/droonga/plugins/groonga.rb (+9 -0) =================================================================== --- lib/droonga/plugins/groonga.rb 2014-02-07 17:18:11 +0900 (2a9f470) +++ lib/droonga/plugins/groonga.rb 2014-02-07 17:30:16 +0900 (4429c4b) @@ -13,5 +13,14 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +require "droonga/plugin" require "droonga/plugins/groonga/generic" require "droonga/plugins/groonga/select" + +module Droonga + module Plugins + module Groonga + Plugin.registry.register("groonga", self) + end + end +end Modified: lib/droonga/plugins/groonga/generic.rb (+0 -2) =================================================================== --- lib/droonga/plugins/groonga/generic.rb 2014-02-07 17:18:11 +0900 (eba9bd4) +++ lib/droonga/plugins/groonga/generic.rb 2014-02-07 17:30:16 +0900 (bbe7843) @@ -20,8 +20,6 @@ module Droonga module Groonga module Generic class Adapter < Droonga::Adapter - plugin.name = "groonga" - groonga_commands = [ "table_create", "table_remove", Modified: lib/droonga/plugins/groonga/select.rb (+0 -1) =================================================================== --- lib/droonga/plugins/groonga/select.rb 2014-02-07 17:18:11 +0900 (55543c0) +++ lib/droonga/plugins/groonga/select.rb 2014-02-07 17:30:16 +0900 (5d92898) @@ -101,7 +101,6 @@ module Droonga end class Adapter < Droonga::Adapter - plugin.name = "groonga" message.input_pattern = ["type", :equal, "select"] def adapt_input(input_message) -------------- next part -------------- HTML����������������������������...Download