YUKI Hiroshi
null+****@clear*****
Thu Feb 20 18:45:20 JST 2014
YUKI Hiroshi 2014-02-20 18:45:20 +0900 (Thu, 20 Feb 2014) New Revision: ba5825d4947945e90807828748601aa284ee9da6 https://github.com/droonga/droonga.org/commit/ba5825d4947945e90807828748601aa284ee9da6 Message: Fix leading text for the reference Modified files: _po/ja/reference/plugin/adapter/index.po _po/ja/tutorial/basic/index.po ja/reference/plugin/adapter/index.md ja/tutorial/basic/index.md reference/plugin/adapter/index.md Modified: _po/ja/reference/plugin/adapter/index.po (+247 -57) =================================================================== --- _po/ja/reference/plugin/adapter/index.po 2014-02-20 18:45:06 +0900 (f339b1c) +++ _po/ja/reference/plugin/adapter/index.po 2014-02-20 18:45:20 +0900 (37b4b3d) @@ -51,31 +51,27 @@ msgid "" msgstr "" msgid "" -"module Droonga\n" -" module Plugins\n" -" module FooPlugin\n" -" Plugin.registry.register(\"foo\", self)" +"module Droonga::Plugins::FooPlugin\n" +" Plugin.registry.register(\"foo\", self)" msgstr "" msgid "" -" class Adapter < Droonga::Adapter\n" -" # operations to configure this adapter\n" -" message.XXXXXX = XXXXXX" +" class Adapter < Droonga::Adapter\n" +" # operations to configure this adapter\n" +" XXXXXX = XXXXXX" msgstr "" msgid "" -" def adapt_input(input_message)\n" -" # operations to modify incoming messages\n" -" input_message.XXXXXX = XXXXXX\n" -" end" +" def adapt_input(input_message)\n" +" # operations to modify incoming messages\n" +" input_message.XXXXXX = XXXXXX\n" +" end" msgstr "" msgid "" -" def adapt_output(output_message)\n" -" # operations to modify outgoing messages\n" -" output_message.XXXXXX = XXXXXX\n" -" end\n" -" end\n" +" def adapt_output(output_message)\n" +" # operations to modify outgoing messages\n" +" output_message.XXXXXX = XXXXXX\n" " end\n" " end\n" "end\n" @@ -86,10 +82,10 @@ msgid "Steps to define an adapter:" msgstr "" msgid "" -" 1. Define a module for your plugin (ex. `Droonga::Plugin::FooPlugin`) and reg" -"ister it as a plugin. (required)\n" -" 2. Define an adapter class (ex. `Droonga::Plugin::FooPlugin::Adapter`) inheri" -"ting [`Droonga::Adapter`](#classes-Droonga-Adapter). (required)\n" +" 1. Define a module for your plugin (ex. `Droonga::Plugins::FooPlugin`) and re" +"gister it as a plugin. (required)\n" +" 2. Define an adapter class (ex. `Droonga::Plugins::FooPlugin::Adapter`) inher" +"iting [`Droonga::Adapter`](#classes-Droonga-Adapter). (required)\n" " 3. [Configure conditions to apply the adapter](#howto-configure). (required)\n" " 4. Define adaption logic for incoming messages as [`#adapt_input`](#classes-D" "roonga-Adapter-adapt_input). (optional)\n" @@ -98,8 +94,8 @@ msgid "" msgstr "" msgid "" -"For more details, see also the [plugin development tutorial](../../../tutorial" -"/plugin-development/adapter/)." +"See also the [plugin development tutorial](../../../tutorial/plugin-developmen" +"t/adapter/)." msgstr "" msgid "### How an adapter works? {#how-works}" @@ -110,15 +106,16 @@ msgstr "" msgid "" " 1. The Droonga Engine starts.\n" -" * A global instance of the adapter class (ex. `Droonga::Plugin::FooPlugin:" -":Adapter`) is created and it is registered.\n" +" * A global instance of the adapter class (ex. `Droonga::Plugins::FooPlugin" +"::Adapter`) is created and it is registered.\n" " * The input pattern and the output pattern are registered.\n" " * The Droonga Engine starts to wait for incoming messages.\n" " 2. An incoming message is transferred from the Protocol Adapter to the Droong" "a Engine.\n" " Then, the adaption phase (for an incoming message) starts.\n" " * The adapter's [`#adapt_input`](#classes-Droonga-Adapter-adapt_input) is " -"called, if the message matches to the [input matching pattern](#config).\n" +"called, if the message matches to the [input matching pattern](#config) of the" +" adapter.\n" " * The method can modify the given incoming message, via [its methods](#cla" "sses-Droonga-InputMessage).\n" " 3. After all adapters are applied, the adaption phase for an incoming message" @@ -126,8 +123,10 @@ msgid "" " 4. An outgoing message returns from the previous \"collection\" phase.\n" " Then, the adaption phase (for an outgoing message) starts.\n" " * The adapter's [`#adapt_output`](#classes-Droonga-Adapter-adapt_output) i" -"s called, if the corresponding incoming message was processed by the adapter a" -"nd the outgoing message matches to the [output matching pattern](#config).\n" +"s called, if the message meets following both requirements:\n" +" - It is originated from an incoming message which was processed by the a" +"dapter itself.\n" +" - It matches to the [output matching pattern](#config) of the adapter.\n" " * The method can modify the given outgoing message, via [its methods](#cla" "sses-Droonga-OutputMessage).\n" " 5. After all adapters are applied, the adaption phase for an outgoing message" @@ -138,31 +137,35 @@ msgid "" "As described above, the Droonga Engine creates only one global instance of the" " adapter class for each plugin.\n" "You should not keep stateful information for a pair of incoming and outgoing m" -"essages as an instance variable of the adapter.\n" +"essages as instance variables of the adapter itself.\n" "Instead, you should give stateful information as a part of the incoming messag" "e body, and receive it from the body of the corresponding outgoing message." msgstr "" msgid "" "Any error raised from the adapter is handled by the Droonga Engine itself. See" -" also [error handling]." +" also [error handling][]." msgstr "" msgid "## Configurations {#config}" msgstr "" msgid "" -"`input_message.pattern`\n" -": A [matching pattern] for incoming messages.\n" -" Only messages matched to the given patten are processed by [`#adapt_input`](" -"#classes-Droonga-Adapter-adapt_input)." +"`input_message.pattern` (optional, default=`nil`)\n" +": A [matching pattern][] for incoming messages.\n" +" If no pattern (`nil`) is given, any message is regarded as \"matched\"." msgstr "" msgid "" -"`output_message.pattern`\n" -": A [matching pattern] for outgoing messages.\n" -" Only messages matched to the given patten are processed by [`#adapt_output`]" -"(#classes-Droonga-Adapter-adapt_output)." +"`output_message.pattern` (optional, default=`nil`)\n" +": A [matching pattern][] for outgoing messages.\n" +" If no pattern (`nil`) is given, any message is regarded as \"matched\"." +msgstr "" + +msgid "" +"Note: On Droonga 0.9.9, they are named as `message.input_pattern` and `message" +".output_pattern` but changed to new configurations on Droonga 1.0.0, like abov" +"e. If you write plugins for Droonga 0.9.9, you have to migrate it." msgstr "" msgid "## Classes and methods {#classes}" @@ -173,25 +176,27 @@ msgstr "" msgid "" "This is the common base class of any adapter. Your plugin's adapter class must" -" inherit the class." +" inherit this." msgstr "" msgid "#### `#adapt_input(input_message)` {#classes-Droonga-Adapter-adapt_input}" msgstr "" msgid "" -"Receives an instance of [`Droonga::InputMessage`](#classes-Droonga-InputMessag" -"e) corresponding to an incoming message." +"This method receives a [`Droonga::InputMessage`](#classes-Droonga-InputMessage" +") wrapped incoming message.\n" +"You can modify the incoming message via its methods." msgstr "" msgid "" -"By defualt this method does nothing, so you have to override it like following" -":" +"In this base class, this method is defined as just a placeholder and it does n" +"othing.\n" +"To modify incoming messages, you have to override it by yours, like following:" msgstr "" msgid "" "~~~ruby\n" -"module FooPlugin\n" +"module Droonga::Plugins::QueryFixer\n" " class Adapter < Droonga::Adapter\n" " def adapt_input(input_message)\n" " input_message.body[\"query\"] = \"fixed query\"\n" @@ -205,49 +210,137 @@ msgid "#### `#adapt_output(output_message)` {#classes-Droonga-Adapter-adapt_outp msgstr "" msgid "" -"Receives an instance of [`Droonga::OutputMessage`](#classes-Droonga-InputMessa" -"ge) corresponding to an outgoing message." +"This method receives a [`Droonga::OutputMessage`](#classes-Droonga-OutputMessa" +"ge) wrapped outgoing message.\n" +"You can modify the outgoing message via its methods." +msgstr "" + +msgid "" +"In this base class, this method is defined as just a placeholder and it does n" +"othing.\n" +"To modify outgoing messages, you have to override it by yours, like following:" msgstr "" msgid "" "~~~ruby\n" -"module FooPlugin\n" +"module Droonga::Plugins::ErrorConcealer\n" " class Adapter < Droonga::Adapter\n" " def adapt_output(output_message)\n" -" output_message.status_code = StatusCode::OK\n" +" output_message.status_code = Droonga::StatusCode::OK\n" " end\n" " end\n" "end\n" "~~~" msgstr "" -msgid "" -"### `Droonga::Plugin::Metadata::AdapterMessage` {#classes-Droonga-Plugin-Metad" -"ata-AdapterMessage}" +msgid "### `Droonga::InputMessage` {#classes-Droonga-InputMessage}" +msgstr "" + +msgid "#### `#command`, `#command=(command)` {#classes-Droonga-InputMessage-command}" msgstr "" -msgid "(under construction)" +msgid "This returns the `\"type\"` of the incoming message." +msgstr "" + +msgid "You can override it by assigning a new string value, like:" msgstr "" msgid "" -"#### `#input_pattern`, `#input_pattern=(pattern)` {#classes-Droonga-Plugin-Met" -"adata-AdapterMessage-input_pattern}" +"~~~ruby\n" +"module Droonga::Plugins::MySearch\n" +" class Adapter < Droonga::Adapter\n" +" input_message.pattern = [\"type\", :equal, \"my-search\"]" msgstr "" msgid "" -"#### `#output_pattern`, `#output_pattern=(pattern)` {#classes-Droonga-Plugin-M" -"etadata-AdapterMessage-output_pattern}" +" def adapt_input(input_message)\n" +" p input_message.command\n" +" # => \"my-search\"\n" +" # This message will be handled by a plugin\n" +" # for the custom \"my-search\" command." msgstr "" -msgid "### `Droonga::InputMessage` {#classes-Droonga-InputMessage}" +msgid " input_message.command = \"search\"" msgstr "" -msgid "#### `#command`, `#command=(command)` {#classes-Droonga-InputMessage-command}" +msgid "" +" p input_message.command\n" +" # => \"search\"\n" +" # The messge type (command) is changed.\n" +" # This message will be handled by the \"search\" plugin,\n" +" # as a regular search request.\n" +" end\n" +" end\n" +"end\n" +"~~~" msgstr "" msgid "#### `#body`, `#body=(body)` {#classes-Droonga-InputMessage-body}" msgstr "" +msgid "This returns the `\"body\"` of the incoming message." +msgstr "" + +msgid "You can override it by assigning a new value, partially or fully. For example:" +msgstr "" + +msgid "" +"~~~ruby\n" +"module Droonga::Plugins::MinimumLimit\n" +" class Adapter < Droonga::Adapter\n" +" input_message.pattern = [\"type\", :equal, \"search\"]" +msgstr "" + +msgid " MAXIMUM_LIMIT = 10" +msgstr "" + +msgid "" +" def adapt_input(input_message)\n" +" input_message.body[\"queries\"].each do |name, query|\n" +" query[\"output\"] ||= {}\n" +" query[\"output\"][\"limit\"] ||= MAXIMUM_LIMIT\n" +" query[\"output\"][\"limit\"] = [query[\"output\"][\"limit\"], MAXIMUM_LIMIT].m" +"in\n" +" end\n" +" # Now, all queries have \"output.limit=10\".\n" +" end\n" +" end\n" +"end\n" +"~~~" +msgstr "" + +msgid "Another case:" +msgstr "" + +msgid "" +" def adapt_input(input_message)\n" +" # Extract the query string from the custom command.\n" +" query_string = input_message[\"body\"][\"query\"]" +msgstr "" + +msgid "" +" # Construct internal search request for the \"search\" command.\n" +" input_message.command = \"search\"\n" +" input_message.body = {\n" +" \"queries\" => {\n" +" \"source\" => \"Store\",\n" +" \"condition\" => {\n" +" \"query\" => query_string,\n" +" \"matchTo\" => [\"name\"],\n" +" },\n" +" \"output\" => {\n" +" \"elements\" => [\"records\"],\n" +" \"limit\" => 10,\n" +" },\n" +" },\n" +" }\n" +" # Now, both \"type\" and \"body\" are completely replaced.\n" +" end\n" +" end\n" +"end\n" +"~~~" +msgstr "" + msgid "### `Droonga::OutputMessage` {#classes-Droonga-OutputMessage}" msgstr "" @@ -256,12 +349,109 @@ msgid "" "age-status_code}" msgstr "" +msgid "This returns the `\"statusCode\"` of the outgoing message." +msgstr "" + +msgid "You can override it by assigning a new status code. For example:" +msgstr "" + +msgid "" +"~~~ruby\n" +"module Droonga::Plugins::ErrorConcealer\n" +" class Adapter < Droonga::Adapter\n" +" input_message.pattern = [\"type\", :equal, \"search\"]" +msgstr "" + +msgid "" +" def adapt_output(output_message)\n" +" unless output_message.status_code == StatusCode::InternalServerError\n" +" output_message.status_code = Droonga::StatusCode::OK\n" +" output_message.body = {}\n" +" output_message.errors = nil\n" +" # Now any internal server error is ignored and clients\n" +" # receive regular responses.\n" +" end\n" +" end\n" +" end\n" +"end\n" +"~~~" +msgstr "" + msgid "#### `#errors`, `#errors=(errors)` {#classes-Droonga-OutputMessage-errors}" msgstr "" +msgid "This returns the `\"errors\"` of the outgoing message." +msgstr "" + +msgid "" +"You can override it by assigning new error information, partially or fully. Fo" +"r example:" +msgstr "" + +msgid "" +"~~~ruby\n" +"module Droonga::Plugins::ErrorExporter\n" +" class Adapter < Droonga::Adapter\n" +" input_message.pattern = [\"type\", :equal, \"search\"]" +msgstr "" + +msgid "" +" def adapt_output(output_message)\n" +" output_message.errors.delete(secret_database)\n" +" # Delete error information from secret database" +msgstr "" + +msgid "" +" output_message.body[\"errors\"] = {\n" +" \"records\" => output_message.errors.collect do |database, error|\n" +" {\n" +" \"database\" => database,\n" +" \"error\" => error\n" +" }\n" +" end,\n" +" }\n" +" # Convert error informations to a fake search result named \"errors\".\n" +" end\n" +" end\n" +"end\n" +"~~~" +msgstr "" + msgid "#### `#body`, `#body=(body)` {#classes-Droonga-OutputMessage-body}" msgstr "" +msgid "This returns the `\"body\"` of the outgoing message." +msgstr "" + +msgid "" +"~~~ruby\n" +"module Droonga::Plugins::SponsoredSearch\n" +" class Adapter < Droonga::Adapter\n" +" input_message.pattern = [\"type\", :equal, \"search\"]" +msgstr "" + +msgid "" +" def adapt_output(output_message)\n" +" output_message.body.each do |name, result|\n" +" next unless result[\"records\"]\n" +" result[\"records\"].unshift(sponsored_entry)\n" +" end\n" +" # Now all search results include sponsored entry.\n" +" end" +msgstr "" + +msgid "" +" def sponsored_entry\n" +" {\n" +" \"title\"=> \"SALE!\",\n" +" \"url\"=> \"http://...\"\n" +" }\n" +" end\n" +" end\n" +"end\n" +"~~~" +msgstr "" + msgid "" " [matching pattern]: ../matching-pattern/\n" " [error handling]: ../error/" Modified: _po/ja/tutorial/basic/index.po (+3 -2) =================================================================== --- _po/ja/tutorial/basic/index.po 2014-02-20 18:45:06 +0900 (eaac8e8) +++ _po/ja/tutorial/basic/index.po 2014-02-20 18:45:20 +0900 (e4b1e25) @@ -3,8 +3,8 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-11-20 22:17+0900\n" -"PO-Revision-Date: 2014-02-10 13:08+0900\n" -"Last-Translator: Droonga Project <droonga �� groonga.org>\n" +"PO-Revision-Date: 2013-12-25 18:27+0900\n" +"Last-Translator: Kouhei Sutou <kou �� clear-code.com>\n" "Language-Team: Japanese\n" "Language: ja\n" "MIME-Version: 1.0\n" @@ -251,6 +251,7 @@ msgstr "" msgid "" " {\n" +" \"version\": 1,\n" " \"effective_date\": \"2013-09-01T00:00:00Z\",\n" " \"zones\": [\"localhost:24224/starbucks\"],\n" " \"farms\": {\n" Modified: ja/reference/plugin/adapter/index.md (+2 -2) =================================================================== --- ja/reference/plugin/adapter/index.md 2014-02-20 18:45:06 +0900 (9df2da3) +++ ja/reference/plugin/adapter/index.md 2014-02-20 18:45:20 +0900 (9883ed0) @@ -56,7 +56,7 @@ Steps to define an adapter: 4. Define adaption logic for incoming messages as [`#adapt_input`](#classes-Droonga-Adapter-adapt_input). (optional) 5. Define adaption logic for outgoing messages as [`#adapt_output`](#classes-Droonga-Adapter-adapt_output). (optional) -For more details, see also the [plugin development tutorial](../../../tutorial/plugin-development/adapter/). +See also the [plugin development tutorial](../../../tutorial/plugin-development/adapter/). ### How an adapter works? {#how-works} @@ -81,7 +81,7 @@ An adapter works like following: 5. After all adapters are applied, the adaption phase for an outgoing message ends, and the outgoing message is transferred to the Protocol Adapter. As described above, the Droonga Engine creates only one global instance of the adapter class for each plugin. -You should not keep stateful information for a pair of incoming and outgoing messages as an instance variable of the adapter. +You should not keep stateful information for a pair of incoming and outgoing messages as instance variables of the adapter itself. Instead, you should give stateful information as a part of the incoming message body, and receive it from the body of the corresponding outgoing message. Any error raised from the adapter is handled by the Droonga Engine itself. See also [error handling][]. Modified: ja/tutorial/basic/index.md (+1 -0) =================================================================== --- ja/tutorial/basic/index.md 2014-02-20 18:45:06 +0900 (ba92930) +++ ja/tutorial/basic/index.md 2014-02-20 18:45:20 +0900 (feadbde) @@ -120,6 +120,7 @@ fluentd.conf: catalog.json: { + "version": 1, "effective_date": "2013-09-01T00:00:00Z", "zones": ["localhost:24224/starbucks"], "farms": { Modified: reference/plugin/adapter/index.md (+2 -2) =================================================================== --- reference/plugin/adapter/index.md 2014-02-20 18:45:06 +0900 (9e7a4ae) +++ reference/plugin/adapter/index.md 2014-02-20 18:45:20 +0900 (6114580) @@ -47,7 +47,7 @@ Steps to define an adapter: 4. Define adaption logic for incoming messages as [`#adapt_input`](#classes-Droonga-Adapter-adapt_input). (optional) 5. Define adaption logic for outgoing messages as [`#adapt_output`](#classes-Droonga-Adapter-adapt_output). (optional) -For more details, see also the [plugin development tutorial](../../../tutorial/plugin-development/adapter/). +See also the [plugin development tutorial](../../../tutorial/plugin-development/adapter/). ### How an adapter works? {#how-works} @@ -72,7 +72,7 @@ An adapter works like following: 5. After all adapters are applied, the adaption phase for an outgoing message ends, and the outgoing message is transferred to the Protocol Adapter. As described above, the Droonga Engine creates only one global instance of the adapter class for each plugin. -You should not keep stateful information for a pair of incoming and outgoing messages as an instance variable of the adapter. +You should not keep stateful information for a pair of incoming and outgoing messages as instance variables of the adapter itself. Instead, you should give stateful information as a part of the incoming message body, and receive it from the body of the corresponding outgoing message. Any error raised from the adapter is handled by the Droonga Engine itself. See also [error handling][]. -------------- next part -------------- HTML����������������������������...Download