groonga-command 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --protected
2
+ --no-private
3
+ --output doc/reference/en
4
+ --title "groonga-command API Reference"
5
+ -
6
+ doc/text/*
data/doc/text/news.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # News
2
2
 
3
+ ## 1.0.1: 2012-12-06
4
+
5
+ It's bug fix release.
6
+
7
+ ### Improvements
8
+
9
+ * Supported "register" command.
10
+
11
+ ### Fixes
12
+
13
+ * Asigned value and columns of "load" command to a result command
14
+ correctly in stand alone parsing.
15
+
3
16
  ## 1.0.0: 2012-11-29
4
17
 
5
18
  The first release!!!
@@ -40,6 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.summary, spec.description, = description.split(/\n\n+/, 3)
41
41
 
42
42
  spec.files = ["README.md", "Rakefile", "Gemfile", "#{spec.name}.gemspec"]
43
+ spec.files += [".yardopts"]
43
44
  spec.files += Dir.glob("lib/**/*.rb")
44
45
  spec.files += Dir.glob("doc/text/*")
45
46
  spec.test_files += Dir.glob("test/**/*")
@@ -52,6 +52,10 @@ module Groonga
52
52
  @arguments[normalize_name(name)]
53
53
  end
54
54
 
55
+ def []=(name, value)
56
+ @arguments[normalize_name(name)] = value
57
+ end
58
+
55
59
  def has_key?(name)
56
60
  @arguments.has_key?(normalize_name(name))
57
61
  end
@@ -24,6 +24,7 @@ require "yajl"
24
24
  require "groonga/command/error"
25
25
 
26
26
  require "groonga/command/base"
27
+
27
28
  require "groonga/command/get"
28
29
  require "groonga/command/select"
29
30
  require "groonga/command/suggest"
@@ -36,6 +37,7 @@ require "groonga/command/column-remove"
36
37
  require "groonga/command/column-rename"
37
38
  require "groonga/command/delete"
38
39
  require "groonga/command/truncate"
40
+ require "groonga/command/register"
39
41
 
40
42
  module Groonga
41
43
  module Command
@@ -70,6 +72,16 @@ module Groonga
70
72
 
71
73
  class Parser
72
74
  class << self
75
+
76
+ # parses groonga command or HTTP (starts with "/d/") command.
77
+ # @overload parse(data)
78
+ # @!macro [new] parser.parse.argument
79
+ # @param [String] data parsed command.
80
+ # @return [Groonga::Command] Returns
81
+ # {Groonga::Command} including parsed data.
82
+ # @!macro parser.parse.argument
83
+ # @overload parse(data, &block)
84
+ # @!macro parser.parse.argument
73
85
  def parse(data, &block)
74
86
  if block_given?
75
87
  event_parse(data, &block)
@@ -111,8 +123,16 @@ module Groonga
111
123
  parser.on_command do |command|
112
124
  parsed_command = command
113
125
  end
126
+ parser.on_load_columns do |command, columns|
127
+ command[:columns] ||= columns.join(",")
128
+ end
129
+ values = []
130
+ parser.on_load_value do |_, value|
131
+ values << value
132
+ end
114
133
  parser.on_load_complete do |command|
115
134
  parsed_command = command
135
+ parsed_command[:values] ||= Yajl::Encoder.encode(values)
116
136
  end
117
137
 
118
138
  consume_data(parser, data)
@@ -140,11 +160,15 @@ module Groonga
140
160
  initialize_hooks
141
161
  end
142
162
 
163
+ # Streaming parsing command.
164
+ # @param [String] chunk parsed chunk of command.
143
165
  def <<(chunk)
144
166
  @buffer << chunk
145
167
  consume_buffer
146
168
  end
147
169
 
170
+ # Finishes parsing. If Parser is loading values specified "load"
171
+ # command, this method raises {ParseError}.
148
172
  def finish
149
173
  if @loading
150
174
  raise ParseError.new("not completed",
@@ -403,7 +427,6 @@ module Groonga
403
427
  command
404
428
  end
405
429
 
406
- private
407
430
  def reset
408
431
  @command = nil
409
432
  @loading = false
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ require "groonga/command/base"
20
+
21
+ module Groonga
22
+ module Command
23
+ class Register < Base
24
+ Command.register("register", self)
25
+
26
+ class << self
27
+ def parameter_names
28
+ [
29
+ :path,
30
+ ]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -18,6 +18,6 @@
18
18
 
19
19
  module Groonga
20
20
  module Command
21
- VERSION = "1.0.0"
21
+ VERSION = "1.0.1"
22
22
  end
23
23
  end
@@ -0,0 +1,39 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ class RegisterCommandTest < Test::Unit::TestCase
20
+ class CommandLineTest < self
21
+ include GroongaCommandTestUtils::CommandLineCommandParser
22
+
23
+ def test_ordered_arguments
24
+ path = "tokenizers/mecab"
25
+
26
+ command = parse(path)
27
+ assert_instance_of(Groonga::Command::Register, command)
28
+ assert_equal({
29
+ :path => path,
30
+ },
31
+ command.arguments)
32
+ end
33
+
34
+ private
35
+ def parse(*arguments)
36
+ super("register", arguments, :output_type => false)
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -150,6 +150,7 @@ files:
150
150
  - Rakefile
151
151
  - Gemfile
152
152
  - groonga-command.gemspec
153
+ - .yardopts
153
154
  - lib/groonga/command/parser.rb
154
155
  - lib/groonga/command/load.rb
155
156
  - lib/groonga/command/table-remove.rb
@@ -160,6 +161,7 @@ files:
160
161
  - lib/groonga/command/get.rb
161
162
  - lib/groonga/command/suggest.rb
162
163
  - lib/groonga/command/table-rename.rb
164
+ - lib/groonga/command/register.rb
163
165
  - lib/groonga/command/column-rename.rb
164
166
  - lib/groonga/command/table-create.rb
165
167
  - lib/groonga/command/delete.rb
@@ -182,6 +184,7 @@ files:
182
184
  - test/command/test-column-remove.rb
183
185
  - test/command/test-column-rename.rb
184
186
  - test/command/test-table-rename.rb
187
+ - test/command/test-register.rb
185
188
  - test/command/test-select.rb
186
189
  - test/groonga-command-test-utils.rb
187
190
  - test/test-parser.rb
@@ -200,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
203
  version: '0'
201
204
  segments:
202
205
  - 0
203
- hash: -2640382691556156079
206
+ hash: -126866082870084770
204
207
  required_rubygems_version: !ruby/object:Gem::Requirement
205
208
  none: false
206
209
  requirements:
@@ -209,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
212
  version: '0'
210
213
  segments:
211
214
  - 0
212
- hash: -2640382691556156079
215
+ hash: -126866082870084770
213
216
  requirements: []
214
217
  rubyforge_project:
215
218
  rubygems_version: 1.8.23
@@ -231,6 +234,7 @@ test_files:
231
234
  - test/command/test-column-remove.rb
232
235
  - test/command/test-column-rename.rb
233
236
  - test/command/test-table-rename.rb
237
+ - test/command/test-register.rb
234
238
  - test/command/test-select.rb
235
239
  - test/groonga-command-test-utils.rb
236
240
  - test/test-parser.rb