[Groonga-commit] ranguba/groonga-client at 8cc1385 [master] Fix documents and API arguments.

Back to archive index

HorimotoYasuhiro null+****@clear*****
Tue Apr 25 19:04:57 JST 2017


HorimotoYasuhiro	2017-04-25 19:04:57 +0900 (Tue, 25 Apr 2017)

  New Revision: 8cc13852820ae087e1cc7efbc972456dee7db8e2
  https://github.com/ranguba/groonga-client/commit/8cc13852820ae087e1cc7efbc972456dee7db8e2

  Merged 82bc9ae: Merge pull request #16 from komainu8/feature/add_new_method

  Message:
    Fix documents and API arguments.

  Modified files:
    lib/groonga/client/request/select.rb
    test/request/test-select.rb

  Modified: lib/groonga/client/request/select.rb (+26 -21)
===================================================================
--- lib/groonga/client/request/select.rb    2017-04-24 19:02:52 +0900 (f5d0203)
+++ lib/groonga/client/request/select.rb    2017-04-25 19:04:57 +0900 (1b05e5c)
@@ -93,20 +93,15 @@ module Groonga
         #        filter.in_values("tags", "tag1", "tag2")
         #          # -> --filter 'in_values(tags, "tag1", "tag2")'
         #
-        #   @return [Groonga::Client::Request::Select::Filter]
-        #     The new request object for setting a filter condition.
-        #
-        #   @since 0.4.3
-        #
         #   @example: Use between function
         #      request.
-        #        filter.between("tags", "min", "min_border", "max", "max_border")
-        #          # -> --filter 'between(tags, min, "min_border", max, "max_border")'
+        #        filter.between("tags", 19, "include", 32, "include")
+        #          # -> --filter 'between(tags, 19, "include", 32, "include")'
         #
         #   @return [Groonga::Client::Request::Select::Filter]
         #     The new request object for setting a filter condition.
         #
-        #   @since 0.4.4
+        #   @since 0.4.3
         def filter(expression_or_column_name=nil, values_or_value=nil)
           if expression_or_column_name.nil? and values_or_value.nil?
             return Filter.new(self)
@@ -195,25 +190,36 @@ module Groonga
           # Adds a `between` condition then return a new `select`
           # request object.
           #
-          # @example: Multiple conditions
+          # @example: Single condition
           #    request.
           #      filter.between("tags", "min", "min_border", "max", "max_border").
           #        # -> --filter 'between(tags, min, "min_border", max, "max_border")'
           #
-          # @example: Ignore no values case
+          # @example: Error no values case
           #    request.
           #      filter.between("tags")
-          #        # -> --filter ''
+          #        # -> ArgumentError
+          #
+          # @param column_name [String, Symbol] The target column name.
+          #
+          # @param min [Integer] Specifies the minimal border value of the range.
           #
-          # @param column_name_or_value [String, Symbol, Integer] The target column name
-          #   or target num.
+          # @param min_border [String] Specifies whether the specified range contains the value
+          #                            of min or not.
+          #                            If it is "include", min value is include.
+          #                            If it is "exclude", min value is not include.
           #
-          # @param values [Object] Range of values.
+          # @param max [Integer] Specifies the maximum border value of the range.
+          #
+          # @param max_border [String] Specifies whether the specified range contains the value
+          #                            of max or not.
+          #                            If it is "include", max value is include.
+          #                            If it is "exclude", max value is not include.
           #
           # @return [Groonga::Client::Request::Select]
           #   The new request with the given condition.
-          def between(column_name_or_value, *values)
-            parameter = FilterBetweenParameter.new(column_name_or_value, *values)
+          def between(column_name, min, min_border, max, max_border)
+            parameter = FilterBetweenParameter.new(column_name, min, min_border, max, max_border)
             add_parameter(FilterMerger, parameter)
           end
 
@@ -495,21 +501,20 @@ module Groonga
         # @private
         class FilterBetweenParameter
           include ScriptSyntaxValueEscapable
-          NUM_OF_ARGUMENTS = 4
 
-          def initialize(column_name_or_value, *values)
-            @column_name_or_value = column_name_or_value
+          def initialize(column_name, *values)
+            @column_name = column_name
             @values = values
           end
 
           def to_parameters
-            return {} if****@value*****? or****@value***** != NUM_OF_ARGUMENTS
+            return {} if****@value*****?
 
             escaped_values =****@value***** do |value|
               escape_script_syntax_value(value)
             end
             {
-              filter: "between(#{@column_name_or_value}, #{escaped_values.join(", ")})",
+              filter: "between(#{@column_name}, #{escaped_values.join(", ")})",
             }
           end
         end

  Modified: test/request/test-select.rb (+2 -8)
===================================================================
--- test/request/test-select.rb    2017-04-24 19:02:52 +0900 (dfb0af6)
+++ test/request/test-select.rb    2017-04-25 19:04:57 +0900 (a24bbdd)
@@ -130,17 +130,11 @@ class TestRequestSelect < Test::Unit::TestCase
       end
 
       test("no values") do
-        assert_equal({
-                       :table => "posts",
-                     },
-                     between("tags"))
+        assert_raise(ArgumentError){ between("tags") }
       end
 
       test("too much values") do
-        assert_equal({
-                       :table => "posts",
-                     },
-                     between("ages", 2, "include", 29, "include", 3))
+        assert_raise(ArgumentError){ between("ages", 2, "include", 29, "include", 3) }
       end
     end
 
-------------- next part --------------
HTML����������������������������...
Download 



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