YUKI Hiroshi
null+****@clear*****
Fri Feb 28 13:57:01 JST 2014
YUKI Hiroshi 2014-02-28 13:57:01 +0900 (Fri, 28 Feb 2014) New Revision: bdd6aebe902a270a106fc6b9e6dd5c9b258ace06 https://github.com/droonga/droonga.org/commit/bdd6aebe902a270a106fc6b9e6dd5c9b258ace06 Message: Update definition style of plugins Modified files: reference/plugin/adapter/index.md tutorial/plugin-development/adapter/index.md tutorial/plugin-development/handler/index.md Modified: reference/plugin/adapter/index.md (+26 -1) =================================================================== --- reference/plugin/adapter/index.md 2014-02-28 13:42:25 +0900 (9bdfd8d) +++ reference/plugin/adapter/index.md 2014-02-28 13:57:01 +0900 (48be82b) @@ -20,7 +20,8 @@ For example, here is a sample plugin named "foo" with an adapter: require "droonga/plugin" module Droonga::Plugins::FooPlugin - Plugin.registry.register("foo", self) + extend Plugin + register("foo") class Adapter < Droonga::Adapter # operations to configure this adapter @@ -106,6 +107,9 @@ To modify incoming messages, you have to override it by yours, like following: ~~~ruby module Droonga::Plugins::QueryFixer + extend Plugin + register("query-fixer") + class Adapter < Droonga::Adapter def adapt_input(input_message) input_message.body["query"] = "fixed query" @@ -124,6 +128,9 @@ To modify outgoing messages, you have to override it by yours, like following: ~~~ruby module Droonga::Plugins::ErrorConcealer + extend Plugin + register("error-concealer") + class Adapter < Droonga::Adapter def adapt_output(output_message) output_message.status_code = Droonga::StatusCode::OK @@ -142,6 +149,9 @@ You can override it by assigning a new string value, like: ~~~ruby module Droonga::Plugins::MySearch + extend Plugin + register("my-search") + class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "my-search"] @@ -173,6 +183,9 @@ You can override it by assigning a new value, partially or fully. For example: ~~~ruby module Droonga::Plugins::MinimumLimit + extend Plugin + register("minimum-limit") + class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "search"] @@ -194,6 +207,9 @@ Another case: ~~~ruby module Droonga::Plugins::MySearch + extend Plugin + register("my-search") + class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "my-search"] @@ -232,6 +248,9 @@ You can override it by assigning a new status code. For example: ~~~ruby module Droonga::Plugins::ErrorConcealer + extend Plugin + register("error-concealer") + class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "search"] @@ -256,6 +275,9 @@ You can override it by assigning new error information, partially or fully. For ~~~ruby module Droonga::Plugins::ErrorExporter + extend Plugin + register("error-exporter") + class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "search"] @@ -285,6 +307,9 @@ You can override it by assigning a new value, partially or fully. For example: ~~~ruby module Droonga::Plugins::SponsoredSearch + extend Plugin + register("sponsored-search") + class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "search"] Modified: tutorial/plugin-development/adapter/index.md (+9 -6) =================================================================== --- tutorial/plugin-development/adapter/index.md 2014-02-28 13:42:25 +0900 (e6e7c98) +++ tutorial/plugin-development/adapter/index.md 2014-02-28 13:57:01 +0900 (90ab200) @@ -64,8 +64,7 @@ module Droonga module Plugins module SampleLoggerPlugin extend Plugin - - registry.register("sample-logger", self) + register("sample-logger") class Adapter < Droonga::Adapter # You'll put codes to modify messages here. @@ -191,7 +190,8 @@ lib/droonga/plugins/sample-logger.rb: ~~~ruby (snip) module SampleLoggerPlugin - Plugin.registry.register("sample-logger", self) + extend Plugin + register("sample-logger") class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "search"] @@ -338,7 +338,8 @@ lib/droonga/plugins/sample-logger.rb: ~~~ruby (snip) module SampleLoggerPlugin - Plugin.registry.register("sample-logger", self) + extend Plugin + register("sample-logger") class Adapter < Droonga::Adapter (snip) @@ -486,7 +487,8 @@ require "droonga/plugin" module Droonga module Plugins module StoreSearchPlugin - Plugin.registry.register("store-search", self) + extend Plugin + register("store-search") class Adapter < Droonga::Adapter input_message.pattern = ["type", :equal, "storeSearch"] @@ -620,7 +622,8 @@ lib/droonga/plugins/store-search.rb: ~~~ruby (snip) module StoreSearchPlugin - Plugin.registry.register("store-search", self) + extend Plugin + register("store-search") class Adapter < Droonga::Adapter (snip) Modified: tutorial/plugin-development/handler/index.md (+12 -6) =================================================================== --- tutorial/plugin-development/handler/index.md 2014-02-28 13:42:25 +0900 (66799c2) +++ tutorial/plugin-development/handler/index.md 2014-02-28 13:57:01 +0900 (9520eed) @@ -107,7 +107,8 @@ require "droonga/plugin" module Droonga module Plugins module CountRecordsPlugin - Plugin.registry.register("count-records", self) + extend Plugin + register("count-records") end end end @@ -125,7 +126,8 @@ require "droonga/plugin" module Droonga module Plugins module CountRecordsPlugin - Plugin.registry.register("count-records", self) + extend Plugin + register("count-records") define_single_step do |step| step.name = "countRecords" @@ -152,7 +154,8 @@ require "droonga/plugin" module Droonga module Plugins module CountRecordsPlugin - Plugin.registry.register("count-records", self) + extend Plugin + register("count-records") define_single_step do |step| step.name = "countRecords" @@ -383,7 +386,8 @@ require "droonga/plugin" module Droonga module Plugins module DeleteStoresPlugin - Plugin.registry.register("delete-stores", self) + extend Plugin + register("delete-stores") end end end @@ -402,7 +406,8 @@ require "droonga/plugin" module Droonga module Plugins module DeleteStoresPlugin - Plugin.registry.register("delete-stores", self) + extend Plugin + register("delete-stores") define_single_step do |step| step.name = "deleteStores" @@ -428,7 +433,8 @@ require "droonga/plugin" module Droonga module Plugins module DeleteStoresPlugin - Plugin.registry.register("delete-stores", self) + extend Plugin + register("delete-stores") define_single_step do |step| step.name = "deleteStores" -------------- next part -------------- HTML����������������������������...Download