[Groonga-commit] groonga/fluent-plugin-droonga at 0a3acd4 [master] Support static number or string values for returned records

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed May 29 13:35:28 JST 2013


YUKI Hiroshi	2013-05-29 13:35:28 +0900 (Wed, 29 May 2013)

  New Revision: 0a3acd4a8c9a2d8718ebfd8e59b98641264d71b6
  https://github.com/groonga/fluent-plugin-droonga/commit/0a3acd4a8c9a2d8718ebfd8e59b98641264d71b6

  Message:
    Support static number or string values for returned records

  Modified files:
    lib/droonga/plugin/handler_search.rb

  Modified: lib/droonga/plugin/handler_search.rb (+12 -1)
===================================================================
--- lib/droonga/plugin/handler_search.rb    2013-05-08 21:30:35 +0900 (b39f6d3)
+++ lib/droonga/plugin/handler_search.rb    2013-05-29 13:35:28 +0900 (53757f8)
@@ -268,6 +268,9 @@ module Droonga
         end
       end
 
+      STATIC_NUMBER_VALUE_PATTERN = /\A[-+]?[\d\.]+\z/.freeze
+      STATIC_STRING_VALUE_PATTERN = /\A("[^"]*"|'[^']*')\z/.freeze
+
       def normalize_target_attributes(attributes)
         attributes.map do |attribute|
           if attribute.is_a?(String)
@@ -276,9 +279,17 @@ module Droonga
               source: attribute,
             }
           else
+            source = attribute["source"]
+            static_value = nil
+            if STATIC_NUMBER_VALUE_PATTERN =~ source
+              static_value = source.to_i
+            elsif STATIC_NUMBER_VALUE_PATTERN =~ source
+              static_value = source[1..-2]
+            end
             {
               label: attribute["label"] || attribute["source"],
-              source: attribute["source"],
+              source: source,
+              static_value: static_value,
             }
           end
         end
-------------- next part --------------
HTML����������������������������...
Download 



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