groonga-command 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bc3354b6043a870c3bc49882c7e32d903f64ca7
4
- data.tar.gz: ea676c91a3247a77351a4d096f431617015dad75
3
+ metadata.gz: 0d32457d22cdba4f0e6ea5758ae038cc66bec03c
4
+ data.tar.gz: fb8c5369a64d1fb468a058826dfc754a90326ef3
5
5
  SHA512:
6
- metadata.gz: 201bb9895bf600093ad3b71be43665cf584eb305aad5478ddd79345d724b1214b67f3c121b3a5f74a7d08652bf3c549bad9e9f64ba33ae96fec06356cdad6f55
7
- data.tar.gz: 9fda5545e981d63ae3b60c8cbda7285ab52fcef4f3983b99777bedbc8dbb777673433e9ccdaf3133bbe31701427a252e56ad72572b480270cd65bf637c69515e
6
+ metadata.gz: c725efcfa81fe6cf6bb8c9b846251c8d05574f286a7d05abe5455eb6ee38eb3d1b9b1be09ebfcba52c0032f53d3b1389bebddb10c49b5c509064016aebc620ca
7
+ data.tar.gz: 14e67e96af3df200db392971cd45eaa6174c6f0746396b42cd117d3d2b23f0ad23c0e65be936f59fa059f75f7d21349d372dfec0311847c9888bd5b87666b826
data/doc/text/news.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # News
2
2
 
3
+ ## 1.2.1: 2016-08-03
4
+
5
+ ### Improvements
6
+
7
+ * {Groonga::Command::Schema}: Added.
8
+ * {Groonga::Command::QueryExpand}: Added.
9
+ * {Groonga::Command::TableCreate#token_filters}: Added.
10
+
3
11
  ## 1.2.0: 2016-03-21
4
12
 
5
13
  ### Improvements
@@ -46,12 +46,14 @@ require "groonga/command/object-inspect"
46
46
  require "groonga/command/object-remove"
47
47
  require "groonga/command/plugin-register"
48
48
  require "groonga/command/plugin-unregister"
49
+ require "groonga/command/query-expand"
49
50
  require "groonga/command/range-filter"
50
51
  require "groonga/command/register"
51
52
  require "groonga/command/reindex"
52
53
  require "groonga/command/request-cancel"
53
54
  require "groonga/command/ruby-eval"
54
55
  require "groonga/command/ruby-load"
56
+ require "groonga/command/schema"
55
57
  require "groonga/command/select"
56
58
  require "groonga/command/shutdown"
57
59
  require "groonga/command/status"
@@ -0,0 +1,99 @@
1
+ # Copyright (C) 2016 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 `query_expand` command.
22
+ #
23
+ # @since 1.2.1
24
+ class QueryExpand < Base
25
+ Command.register("query_expand", self)
26
+
27
+ class << self
28
+ def parameter_names
29
+ [
30
+ :expander,
31
+ :query,
32
+ :flags,
33
+ ]
34
+ end
35
+ end
36
+
37
+ # @return [String] `expander` parameter value.
38
+ #
39
+ # @since 1.2.1
40
+ def expander
41
+ self[:expander]
42
+ end
43
+
44
+ # @return [String] `query` parameter value.
45
+ #
46
+ # @since 1.2.1
47
+ def query
48
+ self[:query]
49
+ end
50
+
51
+ # @return [Array<String>] `flags` parameter value.
52
+ #
53
+ # @since 1.2.1
54
+ def flags
55
+ @flags ||= (self[:flags] || "").split(/(?:\s*\|\s*)|(?:\s+)/)
56
+ end
57
+
58
+ # @return [Boolean] `true` if `"ALLOW_PRAGMA"` is specified in
59
+ # {#flags}, `false` otherwise.
60
+ #
61
+ # @since 1.2.1
62
+ def allow_pragma?
63
+ flags.include?("ALLOW_PRAGMA")
64
+ end
65
+
66
+ # @return [Boolean] `true` if `"ALLOW_COLUMN"` is specified in
67
+ # {#flags}, `false` otherwise.
68
+ #
69
+ # @since 1.2.1
70
+ def allow_column?
71
+ flags.include?("ALLOW_COLUMN")
72
+ end
73
+
74
+ # @return [Boolean] `true` if `"ALLOW_UPDATE"` is specified in
75
+ # {#flags}, `false` otherwise.
76
+ #
77
+ # @since 1.2.1
78
+ def allow_update?
79
+ flags.include?("ALLOW_UPDATE")
80
+ end
81
+
82
+ # @return [Boolean] `true` if `"ALLOW_LEADING_NOT"` is specified in
83
+ # {#flags}, `false` otherwise.
84
+ #
85
+ # @since 1.2.1
86
+ def allow_leading_not?
87
+ flags.include?("ALLOW_LEADING_NOT")
88
+ end
89
+
90
+ # @return [Boolean] `true` if `"NONE"` is specified in {#flags},
91
+ # `false` otherwise.
92
+ #
93
+ # @since 1.2.1
94
+ def none?
95
+ flags.include?("NONE")
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (C) 2016 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 `schema` command.
22
+ #
23
+ # @since 1.2.1
24
+ class Schema < Base
25
+ Command.register("schema", self)
26
+ end
27
+ end
28
+ end
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2012-2016 Kouhei Sutou <kou@clear-code.com>
4
2
  #
5
3
  # This library is free software; you can redistribute it and/or
6
4
  # modify it under the terms of the GNU Lesser General Public
@@ -32,6 +30,7 @@ module Groonga
32
30
  :value_type,
33
31
  :default_tokenizer,
34
32
  :normalizer,
33
+ :token_filters,
35
34
  ]
36
35
  end
37
36
  end
@@ -92,6 +91,12 @@ module Groonga
92
91
  def normalizer
93
92
  self[:normalizer]
94
93
  end
94
+
95
+ # @return [::Array<String>] Token filter names.
96
+ # @since 1.2.1
97
+ def token_filters
98
+ @token_filters ||= (self[:token_filters] || "").split(/\s*\|\s*/)
99
+ end
95
100
  end
96
101
  end
97
102
  end
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Groonga
18
18
  module Command
19
- VERSION = "1.2.0"
19
+ VERSION = "1.2.1"
20
20
  end
21
21
  end
@@ -0,0 +1,171 @@
1
+ # Copyright (C) 2016 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 QueryExpandCommandTest < Test::Unit::TestCase
18
+ private
19
+ def query_expand_command(pair_arguments={}, ordered_arguments=[])
20
+ Groonga::Command::QueryExpand.new("query_expand",
21
+ pair_arguments,
22
+ ordered_arguments)
23
+ end
24
+
25
+ class ConstructorTest < self
26
+ def test_ordered_arguments
27
+ expander = "QueryExpanderTSV"
28
+ query = "Rroonga"
29
+ flags = "ALLOW_PRAGMA|ALLOW_COLUMN"
30
+
31
+ command = query_expand_command({},
32
+ [
33
+ expander,
34
+ query,
35
+ flags,
36
+ ])
37
+ assert_equal({
38
+ :expander => expander,
39
+ :query => query,
40
+ :flags => flags,
41
+ },
42
+ command.arguments)
43
+ end
44
+ end
45
+
46
+ class ExpanderTest < self
47
+ def test_reader
48
+ command = query_expand_command(:expander => "QueryExpanderTSV")
49
+ assert_equal("QueryExpanderTSV", command.expander)
50
+ end
51
+ end
52
+
53
+ class QueryTest < self
54
+ def test_reader
55
+ command = query_expand_command(:query => "Rroonga")
56
+ assert_equal("Rroonga", command.query)
57
+ end
58
+ end
59
+
60
+ class FlagsTest < self
61
+ def test_omitted
62
+ command = query_expand_command
63
+ assert_equal([],
64
+ command.flags)
65
+ end
66
+
67
+ def test_one
68
+ command = query_expand_command(:flags => "ALLOW_COLUMN")
69
+ assert_equal(["ALLOW_COLUMN"],
70
+ command.flags)
71
+ end
72
+
73
+ def test_pipe_separator
74
+ command = query_expand_command(:flags => "ALLOW_UPDATE|ALLOW_COLUMN")
75
+ assert_equal(["ALLOW_UPDATE", "ALLOW_COLUMN"],
76
+ command.flags)
77
+ end
78
+
79
+ def test_pipe_separator_with_space
80
+ command = query_expand_command(:flags => "ALLOW_UPDATE | ALLOW_COLUMN")
81
+ assert_equal(["ALLOW_UPDATE", "ALLOW_COLUMN"],
82
+ command.flags)
83
+ end
84
+
85
+ def test_space_separator
86
+ command = query_expand_command(:flags => "ALLOW_UPDATE ALLOW_COLUMN")
87
+ assert_equal(["ALLOW_UPDATE", "ALLOW_COLUMN"],
88
+ command.flags)
89
+ end
90
+ end
91
+
92
+ class AllowPragmaTest < self
93
+ def test_true
94
+ command = query_expand_command(:flags => "ALLOW_PRAGMA")
95
+ assert do
96
+ command.allow_pragma?
97
+ end
98
+ end
99
+
100
+ def test_false
101
+ command = query_expand_command(:flags => "ALLOW_COLUMN")
102
+ assert do
103
+ not command.allow_pragma?
104
+ end
105
+ end
106
+ end
107
+
108
+ class AllowColumnTest < self
109
+ def test_true
110
+ command = query_expand_command(:flags => "ALLOW_COLUMN")
111
+ assert do
112
+ command.allow_column?
113
+ end
114
+ end
115
+
116
+ def test_false
117
+ command = query_expand_command(:flags => "ALLOW_PRAGMA")
118
+ assert do
119
+ not command.allow_column?
120
+ end
121
+ end
122
+ end
123
+
124
+ class AllowUpdateTest < self
125
+ def test_true
126
+ command = query_expand_command(:flags => "ALLOW_UPDATE")
127
+ assert do
128
+ command.allow_update?
129
+ end
130
+ end
131
+
132
+ def test_false
133
+ command = query_expand_command(:flags => "ALLOW_PRAGMA")
134
+ assert do
135
+ not command.allow_update?
136
+ end
137
+ end
138
+ end
139
+
140
+ class AllowLeadingNotTest < self
141
+ def test_true
142
+ command = query_expand_command(:flags => "ALLOW_LEADING_NOT")
143
+ assert do
144
+ command.allow_leading_not?
145
+ end
146
+ end
147
+
148
+ def test_false
149
+ command = query_expand_command(:flags => "ALLOW_PRAGMA")
150
+ assert do
151
+ not command.allow_leading_not?
152
+ end
153
+ end
154
+ end
155
+
156
+ class NoneTest < self
157
+ def test_true
158
+ command = query_expand_command(:flags => "NONE")
159
+ assert do
160
+ command.none?
161
+ end
162
+ end
163
+
164
+ def test_false
165
+ command = query_expand_command(:flags => "ALLOW_PRAGMA")
166
+ assert do
167
+ not command.none?
168
+ end
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,29 @@
1
+ # Copyright (C) 2016 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 SchemaCommandTest < Test::Unit::TestCase
18
+ private
19
+ def schema_command(pair_arguments={}, ordered_arguments=[])
20
+ Groonga::Command::Schema.new("schema", pair_arguments, ordered_arguments)
21
+ end
22
+
23
+ class ConstructorTest < self
24
+ def test_ordered_arguments
25
+ command = schema_command({}, [])
26
+ assert_equal({}, command.arguments)
27
+ end
28
+ end
29
+ end
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2012-2016 Kouhei Sutou <kou@clear-code.com>
4
2
  #
5
3
  # This library is free software; you can redistribute it and/or
6
4
  # modify it under the terms of the GNU Lesser General Public
@@ -32,6 +30,7 @@ class TableCreateCommandTest < Test::Unit::TestCase
32
30
  value_type = "UInt32"
33
31
  default_tokenizer = "TokenBigram"
34
32
  normalizer = "NormalizerAuto"
33
+ token_filters = "TokenFilterStopWord|TokenFilterStem"
35
34
 
36
35
  ordered_arguments = [
37
36
  name,
@@ -40,6 +39,7 @@ class TableCreateCommandTest < Test::Unit::TestCase
40
39
  value_type,
41
40
  default_tokenizer,
42
41
  normalizer,
42
+ token_filters,
43
43
  ]
44
44
  command = table_create_command({}, ordered_arguments)
45
45
  assert_equal({
@@ -49,6 +49,7 @@ class TableCreateCommandTest < Test::Unit::TestCase
49
49
  :value_type => value_type,
50
50
  :default_tokenizer => default_tokenizer,
51
51
  :normalizer => normalizer,
52
+ :token_filters => token_filters,
52
53
  },
53
54
  command.arguments)
54
55
  end
@@ -185,4 +186,29 @@ class TableCreateCommandTest < Test::Unit::TestCase
185
186
  assert_nil(command.normalizer)
186
187
  end
187
188
  end
189
+
190
+ class TokenFiltersTest < self
191
+ def test_multiple
192
+ arguments = {
193
+ "token_filters" => "TokenFilterStopWord|TokenFilterStem",
194
+ }
195
+ command = table_create_command(arguments)
196
+ assert_equal(["TokenFilterStopWord", "TokenFilterStem"],
197
+ command.token_filters)
198
+ end
199
+
200
+ def test_one
201
+ arguments = {
202
+ "token_filters" => "TokenFilterStopWord",
203
+ }
204
+ command = table_create_command(arguments)
205
+ assert_equal(["TokenFilterStopWord"],
206
+ command.token_filters)
207
+ end
208
+
209
+ def test_no_flags
210
+ command = table_create_command
211
+ assert_equal([], command.token_filters)
212
+ end
213
+ end
188
214
  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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-21 00:00:00.000000000 Z
11
+ date: 2016-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -167,12 +167,14 @@ files:
167
167
  - lib/groonga/command/object-remove.rb
168
168
  - lib/groonga/command/plugin-register.rb
169
169
  - lib/groonga/command/plugin-unregister.rb
170
+ - lib/groonga/command/query-expand.rb
170
171
  - lib/groonga/command/range-filter.rb
171
172
  - lib/groonga/command/register.rb
172
173
  - lib/groonga/command/reindex.rb
173
174
  - lib/groonga/command/request-cancel.rb
174
175
  - lib/groonga/command/ruby-eval.rb
175
176
  - lib/groonga/command/ruby-load.rb
177
+ - lib/groonga/command/schema.rb
176
178
  - lib/groonga/command/select.rb
177
179
  - lib/groonga/command/shutdown.rb
178
180
  - lib/groonga/command/status.rb
@@ -214,12 +216,14 @@ files:
214
216
  - test/command/test-object-remove.rb
215
217
  - test/command/test-plugin-register.rb
216
218
  - test/command/test-plugin-unregister.rb
219
+ - test/command/test-query-expand.rb
217
220
  - test/command/test-range-filter.rb
218
221
  - test/command/test-register.rb
219
222
  - test/command/test-reindex.rb
220
223
  - test/command/test-request-cancel.rb
221
224
  - test/command/test-ruby-eval.rb
222
225
  - test/command/test-ruby-load.rb
226
+ - test/command/test-schema.rb
223
227
  - test/command/test-select.rb
224
228
  - test/command/test-shutdown.rb
225
229
  - test/command/test-status.rb
@@ -298,6 +302,7 @@ test_files:
298
302
  - test/command/test-range-filter.rb
299
303
  - test/command/test-status.rb
300
304
  - test/command/test-logical-shard-list.rb
305
+ - test/command/test-schema.rb
301
306
  - test/command/test-suggest.rb
302
307
  - test/command/test-select.rb
303
308
  - test/command/test-column-remove.rb
@@ -305,6 +310,7 @@ test_files:
305
310
  - test/command/test-table-create.rb
306
311
  - test/command/test-table-remove.rb
307
312
  - test/command/test-ruby-load.rb
313
+ - test/command/test-query-expand.rb
308
314
  - test/command/test-truncate.rb
309
315
  - test/command/test-logical-table-remove.rb
310
316
  - test/run-test.rb