groonga-command 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/text/news.md +10 -0
- data/lib/groonga/command.rb +4 -1
- data/lib/groonga/command/range-filter.rb +119 -0
- data/lib/groonga/command/request-cancel.rb +42 -0
- data/lib/groonga/command/table-tokenize.rb +70 -0
- data/lib/groonga/command/tokenize.rb +20 -1
- data/lib/groonga/command/version.rb +1 -1
- data/test/command/test-range-filter.rb +136 -0
- data/test/command/test-request-cancel.rb +46 -0
- data/test/command/test-table-tokenize.rb +99 -0
- data/test/command/test-tokenize.rb +40 -1
- metadata +29 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 591023da10e62aa8ae69838fa6d5a468d2d9b3a6
|
4
|
+
data.tar.gz: 42e6f65a25e722c3df64f4f66abe49d2396b8533
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e1b13facf3a3c6bdb42f75a8cc1c0e1a0a361eafa4d942af624456a5759805f12c265003a56802b22b1ce23b167f9b5655e8c3b9b066df4ae94b67636cd586b
|
7
|
+
data.tar.gz: 16dc292d5de500fdcdbcfc6ecf7a037a43230afaceab436483cebf5ca855fd9e622fc61a27ee02e41cfd1fd3cfc0dc41ae3719665a6a7fc9dc37b251c0327a98
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 1.1.0: 2015-02-09
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* {Groonga::Command::RangeFilter}: Added.
|
8
|
+
* {Groonga::Command::TableTokenize}: Added.
|
9
|
+
* {Groonga::Command::Tokenize#mode}: Added.
|
10
|
+
* {Groonga::Command::Tokenize#token_filters}: Added.
|
11
|
+
* {Groonga::Command::RequestCancel}: Added.
|
12
|
+
|
3
13
|
## 1.0.9: 2014-10-02
|
4
14
|
|
5
15
|
### Improvements
|
data/lib/groonga/command.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2012-
|
3
|
+
# Copyright (C) 2012-2015 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -29,7 +29,9 @@ require "groonga/command/dump"
|
|
29
29
|
require "groonga/command/get"
|
30
30
|
require "groonga/command/load"
|
31
31
|
require "groonga/command/normalize"
|
32
|
+
require "groonga/command/range-filter"
|
32
33
|
require "groonga/command/register"
|
34
|
+
require "groonga/command/request-cancel"
|
33
35
|
require "groonga/command/ruby-eval"
|
34
36
|
require "groonga/command/ruby-load"
|
35
37
|
require "groonga/command/select"
|
@@ -38,5 +40,6 @@ require "groonga/command/suggest"
|
|
38
40
|
require "groonga/command/table-create"
|
39
41
|
require "groonga/command/table-remove"
|
40
42
|
require "groonga/command/table-rename"
|
43
|
+
require "groonga/command/table-tokenize"
|
41
44
|
require "groonga/command/tokenize"
|
42
45
|
require "groonga/command/truncate"
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "groonga/command/base"
|
18
|
+
|
19
|
+
module Groonga
|
20
|
+
module Command
|
21
|
+
# A command class that represents `range_filter` command.
|
22
|
+
#
|
23
|
+
# @since 1.1.0
|
24
|
+
class RangeFilter < Base
|
25
|
+
Command.register("range_filter", self)
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def parameter_names
|
29
|
+
[
|
30
|
+
:table,
|
31
|
+
:column,
|
32
|
+
:min,
|
33
|
+
:min_border,
|
34
|
+
:max,
|
35
|
+
:max_border,
|
36
|
+
:offset,
|
37
|
+
:limit,
|
38
|
+
:filter,
|
39
|
+
:output_columns,
|
40
|
+
]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [String] `table` parameter value.
|
45
|
+
#
|
46
|
+
# @since 1.1.0
|
47
|
+
def table
|
48
|
+
self[:table]
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [String] `column` parameter value.
|
52
|
+
#
|
53
|
+
# @since 1.1.0
|
54
|
+
def column
|
55
|
+
self[:column]
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [String] `min` parameter value.
|
59
|
+
#
|
60
|
+
# @since 1.1.0
|
61
|
+
def min
|
62
|
+
self[:min]
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [String] `min_border` parameter value.
|
66
|
+
#
|
67
|
+
# @since 1.1.0
|
68
|
+
def min_border
|
69
|
+
self[:min_border]
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [String] `max` parameter value.
|
73
|
+
#
|
74
|
+
# @since 1.1.0
|
75
|
+
def max
|
76
|
+
self[:max]
|
77
|
+
end
|
78
|
+
|
79
|
+
# @return [String] `max_border` parameter value.
|
80
|
+
#
|
81
|
+
# @since 1.1.0
|
82
|
+
def max_border
|
83
|
+
self[:max_border]
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [String] `offset` parameter value.
|
87
|
+
#
|
88
|
+
# @since 1.1.0
|
89
|
+
def offset
|
90
|
+
value = self[:offset]
|
91
|
+
value = value.to_i unless value.nil?
|
92
|
+
value
|
93
|
+
end
|
94
|
+
|
95
|
+
# @return [String] `limit` parameter value.
|
96
|
+
#
|
97
|
+
# @since 1.1.0
|
98
|
+
def limit
|
99
|
+
value = self[:limit]
|
100
|
+
value = value.to_i unless value.nil?
|
101
|
+
value
|
102
|
+
end
|
103
|
+
|
104
|
+
# @return [String] `filter` parameter value.
|
105
|
+
#
|
106
|
+
# @since 1.1.0
|
107
|
+
def filter
|
108
|
+
self[:filter]
|
109
|
+
end
|
110
|
+
|
111
|
+
# @return [String] `output_columns` parameter value.
|
112
|
+
#
|
113
|
+
# @since 1.1.0
|
114
|
+
def output_columns
|
115
|
+
self[:output_columns]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "groonga/command/base"
|
18
|
+
|
19
|
+
module Groonga
|
20
|
+
module Command
|
21
|
+
# A command class that represents `request_cancel` command.
|
22
|
+
#
|
23
|
+
# @since 1.1.0
|
24
|
+
class RequestCancel < Base
|
25
|
+
Command.register("request_cancel", self)
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def parameter_names
|
29
|
+
[
|
30
|
+
:id,
|
31
|
+
]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String] `id` parameter value.
|
36
|
+
# @since 1.1.0
|
37
|
+
def id
|
38
|
+
self[:id]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "groonga/command/base"
|
18
|
+
|
19
|
+
module Groonga
|
20
|
+
module Command
|
21
|
+
# A command class that represents `table_tokenize` command.
|
22
|
+
#
|
23
|
+
# @since 1.1.0
|
24
|
+
class TableTokenize < Base
|
25
|
+
Command.register("table_tokenize", self)
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def parameter_names
|
29
|
+
[
|
30
|
+
:table,
|
31
|
+
:string,
|
32
|
+
:flags,
|
33
|
+
:mode,
|
34
|
+
]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String] `table` parameter value.
|
39
|
+
#
|
40
|
+
# @since 1.1.0
|
41
|
+
def table
|
42
|
+
self[:table]
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String] `string` parameter value.
|
46
|
+
#
|
47
|
+
# @since 1.1.0
|
48
|
+
def string
|
49
|
+
self[:string]
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [Array<String>] An array of flag specified in `flags`
|
53
|
+
# parameter value. This array is extracted by parsing `flags`
|
54
|
+
# parameter value. If `flags` parameter value is nil or empty,
|
55
|
+
# an empty array is returned.
|
56
|
+
#
|
57
|
+
# @since 1.1.0
|
58
|
+
def flags
|
59
|
+
@flags ||= (self[:flags] || "").split(/\s*[| ]\s*/)
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [String] `mode` parameter value.
|
63
|
+
#
|
64
|
+
# @since 1.1.0
|
65
|
+
def mode
|
66
|
+
self[:mode]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -33,6 +33,8 @@ module Groonga
|
|
33
33
|
:string,
|
34
34
|
:normalizer,
|
35
35
|
:flags,
|
36
|
+
:mode,
|
37
|
+
:token_filters,
|
36
38
|
]
|
37
39
|
end
|
38
40
|
end
|
@@ -55,7 +57,7 @@ module Groonga
|
|
55
57
|
self[:normalizer]
|
56
58
|
end
|
57
59
|
|
58
|
-
# @return [Array<String>] An array of
|
60
|
+
# @return [Array<String>] An array of flag specified in `flags`
|
59
61
|
# parameter value. This array is extracted by parsing `flags`
|
60
62
|
# parameter value. If `flags` parameter value is nil or empty,
|
61
63
|
# an empty array is returned.
|
@@ -64,6 +66,23 @@ module Groonga
|
|
64
66
|
def flags
|
65
67
|
@flags ||= (self[:flags] || "").split(/\s*[| ]\s*/)
|
66
68
|
end
|
69
|
+
|
70
|
+
# @return [String] `mode` parameter value.
|
71
|
+
#
|
72
|
+
# @since 1.1.0
|
73
|
+
def mode
|
74
|
+
self[:mode]
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [Array<String>] An array of token filter specified in
|
78
|
+
# `token_filters` parameter value. This array is extracted by
|
79
|
+
# parsing `token_filters` parameter value. If `token_filters`
|
80
|
+
# parameter value is nil or empty, an empty array is returned.
|
81
|
+
#
|
82
|
+
# @since 1.1.0
|
83
|
+
def token_filters
|
84
|
+
@token_filters ||= (self[:token_filters] || "").split(/\s*,\s*/)
|
85
|
+
end
|
67
86
|
end
|
68
87
|
end
|
69
88
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
class RangeFilterCommandTest < Test::Unit::TestCase
|
18
|
+
private
|
19
|
+
def range_filter_command(pair_arguments={}, ordered_arguments=[])
|
20
|
+
Groonga::Command::RangeFilter.new("range_filter",
|
21
|
+
pair_arguments,
|
22
|
+
ordered_arguments)
|
23
|
+
end
|
24
|
+
|
25
|
+
class ConstructorTest < self
|
26
|
+
def test_ordered_arguments
|
27
|
+
table = "Logs"
|
28
|
+
column = "timestamp",
|
29
|
+
min = "2015-01-26 00:00:00"
|
30
|
+
min_border = "include"
|
31
|
+
max = "2015-01-27 00:00:00"
|
32
|
+
max_border = "exclude"
|
33
|
+
offset = "10"
|
34
|
+
limit = "20"
|
35
|
+
filter = "value == 10"
|
36
|
+
output_columns = "_key, timestamp"
|
37
|
+
|
38
|
+
ordered_arguments = [
|
39
|
+
table,
|
40
|
+
column,
|
41
|
+
min,
|
42
|
+
min_border,
|
43
|
+
max,
|
44
|
+
max_border,
|
45
|
+
offset,
|
46
|
+
limit,
|
47
|
+
filter,
|
48
|
+
output_columns,
|
49
|
+
]
|
50
|
+
command = range_filter_command({}, ordered_arguments)
|
51
|
+
assert_equal({
|
52
|
+
:table => table,
|
53
|
+
:column => column,
|
54
|
+
:min => min,
|
55
|
+
:min_border => min_border,
|
56
|
+
:max => max,
|
57
|
+
:max_border => max_border,
|
58
|
+
:offset => offset,
|
59
|
+
:limit => limit,
|
60
|
+
:filter => filter,
|
61
|
+
:output_columns => output_columns,
|
62
|
+
},
|
63
|
+
command.arguments)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class TableTest < self
|
68
|
+
def test_reader
|
69
|
+
command = range_filter_command(:table => "Logs")
|
70
|
+
assert_equal("Logs", command.table)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class ColumnTest < self
|
75
|
+
def test_reader
|
76
|
+
command = range_filter_command(:column => "timestamp")
|
77
|
+
assert_equal("timestamp", command.column)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
class MinTest < self
|
82
|
+
def test_reader
|
83
|
+
command = range_filter_command(:min => "2015-01-26 00:00:00")
|
84
|
+
assert_equal("2015-01-26 00:00:00", command.min)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class MinBorderTest < self
|
89
|
+
def test_reader
|
90
|
+
command = range_filter_command(:min_border => "include")
|
91
|
+
assert_equal("include", command.min_border)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class MaxTest < self
|
96
|
+
def test_reader
|
97
|
+
command = range_filter_command(:max => "2015-01-26 00:00:00")
|
98
|
+
assert_equal("2015-01-26 00:00:00", command.max)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class MaxBorderTest < self
|
103
|
+
def test_reader
|
104
|
+
command = range_filter_command(:max_border => "include")
|
105
|
+
assert_equal("include", command.max_border)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class OffsetTest < self
|
110
|
+
def test_reader
|
111
|
+
command = range_filter_command(:offset => "10")
|
112
|
+
assert_equal(10, command.offset)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class LimitTest < self
|
117
|
+
def test_reader
|
118
|
+
command = range_filter_command(:limit => "20")
|
119
|
+
assert_equal(20, command.limit)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class FilterTest < self
|
124
|
+
def test_reader
|
125
|
+
command = range_filter_command(:filter => "value == 10")
|
126
|
+
assert_equal("value == 10", command.filter)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
class OutputColumnsTest < self
|
131
|
+
def test_reader
|
132
|
+
command = range_filter_command(:output_columns => "_key, timestamp")
|
133
|
+
assert_equal("_key, timestamp", command.output_columns)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
class RequestCancelCommandTest < Test::Unit::TestCase
|
18
|
+
private
|
19
|
+
def request_cancel_command(pair_arguments={}, ordered_arguments=[])
|
20
|
+
Groonga::Command::RequestCancel.new("request_cancel",
|
21
|
+
pair_arguments,
|
22
|
+
ordered_arguments)
|
23
|
+
end
|
24
|
+
|
25
|
+
class ConstructorTest < self
|
26
|
+
def test_ordered_arguments
|
27
|
+
id = "ID"
|
28
|
+
|
29
|
+
ordered_arguments = [
|
30
|
+
id,
|
31
|
+
]
|
32
|
+
command = request_cancel_command({}, ordered_arguments)
|
33
|
+
assert_equal({
|
34
|
+
:id => id,
|
35
|
+
},
|
36
|
+
command.arguments)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class IDTest < self
|
41
|
+
def test_reader
|
42
|
+
command = request_cancel_command(:id => "ID")
|
43
|
+
assert_equal("ID", command.id)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# Copyright (C) 2015 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
class TableTokenizeCommandTest < Test::Unit::TestCase
|
18
|
+
private
|
19
|
+
def table_tokenize_command(pair_arguments={}, ordered_arguments=[])
|
20
|
+
Groonga::Command::TableTokenize.new("table_tokenize",
|
21
|
+
pair_arguments,
|
22
|
+
ordered_arguments)
|
23
|
+
end
|
24
|
+
|
25
|
+
class ConstructorTest < self
|
26
|
+
def test_ordered_arguments
|
27
|
+
table = "Lexicon"
|
28
|
+
string = "groonga ruby linux"
|
29
|
+
flags = "NONE"
|
30
|
+
mode = "ADD"
|
31
|
+
|
32
|
+
ordered_arguments = [
|
33
|
+
table,
|
34
|
+
string,
|
35
|
+
flags,
|
36
|
+
mode,
|
37
|
+
]
|
38
|
+
command = table_tokenize_command({}, ordered_arguments)
|
39
|
+
assert_equal({
|
40
|
+
:table => table,
|
41
|
+
:string => string,
|
42
|
+
:flags => flags,
|
43
|
+
:mode => mode,
|
44
|
+
},
|
45
|
+
command.arguments)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class TableTest < self
|
50
|
+
def test_reader
|
51
|
+
command = table_tokenize_command(:table => "Lexicon")
|
52
|
+
assert_equal("Lexicon", command.table)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class StringTest < self
|
57
|
+
def test_reader
|
58
|
+
command = table_tokenize_command(:string => "Hello World")
|
59
|
+
assert_equal("Hello World", command.string)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class FlagsTest < self
|
64
|
+
def test_nil
|
65
|
+
command = table_tokenize_command
|
66
|
+
assert_equal([], command.flags)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_empty
|
70
|
+
command = table_tokenize_command(:flags => "")
|
71
|
+
assert_equal([], command.flags)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_pipe_separator
|
75
|
+
flags = "NONE|ENABLE_TOKENIZED_DELIMITER"
|
76
|
+
command = table_tokenize_command(:flags => flags)
|
77
|
+
assert_equal(["NONE", "ENABLE_TOKENIZED_DELIMITER"], command.flags)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_space_separator
|
81
|
+
flags = "NONE ENABLE_TOKENIZED_DELIMITER"
|
82
|
+
command = table_tokenize_command(:flags => flags)
|
83
|
+
assert_equal(["NONE", "ENABLE_TOKENIZED_DELIMITER"], command.flags)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_spaces_around_separator
|
87
|
+
flags = "NONE | ENABLE_TOKENIZED_DELIMITER"
|
88
|
+
command = table_tokenize_command(:flags => flags)
|
89
|
+
assert_equal(["NONE", "ENABLE_TOKENIZED_DELIMITER"], command.flags)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
class ModeTest < self
|
94
|
+
def test_reader
|
95
|
+
command = table_tokenize_command(:mode => "ADD")
|
96
|
+
assert_equal("ADD", command.mode)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
|
3
|
+
# Copyright (C) 2013-2015 Kouhei Sutou <kou@clear-code.com>
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -30,12 +30,16 @@ class TokenizeCommandTest < Test::Unit::TestCase
|
|
30
30
|
string = "groonga ruby linux"
|
31
31
|
normalizer = "NormalizerAuto"
|
32
32
|
flags = "NONE"
|
33
|
+
mode = "ADD"
|
34
|
+
token_filters = "TokenFilterStem"
|
33
35
|
|
34
36
|
ordered_arguments = [
|
35
37
|
tokenizer,
|
36
38
|
string,
|
37
39
|
normalizer,
|
38
40
|
flags,
|
41
|
+
mode,
|
42
|
+
token_filters
|
39
43
|
]
|
40
44
|
command = tokenize_command({}, ordered_arguments)
|
41
45
|
assert_equal({
|
@@ -43,6 +47,8 @@ class TokenizeCommandTest < Test::Unit::TestCase
|
|
43
47
|
:string => string,
|
44
48
|
:normalizer => normalizer,
|
45
49
|
:flags => flags,
|
50
|
+
:mode => mode,
|
51
|
+
:token_filters => token_filters,
|
46
52
|
},
|
47
53
|
command.arguments)
|
48
54
|
end
|
@@ -95,4 +101,37 @@ class TokenizeCommandTest < Test::Unit::TestCase
|
|
95
101
|
assert_equal(["NONE", "ENABLE_TOKENIZED_DELIMITER"], command.flags)
|
96
102
|
end
|
97
103
|
end
|
104
|
+
|
105
|
+
class ModeTest < self
|
106
|
+
def test_reader
|
107
|
+
command = tokenize_command(:mode => "ADD")
|
108
|
+
assert_equal("ADD", command.mode)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class TokenFiltersTest < self
|
113
|
+
def test_nil
|
114
|
+
command = tokenize_command
|
115
|
+
assert_equal([], command.token_filters)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_empty
|
119
|
+
command = tokenize_command(:token_filters => "")
|
120
|
+
assert_equal([], command.token_filters)
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_comma_separator
|
124
|
+
token_filters = "TokenFilterStem,TokenFilterStopWord"
|
125
|
+
command = tokenize_command(:token_filters => token_filters)
|
126
|
+
assert_equal(["TokenFilterStem", "TokenFilterStopWord"],
|
127
|
+
command.token_filters)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_spaces_around_separator
|
131
|
+
token_filters = "TokenFilterStem , TokenFilterStopWord"
|
132
|
+
command = tokenize_command(:token_filters => token_filters)
|
133
|
+
assert_equal(["TokenFilterStem", "TokenFilterStopWord"],
|
134
|
+
command.token_filters)
|
135
|
+
end
|
136
|
+
end
|
98
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -150,7 +150,9 @@ files:
|
|
150
150
|
- lib/groonga/command/get.rb
|
151
151
|
- lib/groonga/command/load.rb
|
152
152
|
- lib/groonga/command/normalize.rb
|
153
|
+
- lib/groonga/command/range-filter.rb
|
153
154
|
- lib/groonga/command/register.rb
|
155
|
+
- lib/groonga/command/request-cancel.rb
|
154
156
|
- lib/groonga/command/ruby-eval.rb
|
155
157
|
- lib/groonga/command/ruby-load.rb
|
156
158
|
- lib/groonga/command/select.rb
|
@@ -159,6 +161,7 @@ files:
|
|
159
161
|
- lib/groonga/command/table-create.rb
|
160
162
|
- lib/groonga/command/table-remove.rb
|
161
163
|
- lib/groonga/command/table-rename.rb
|
164
|
+
- lib/groonga/command/table-tokenize.rb
|
162
165
|
- lib/groonga/command/tokenize.rb
|
163
166
|
- lib/groonga/command/truncate.rb
|
164
167
|
- lib/groonga/command/version.rb
|
@@ -173,7 +176,9 @@ files:
|
|
173
176
|
- test/command/test-get.rb
|
174
177
|
- test/command/test-load.rb
|
175
178
|
- test/command/test-normalize.rb
|
179
|
+
- test/command/test-range-filter.rb
|
176
180
|
- test/command/test-register.rb
|
181
|
+
- test/command/test-request-cancel.rb
|
177
182
|
- test/command/test-ruby-eval.rb
|
178
183
|
- test/command/test-ruby-load.rb
|
179
184
|
- test/command/test-select.rb
|
@@ -182,6 +187,7 @@ files:
|
|
182
187
|
- test/command/test-table-create.rb
|
183
188
|
- test/command/test-table-remove.rb
|
184
189
|
- test/command/test-table-rename.rb
|
190
|
+
- test/command/test-table-tokenize.rb
|
185
191
|
- test/command/test-tokenize.rb
|
186
192
|
- test/command/test-truncate.rb
|
187
193
|
- test/groonga-command-test-utils.rb
|
@@ -212,28 +218,31 @@ specification_version: 4
|
|
212
218
|
summary: Groonga-command is a library that represents [Groonga](http://groonga.org/)'s
|
213
219
|
command. You can write a program that handle Groonga's command by using groonga-command.
|
214
220
|
test_files:
|
215
|
-
- test/
|
216
|
-
- test/command/test-
|
217
|
-
- test/command/test-ruby-load.rb
|
218
|
-
- test/command/test-table-rename.rb
|
219
|
-
- test/command/test-dump.rb
|
220
|
-
- test/command/test-base.rb
|
221
|
-
- test/command/test-status.rb
|
221
|
+
- test/command/test-column-remove.rb
|
222
|
+
- test/command/test-range-filter.rb
|
222
223
|
- test/command/test-table-remove.rb
|
223
|
-
- test/command/format/test-command.rb
|
224
|
-
- test/command/test-delete.rb
|
225
|
-
- test/command/test-select.rb
|
226
|
-
- test/command/test-table-create.rb
|
227
|
-
- test/command/test-load.rb
|
228
|
-
- test/command/test-suggest.rb
|
229
224
|
- test/command/test-column-rename.rb
|
230
|
-
- test/command/test-ruby-eval.rb
|
231
|
-
- test/command/test-tokenize.rb
|
232
|
-
- test/command/test-column-remove.rb
|
233
|
-
- test/command/test-truncate.rb
|
234
225
|
- test/command/test-column-create.rb
|
235
|
-
- test/command/test-
|
226
|
+
- test/command/test-select.rb
|
227
|
+
- test/command/test-table-tokenize.rb
|
228
|
+
- test/command/test-suggest.rb
|
229
|
+
- test/command/test-request-cancel.rb
|
236
230
|
- test/command/test-column-list.rb
|
231
|
+
- test/command/test-load.rb
|
232
|
+
- test/command/test-dump.rb
|
233
|
+
- test/command/test-truncate.rb
|
234
|
+
- test/command/test-delete.rb
|
235
|
+
- test/command/test-ruby-load.rb
|
236
|
+
- test/command/test-base.rb
|
237
|
+
- test/command/test-table-rename.rb
|
238
|
+
- test/command/test-normalize.rb
|
237
239
|
- test/command/test-get.rb
|
240
|
+
- test/command/format/test-command.rb
|
241
|
+
- test/command/test-tokenize.rb
|
242
|
+
- test/command/test-ruby-eval.rb
|
243
|
+
- test/command/test-status.rb
|
244
|
+
- test/command/test-register.rb
|
245
|
+
- test/command/test-table-create.rb
|
238
246
|
- test/run-test.rb
|
247
|
+
- test/groonga-command-test-utils.rb
|
239
248
|
has_rdoc:
|