[Groonga-commit] droonga/droonga-engine at 97becd7 [master] Use one line per one option

Back to archive index

Kouhei Sutou kou****@clear*****
Tue Aug 26 09:45:44 JST 2014


> +        Droonga::Client.open(:host          => source_host,
> +                             :port          => source_node_port,
> +                             :tag           => tag,
> +                             :protocol      => :droonga,
> +                             :timeout       => 1,
> +                             :receiver_host => joining_host,


これ、もう一歩推し進めて、オプション群に名前をつけるのはどう
でしょうか?

open_options = {
  :host          => source_host,
  :port          => source_node_port,
  :tag           => tag,
  :protocol      => :droonga,
  :timeout       => 1,
  :receiver_host => joining_host,
  :receiver_port => 0
}
Droonga::Client.open(open_options) do |client|
  ...
end

こうすると、Droonga::Client.openからdoまでの間が短くなって、
openにはブロックも指定してい(て、そのブロックにはこんな値が
渡)るんだな、というのがわかりやすくなると思いました。

In <97becd72a76830c464fcc8f31522a6ca5b233758 �� jenkins.clear-code.com>
  "[Groonga-commit] droonga/droonga-engine �� 97becd7 [master] Use one line per one option" on Mon, 25 Aug 2014 20:21:01 +0900,
  YUKI "Piro" Hiroshi <null+groonga �� clear-code.com> wrote:

> YUKI "Piro" Hiroshi	2014-08-25 20:21:01 +0900 (Mon, 25 Aug 2014)
> 
>   New Revision: 97becd72a76830c464fcc8f31522a6ca5b233758
>   https://github.com/droonga/droonga-engine/commit/97becd72a76830c464fcc8f31522a6ca5b233758
> 
>   Message:
>     Use one line per one option
> 
>   Modified files:
>     lib/droonga/command/serf_event_handler.rb
> 
>   Modified: lib/droonga/command/serf_event_handler.rb (+7 -4)
> ===================================================================
> --- lib/droonga/command/serf_event_handler.rb    2014-08-25 20:19:37 +0900 (7823a47)
> +++ lib/droonga/command/serf_event_handler.rb    2014-08-25 20:21:01 +0900 (ae49814)
> @@ -145,12 +145,15 @@ module Droonga
>          joining_host = joining_node.split(":").first
>  
>          catalog = nil
> -        Droonga::Client.open(:host => source_host, :port => source_node_port,
> -                             :tag => tag, :protocol => :droonga, :timeout => 1, 
> -                             :receiver_host => joining_host, 
> +        Droonga::Client.open(:host          => source_host,
> +                             :port          => source_node_port,
> +                             :tag           => tag,
> +                             :protocol      => :droonga,
> +                             :timeout       => 1,
> +                             :receiver_host => joining_host,
>                               :receiver_port => 0) do |client|
>            request = client.request(:dataset => source_node_dataset , 
> -                                   :type => "catalog.fetch") do |responce|
> +                                   :type    => "catalog.fetch") do |responce|
>              File.write(Path.catalog, JSON.generate(responce["body"]))
>              catalog = responce["body"]
>            end




More information about the Groonga-commit mailing list
Back to archive index