[Groonga-commit] droonga/droonga-client-ruby at def869d [master] Define default protocol as a constant

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu May 7 12:52:46 JST 2015


YUKI Hiroshi	2015-05-07 12:52:46 +0900 (Thu, 07 May 2015)

  New Revision: def869df4a5023ef231bf53f8cf008f11d28a74b
  https://github.com/droonga/droonga-client-ruby/commit/def869df4a5023ef231bf53f8cf008f11d28a74b

  Message:
    Define default protocol as a constant

  Modified files:
    bin/droonga-request
    bin/droonga-send
    lib/droonga/client.rb

  Modified: bin/droonga-request (+1 -1)
===================================================================
--- bin/droonga-request    2015-05-07 12:42:23 +0900 (09f4d20)
+++ bin/droonga-request    2015-05-07 12:52:46 +0900 (54f3356)
@@ -26,7 +26,7 @@ options = {
   :port                => Droonga::Client::DEFAULT_PORT,
   :tag                 => Droonga::Client::DEFAULT_TAG,
   :default_dataset     => Droonga::Client::DEFAULT_DATASET,
-  :protocol            => :droonga,
+  :protocol            => Droonga::Client::DEFAULT_PROTOCOL,
   :default_target_role => Droonga::Client::DEFAULT_TARGET_ROLE,
   :timeout             => 1,
   :exit_on_response    => true,

  Modified: bin/droonga-send (+1 -1)
===================================================================
--- bin/droonga-send    2015-05-07 12:42:23 +0900 (23d4182)
+++ bin/droonga-send    2015-05-07 12:52:46 +0900 (696774f)
@@ -25,7 +25,7 @@ require "droonga/client"
 options = OpenStruct.new
 options.report_request = false
 options.report_throughput = false
-options.default_protocol = "droonga"
+options.default_protocol = Droonga::Client::DEFAULT_PROTOCOL
 options.default_host     = Droonga::Client::DEFAULT_HOST
 options.default_port     = Droonga::Client::DEFAULT_PORT
 options.default_tag      = Droonga::Client::DEFAULT_TAG

  Modified: lib/droonga/client.rb (+4 -1)
===================================================================
--- lib/droonga/client.rb    2015-05-07 12:42:23 +0900 (17913a7)
+++ lib/droonga/client.rb    2015-05-07 12:52:46 +0900 (ec205a7)
@@ -25,6 +25,7 @@ require "droonga/client/message_validator"
 
 module Droonga
   class Client
+    DEFAULT_PROTOCOL = :droonga
     DEFAULT_HOST = Socket.gethostname
     DEFAULT_HOST.force_encoding("US-ASCII") if DEFAULT_HOST.ascii_only?
     DEFAULT_PORT = 10031
@@ -34,6 +35,7 @@ module Droonga
     DEFAULT_TIMEOUT_SECONDS = 3
 
     attr_writer :on_error
+    attr_reader :protocol
 
     class ConnectionError < StandardError
       def initialize(error)
@@ -83,6 +85,7 @@ module Droonga
     # @option options [Boolean] :validation (true)
     #   Do or do not validate input messages.
     def initialize(options={})
+      @protocol = options[:protocol] || DEFAULT_PROTOCOL
       @connection = create_connection(options)
       @connection.on_error = lambda do |error|
         on_error(ConnectionError.new(error))
@@ -129,7 +132,7 @@ module Droonga
 
     private
     def create_connection(options)
-      case options[:protocol] || :droonga
+      case @protocol
       when :http
         Connection::HTTP.new(options)
       when :droonga
-------------- next part --------------
HTML����������������������������...
Download 



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