groonga-command 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.yardopts CHANGED
@@ -2,5 +2,6 @@
2
2
  --no-private
3
3
  --output doc/reference/en
4
4
  --title "groonga-command API Reference"
5
+ --markup markdown
5
6
  -
6
7
  doc/text/*
data/README.md CHANGED
@@ -7,8 +7,8 @@ groonga-command
7
7
  ## Description
8
8
 
9
9
  Groonga-command is a library that represents
10
- [groonga](http://groonga.org/)'s command. You can write a program that
11
- handle groonga's command by using groonga-command.
10
+ [Groonga](http://groonga.org/)'s command. You can write a program that
11
+ handle Groonga's command by using groonga-command.
12
12
 
13
13
  ## Install
14
14
 
data/doc/text/news.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # News
2
2
 
3
+ ## 1.0.6: 2013-10-29
4
+
5
+ ### Improvements
6
+
7
+ * {Groonga::Command::Status}: Added.
8
+ * {Groonga::Command::Select}: Added accessor for "values" parameter.
9
+ * {Groonga::Command::Tokenize}: Added.
10
+ * {Groonga::Command::ColumnList}: Added.
11
+ * {Groonga::Command::Normalize}: Added.
12
+ * {Groonga::Command::RubyEval}: Added.
13
+ * {Groonga::Command::RubyLoad}: Added.
14
+
3
15
  ## 1.0.5: 2013-09-29
4
16
 
5
17
  ### Improvements
@@ -52,6 +52,8 @@ Gem::Specification.new do |spec|
52
52
  spec.licenses = ["LGPLv2.1+"]
53
53
  spec.require_paths = ["lib"]
54
54
 
55
+ spec.add_runtime_dependency("json")
56
+
55
57
  spec.add_development_dependency("test-unit")
56
58
  spec.add_development_dependency("test-unit-notify")
57
59
  spec.add_development_dependency("rake")
@@ -21,16 +21,22 @@ require "groonga/command/version"
21
21
  require "groonga/command/error"
22
22
 
23
23
  require "groonga/command/column-create"
24
+ require "groonga/command/column-list"
24
25
  require "groonga/command/column-remove"
25
26
  require "groonga/command/column-rename"
26
27
  require "groonga/command/delete"
27
28
  require "groonga/command/dump"
28
29
  require "groonga/command/get"
29
30
  require "groonga/command/load"
31
+ require "groonga/command/normalize"
30
32
  require "groonga/command/register"
33
+ require "groonga/command/ruby-eval"
34
+ require "groonga/command/ruby-load"
31
35
  require "groonga/command/select"
36
+ require "groonga/command/status"
32
37
  require "groonga/command/suggest"
33
38
  require "groonga/command/table-create"
34
39
  require "groonga/command/table-remove"
35
40
  require "groonga/command/table-rename"
41
+ require "groonga/command/tokenize"
36
42
  require "groonga/command/truncate"
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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
+ # A command class that represents `column_list` command.
24
+ #
25
+ # @since 1.0.6
26
+ class ColumnList < Base
27
+ Command.register("column_list", self)
28
+
29
+ class << self
30
+ def parameter_names
31
+ [
32
+ :table,
33
+ ]
34
+ end
35
+ end
36
+
37
+ # @return [String] `table` parameter value.
38
+ # @since 1.0.6
39
+ def table
40
+ self[:table]
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
3
+ # Copyright (C) 2012-2013 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
@@ -16,6 +16,8 @@
16
16
  # License along with this library; if not, write to the Free Software
17
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
+ require "json"
20
+
19
21
  require "groonga/command/base"
20
22
 
21
23
  module Groonga
@@ -36,17 +38,28 @@ module Groonga
36
38
  end
37
39
  end
38
40
 
41
+ attr_writer :values
39
42
  attr_writer :columns
40
43
  def initialize(*argumetns)
41
44
  super
45
+ @values = nil
42
46
  @columns = nil
43
47
  end
44
48
 
49
+ def values
50
+ @values ||= parse_values(self[:values])
51
+ end
52
+
45
53
  def columns
46
54
  @columns ||= parse_columns(self[:columns])
47
55
  end
48
56
 
49
57
  private
58
+ def parse_values(values)
59
+ return values if values.nil?
60
+ JSON.parse(values)
61
+ end
62
+
50
63
  def parse_columns(columns)
51
64
  return columns if columns.nil?
52
65
  columns.split(/\s*,\s*/)
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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
+ # A command class that represents `normalize` command.
24
+ #
25
+ # @since 1.0.6
26
+ class Normalize < Base
27
+ Command.register("normalize", self)
28
+
29
+ class << self
30
+ def parameter_names
31
+ [
32
+ :normalizer,
33
+ :string,
34
+ :flags,
35
+ ]
36
+ end
37
+ end
38
+
39
+ # @return [String] `normalizer` parameter value.
40
+ # @since 1.0.6
41
+ def normalizer
42
+ self[:normalizer]
43
+ end
44
+
45
+ # @return [String] `string` parameter value.
46
+ # @since 1.0.6
47
+ def string
48
+ self[:string]
49
+ end
50
+
51
+ # @return [Array<String>] An array of flags specified in `flags`
52
+ # parameter value. This array is extracted by parsing `flags`
53
+ # parameter value. If `flags` parameter value is nil or empty,
54
+ # an empty array is returned.
55
+ #
56
+ # @since 1.0.6
57
+ def flags
58
+ @flags ||= (self[:flags] || "").split(/\s*[| ]\s*/)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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
+ # A command class that represents `ruby_eval` command.
24
+ #
25
+ # @since 1.0.6
26
+ class RubyEval < Base
27
+ Command.register("ruby_eval", self)
28
+
29
+ class << self
30
+ def parameter_names
31
+ [
32
+ :script,
33
+ ]
34
+ end
35
+ end
36
+
37
+ # @return [String] `script` parameter value.
38
+ # @since 1.0.6
39
+ def script
40
+ self[:script]
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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
+ # A command class that represents `ruby_load` command.
24
+ #
25
+ # @since 1.0.6
26
+ class RubyLoad < Base
27
+ Command.register("ruby_load", self)
28
+
29
+ class << self
30
+ def parameter_names
31
+ [
32
+ :path,
33
+ ]
34
+ end
35
+ end
36
+
37
+ # @return [String] `path` parameter value.
38
+ # @since 1.0.6
39
+ def path
40
+ self[:path]
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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 Status < Base
24
+ Command.register("status", self)
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,69 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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
+ # A command class that represents `tokenize` command.
24
+ #
25
+ # @since 1.0.6
26
+ class Tokenize < Base
27
+ Command.register("tokenize", self)
28
+
29
+ class << self
30
+ def parameter_names
31
+ [
32
+ :tokenizer,
33
+ :string,
34
+ :normalizer,
35
+ :flags,
36
+ ]
37
+ end
38
+ end
39
+
40
+ # @return [String] `tokenizer` parameter value.
41
+ # @since 1.0.6
42
+ def tokenizer
43
+ self[:tokenizer]
44
+ end
45
+
46
+ # @return [String] `string` parameter value.
47
+ # @since 1.0.6
48
+ def string
49
+ self[:string]
50
+ end
51
+
52
+ # @return [String] `normalizer` parameter value.
53
+ # @since 1.0.6
54
+ def normalizer
55
+ self[:normalizer]
56
+ end
57
+
58
+ # @return [Array<String>] An array of flags specified in `flags`
59
+ # parameter value. This array is extracted by parsing `flags`
60
+ # parameter value. If `flags` parameter value is nil or empty,
61
+ # an empty array is returned.
62
+ #
63
+ # @since 1.0.6
64
+ def flags
65
+ @flags ||= (self[:flags] || "").split(/\s*[| ]\s*/)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -18,6 +18,6 @@
18
18
 
19
19
  module Groonga
20
20
  module Command
21
- VERSION = "1.0.5"
21
+ VERSION = "1.0.6"
22
22
  end
23
23
  end
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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 ColumnListCommandTest < Test::Unit::TestCase
20
+ private
21
+ def column_list_command(pair_arguments={}, ordered_arguments=[])
22
+ Groonga::Command::ColumnList.new("column_list",
23
+ pair_arguments,
24
+ ordered_arguments)
25
+ end
26
+
27
+ class ConstructorTest < self
28
+ def test_ordered_arguments
29
+ table = "Users"
30
+
31
+ ordered_arguments = [
32
+ table,
33
+ ]
34
+ command = column_list_command({}, ordered_arguments)
35
+ assert_equal({
36
+ :table => table,
37
+ },
38
+ command.arguments)
39
+ end
40
+ end
41
+
42
+ class TableTest < self
43
+ def test_reader
44
+ command = column_list_command(:table => "Users")
45
+ assert_equal("Users", command.table)
46
+ end
47
+ end
48
+ end
@@ -53,4 +53,39 @@ class LoadCommandTest < Test::Unit::TestCase
53
53
  command.arguments)
54
54
  end
55
55
  end
56
+
57
+ class ValuesTest < self
58
+ def test_nil
59
+ command = load_command
60
+ assert_nil(command.values)
61
+ end
62
+
63
+ def test_empty
64
+ command = load_command(:values => "[]")
65
+ assert_equal([], command.values)
66
+ end
67
+
68
+ def test_array
69
+ command = load_command(:values => "[[\"Alice\"]]")
70
+ assert_equal([["Alice"]], command.values)
71
+ end
72
+
73
+ def test_object_literal
74
+ command = load_command(:values => "[{\"key\": \"Alice\"}]")
75
+ assert_equal([{"key" => "Alice"}], command.values)
76
+ end
77
+
78
+ def test_writer
79
+ command = load_command(:values => "[{\"key\": \"Alice\"}]")
80
+ command.values = [["Alice"]]
81
+ assert_equal({
82
+ :reader => [["Alice"]],
83
+ :array_reference => "[{\"key\": \"Alice\"}]",
84
+ },
85
+ {
86
+ :reader => command.values,
87
+ :array_reference => command[:values],
88
+ })
89
+ end
90
+ end
56
91
  end
@@ -0,0 +1,88 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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 NormalizeCommandTest < Test::Unit::TestCase
20
+ private
21
+ def normalize_command(pair_arguments={}, ordered_arguments=[])
22
+ Groonga::Command::Normalize.new("normalize",
23
+ pair_arguments,
24
+ ordered_arguments)
25
+ end
26
+
27
+ class ConstructorTest < self
28
+ def test_ordered_arguments
29
+ normalizer = "NormalizerAuto"
30
+ string = "AbcDef"
31
+ flags = "REMOVE_BLANK"
32
+
33
+ ordered_arguments = [
34
+ normalizer,
35
+ string,
36
+ flags,
37
+ ]
38
+ command = normalize_command({}, ordered_arguments)
39
+ assert_equal({
40
+ :normalizer => normalizer,
41
+ :string => string,
42
+ :flags => flags,
43
+ },
44
+ command.arguments)
45
+ end
46
+ end
47
+
48
+ class NormalizerTest < self
49
+ def test_reader
50
+ command = normalize_command(:normalizer => "NormalizerAuto")
51
+ assert_equal("NormalizerAuto", command.normalizer)
52
+ end
53
+ end
54
+
55
+ class StringTest < self
56
+ def test_reader
57
+ command = normalize_command(:string => "Hello World")
58
+ assert_equal("Hello World", command.string)
59
+ end
60
+ end
61
+
62
+ class FlagsTest < self
63
+ def test_nil
64
+ command = normalize_command
65
+ assert_equal([], command.flags)
66
+ end
67
+
68
+ def test_empty
69
+ command = normalize_command(:flags => "")
70
+ assert_equal([], command.flags)
71
+ end
72
+
73
+ def test_pipe_separator
74
+ command = normalize_command(:flags => "REMOVE_BLANK|WITH_TYPES")
75
+ assert_equal(["REMOVE_BLANK", "WITH_TYPES"], command.flags)
76
+ end
77
+
78
+ def test_space_separator
79
+ command = normalize_command(:flags => "REMOVE_BLANK WITH_TYPES")
80
+ assert_equal(["REMOVE_BLANK", "WITH_TYPES"], command.flags)
81
+ end
82
+
83
+ def test_spaces_around_separator
84
+ command = normalize_command(:flags => "REMOVE_BLANK | WITH_TYPES")
85
+ assert_equal(["REMOVE_BLANK", "WITH_TYPES"], command.flags)
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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 RubyEvalCommandTest < Test::Unit::TestCase
20
+ private
21
+ def ruby_eval_command(pair_arguments={}, ordered_arguments=[])
22
+ Groonga::Command::RubyEval.new("ruby_eval",
23
+ pair_arguments,
24
+ ordered_arguments)
25
+ end
26
+
27
+ class ConstructorTest < self
28
+ def test_ordered_arguments
29
+ script = "1 + 1"
30
+
31
+ ordered_arguments = [
32
+ script,
33
+ ]
34
+ command = ruby_eval_command({}, ordered_arguments)
35
+ assert_equal({
36
+ :script => script,
37
+ },
38
+ command.arguments)
39
+ end
40
+ end
41
+
42
+ class ScriptTest < self
43
+ def test_reader
44
+ command = ruby_eval_command(:script => "1 + 1")
45
+ assert_equal("1 + 1", command.script)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,48 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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 RubyLoadCommandTest < Test::Unit::TestCase
20
+ private
21
+ def ruby_load_command(pair_arguments={}, ordered_arguments=[])
22
+ Groonga::Command::RubyLoad.new("ruby_load",
23
+ pair_arguments,
24
+ ordered_arguments)
25
+ end
26
+
27
+ class ConstructorTest < self
28
+ def test_ordered_arguments
29
+ path = "my-library.rb"
30
+
31
+ ordered_arguments = [
32
+ path,
33
+ ]
34
+ command = ruby_load_command({}, ordered_arguments)
35
+ assert_equal({
36
+ :path => path,
37
+ },
38
+ command.arguments)
39
+ end
40
+ end
41
+
42
+ class PathTest < self
43
+ def test_reader
44
+ command = ruby_load_command(:path => "my-library.rb")
45
+ assert_equal("my-library.rb", command.path)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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 StatusCommandTest < Test::Unit::TestCase
20
+ private
21
+ def status_command(pair_arguments={}, ordered_arguments=[])
22
+ Groonga::Command::Status.new("status", pair_arguments, ordered_arguments)
23
+ end
24
+
25
+ class ConstructorTest < self
26
+ def test_ordered_arguments
27
+ command = status_command
28
+ assert_equal({}, command.arguments)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,98 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 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 TokenizeCommandTest < Test::Unit::TestCase
20
+ private
21
+ def tokenize_command(pair_arguments={}, ordered_arguments=[])
22
+ Groonga::Command::Tokenize.new("tokenize",
23
+ pair_arguments,
24
+ ordered_arguments)
25
+ end
26
+
27
+ class ConstructorTest < self
28
+ def test_ordered_arguments
29
+ tokenizer = "TokenDelimit"
30
+ string = "groonga ruby linux"
31
+ normalizer = "NormalizerAuto"
32
+ flags = "NONE"
33
+
34
+ ordered_arguments = [
35
+ tokenizer,
36
+ string,
37
+ normalizer,
38
+ flags,
39
+ ]
40
+ command = tokenize_command({}, ordered_arguments)
41
+ assert_equal({
42
+ :tokenizer => tokenizer,
43
+ :string => string,
44
+ :normalizer => normalizer,
45
+ :flags => flags,
46
+ },
47
+ command.arguments)
48
+ end
49
+ end
50
+
51
+ class TokenizerTest < self
52
+ def test_reader
53
+ command = tokenize_command(:tokenizer => "TokenBigram")
54
+ assert_equal("TokenBigram", command.tokenizer)
55
+ end
56
+ end
57
+
58
+ class StringTest < self
59
+ def test_reader
60
+ command = tokenize_command(:string => "Hello World")
61
+ assert_equal("Hello World", command.string)
62
+ end
63
+ end
64
+
65
+ class NormalizerTest < self
66
+ def test_reader
67
+ command = tokenize_command(:normalizer => "NormalizerAuto")
68
+ assert_equal("NormalizerAuto", command.normalizer)
69
+ end
70
+ end
71
+
72
+ class FlagsTest < self
73
+ def test_nil
74
+ command = tokenize_command
75
+ assert_equal([], command.flags)
76
+ end
77
+
78
+ def test_empty
79
+ command = tokenize_command(:flags => "")
80
+ assert_equal([], command.flags)
81
+ end
82
+
83
+ def test_pipe_separator
84
+ command = tokenize_command(:flags => "NONE|ENABLE_TOKENIZED_DELIMITER")
85
+ assert_equal(["NONE", "ENABLE_TOKENIZED_DELIMITER"], command.flags)
86
+ end
87
+
88
+ def test_space_separator
89
+ command = tokenize_command(:flags => "NONE ENABLE_TOKENIZED_DELIMITER")
90
+ assert_equal(["NONE", "ENABLE_TOKENIZED_DELIMITER"], command.flags)
91
+ end
92
+
93
+ def test_spaces_around_separator
94
+ command = tokenize_command(:flags => "NONE | ENABLE_TOKENIZED_DELIMITER")
95
+ assert_equal(["NONE", "ENABLE_TOKENIZED_DELIMITER"], command.flags)
96
+ end
97
+ end
98
+ end
metadata CHANGED
@@ -1,111 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Kouhei Sutou
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-09-29 00:00:00.000000000 Z
12
+ date: 2013-10-29 00:00:00.000000000 Z
12
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
13
30
  - !ruby/object:Gem::Dependency
14
31
  name: test-unit
15
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
16
34
  requirements:
17
- - - '>='
35
+ - - ! '>='
18
36
  - !ruby/object:Gem::Version
19
37
  version: '0'
20
38
  type: :development
21
39
  prerelease: false
22
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
23
42
  requirements:
24
- - - '>='
43
+ - - ! '>='
25
44
  - !ruby/object:Gem::Version
26
45
  version: '0'
27
46
  - !ruby/object:Gem::Dependency
28
47
  name: test-unit-notify
29
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
30
50
  requirements:
31
- - - '>='
51
+ - - ! '>='
32
52
  - !ruby/object:Gem::Version
33
53
  version: '0'
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
37
58
  requirements:
38
- - - '>='
59
+ - - ! '>='
39
60
  - !ruby/object:Gem::Version
40
61
  version: '0'
41
62
  - !ruby/object:Gem::Dependency
42
63
  name: rake
43
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
44
66
  requirements:
45
- - - '>='
67
+ - - ! '>='
46
68
  - !ruby/object:Gem::Version
47
69
  version: '0'
48
70
  type: :development
49
71
  prerelease: false
50
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
51
74
  requirements:
52
- - - '>='
75
+ - - ! '>='
53
76
  - !ruby/object:Gem::Version
54
77
  version: '0'
55
78
  - !ruby/object:Gem::Dependency
56
79
  name: bundler
57
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
58
82
  requirements:
59
- - - '>='
83
+ - - ! '>='
60
84
  - !ruby/object:Gem::Version
61
85
  version: '0'
62
86
  type: :development
63
87
  prerelease: false
64
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
65
90
  requirements:
66
- - - '>='
91
+ - - ! '>='
67
92
  - !ruby/object:Gem::Version
68
93
  version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: packnga
71
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
72
98
  requirements:
73
- - - '>='
99
+ - - ! '>='
74
100
  - !ruby/object:Gem::Version
75
101
  version: '0'
76
102
  type: :development
77
103
  prerelease: false
78
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
79
106
  requirements:
80
- - - '>='
107
+ - - ! '>='
81
108
  - !ruby/object:Gem::Version
82
109
  version: '0'
83
110
  - !ruby/object:Gem::Dependency
84
111
  name: yard
85
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
86
114
  requirements:
87
- - - '>='
115
+ - - ! '>='
88
116
  - !ruby/object:Gem::Version
89
117
  version: '0'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
93
122
  requirements:
94
- - - '>='
123
+ - - ! '>='
95
124
  - !ruby/object:Gem::Version
96
125
  version: '0'
97
126
  - !ruby/object:Gem::Dependency
98
127
  name: redcarpet
99
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
100
130
  requirements:
101
- - - '>='
131
+ - - ! '>='
102
132
  - !ruby/object:Gem::Version
103
133
  version: '0'
104
134
  type: :development
105
135
  prerelease: false
106
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
107
138
  requirements:
108
- - - '>='
139
+ - - ! '>='
109
140
  - !ruby/object:Gem::Version
110
141
  version: '0'
111
142
  description: ''
@@ -120,88 +151,107 @@ files:
120
151
  - Gemfile
121
152
  - groonga-command.gemspec
122
153
  - .yardopts
123
- - lib/groonga/command/version.rb
124
- - lib/groonga/command/table-create.rb
125
- - lib/groonga/command/table-rename.rb
126
- - lib/groonga/command/column-rename.rb
154
+ - lib/groonga/command/truncate.rb
127
155
  - lib/groonga/command/table-remove.rb
128
- - lib/groonga/command/register.rb
156
+ - lib/groonga/command/ruby-eval.rb
157
+ - lib/groonga/command/load.rb
158
+ - lib/groonga/command/delete.rb
159
+ - lib/groonga/command/base.rb
129
160
  - lib/groonga/command/suggest.rb
130
- - lib/groonga/command/column-remove.rb
131
- - lib/groonga/command/get.rb
161
+ - lib/groonga/command/status.rb
132
162
  - lib/groonga/command/error.rb
133
- - lib/groonga/command/truncate.rb
134
- - lib/groonga/command/load.rb
163
+ - lib/groonga/command/register.rb
164
+ - lib/groonga/command/version.rb
165
+ - lib/groonga/command/column-remove.rb
166
+ - lib/groonga/command/column-list.rb
167
+ - lib/groonga/command/column-rename.rb
135
168
  - lib/groonga/command/dump.rb
136
- - lib/groonga/command/column-create.rb
137
- - lib/groonga/command/base.rb
138
- - lib/groonga/command/select.rb
169
+ - lib/groonga/command/normalize.rb
170
+ - lib/groonga/command/table-create.rb
139
171
  - lib/groonga/command/format/command.rb
140
172
  - lib/groonga/command/format/uri.rb
141
- - lib/groonga/command/delete.rb
173
+ - lib/groonga/command/column-create.rb
174
+ - lib/groonga/command/get.rb
175
+ - lib/groonga/command/ruby-load.rb
176
+ - lib/groonga/command/select.rb
177
+ - lib/groonga/command/table-rename.rb
178
+ - lib/groonga/command/tokenize.rb
142
179
  - lib/groonga/command.rb
143
180
  - doc/text/news.md
144
181
  - doc/text/lgpl-2.1.txt
145
182
  - test/groonga-command-test-utils.rb
146
- - test/command/test-table-remove.rb
183
+ - test/run-test.rb
147
184
  - test/command/test-table-create.rb
148
- - test/command/test-column-remove.rb
149
- - test/command/test-select.rb
185
+ - test/command/test-status.rb
186
+ - test/command/test-ruby-load.rb
187
+ - test/command/test-ruby-eval.rb
188
+ - test/command/test-tokenize.rb
189
+ - test/command/test-dump.rb
150
190
  - test/command/test-table-rename.rb
151
- - test/command/test-load.rb
152
- - test/command/test-column-rename.rb
153
- - test/command/test-register.rb
154
- - test/command/test-column-create.rb
155
- - test/command/test-suggest.rb
191
+ - test/command/test-table-remove.rb
192
+ - test/command/test-truncate.rb
156
193
  - test/command/test-delete.rb
194
+ - test/command/test-select.rb
195
+ - test/command/test-column-list.rb
157
196
  - test/command/test-base.rb
158
- - test/command/test-truncate.rb
159
- - test/command/format/test-command.rb
197
+ - test/command/test-column-create.rb
198
+ - test/command/test-register.rb
160
199
  - test/command/test-get.rb
161
- - test/command/test-dump.rb
162
- - test/run-test.rb
200
+ - test/command/test-suggest.rb
201
+ - test/command/test-normalize.rb
202
+ - test/command/format/test-command.rb
203
+ - test/command/test-column-rename.rb
204
+ - test/command/test-load.rb
205
+ - test/command/test-column-remove.rb
163
206
  homepage: https://github.com/groonga/groonga-command
164
207
  licenses:
165
208
  - LGPLv2.1+
166
- metadata: {}
167
209
  post_install_message:
168
210
  rdoc_options: []
169
211
  require_paths:
170
212
  - lib
171
213
  required_ruby_version: !ruby/object:Gem::Requirement
214
+ none: false
172
215
  requirements:
173
- - - '>='
216
+ - - ! '>='
174
217
  - !ruby/object:Gem::Version
175
218
  version: '0'
176
219
  required_rubygems_version: !ruby/object:Gem::Requirement
220
+ none: false
177
221
  requirements:
178
- - - '>='
222
+ - - ! '>='
179
223
  - !ruby/object:Gem::Version
180
224
  version: '0'
181
225
  requirements: []
182
226
  rubyforge_project:
183
- rubygems_version: 2.0.7
227
+ rubygems_version: 1.8.23
184
228
  signing_key:
185
- specification_version: 4
186
- summary: Groonga-command is a library that represents [groonga](http://groonga.org/)'s
187
- command. You can write a program that handle groonga's command by using groonga-command.
229
+ specification_version: 3
230
+ summary: Groonga-command is a library that represents [Groonga](http://groonga.org/)'s
231
+ command. You can write a program that handle Groonga's command by using groonga-command.
188
232
  test_files:
189
233
  - test/groonga-command-test-utils.rb
190
- - test/command/test-table-remove.rb
234
+ - test/run-test.rb
191
235
  - test/command/test-table-create.rb
192
- - test/command/test-column-remove.rb
193
- - test/command/test-select.rb
236
+ - test/command/test-status.rb
237
+ - test/command/test-ruby-load.rb
238
+ - test/command/test-ruby-eval.rb
239
+ - test/command/test-tokenize.rb
240
+ - test/command/test-dump.rb
194
241
  - test/command/test-table-rename.rb
195
- - test/command/test-load.rb
196
- - test/command/test-column-rename.rb
197
- - test/command/test-register.rb
198
- - test/command/test-column-create.rb
199
- - test/command/test-suggest.rb
242
+ - test/command/test-table-remove.rb
243
+ - test/command/test-truncate.rb
200
244
  - test/command/test-delete.rb
245
+ - test/command/test-select.rb
246
+ - test/command/test-column-list.rb
201
247
  - test/command/test-base.rb
202
- - test/command/test-truncate.rb
203
- - test/command/format/test-command.rb
248
+ - test/command/test-column-create.rb
249
+ - test/command/test-register.rb
204
250
  - test/command/test-get.rb
205
- - test/command/test-dump.rb
206
- - test/run-test.rb
251
+ - test/command/test-suggest.rb
252
+ - test/command/test-normalize.rb
253
+ - test/command/format/test-command.rb
254
+ - test/command/test-column-rename.rb
255
+ - test/command/test-load.rb
256
+ - test/command/test-column-remove.rb
207
257
  has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 4654fec50cf4403398ad01e35a8044936faa2a0c
4
- data.tar.gz: 4060b65fbf62018cea9469f357f1fc9069315f66
5
- SHA512:
6
- metadata.gz: 0017d4332d7d050a4cf37417a05089faba2fbf6081530a0880a39a01012e16c34fd75c81c3cbae9e6eec8cdb242baa19ffeaa402746f1b19c5920493ae1747b0
7
- data.tar.gz: 57f9e10c322527640118ea6e0539437a9629687d3fd3cd668b0e9f903cadede2461dd42ab434ac066d292f7fddf96d5c95c73bbd782e470f27dbee325e7c6648