groonga-command 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +3 -3
- data/doc/text/news.md +7 -0
- data/groonga-command.gemspec +1 -3
- data/lib/groonga/command/version.rb +2 -2
- data/lib/groonga/command.rb +18 -2
- data/test/command/test-column-create.rb +107 -108
- data/test/command/test-column-remove.rb +9 -10
- data/test/command/test-column-rename.rb +9 -10
- data/test/command/test-delete.rb +9 -10
- data/test/command/test-dump.rb +7 -7
- data/test/command/test-get.rb +13 -16
- data/test/command/test-load.rb +17 -10
- data/test/command/test-register.rb +9 -10
- data/test/command/test-select.rb +83 -82
- data/test/command/test-suggest.rb +43 -35
- data/test/command/test-table-create.rb +101 -94
- data/test/command/test-table-remove.rb +9 -10
- data/test/command/test-table-rename.rb +9 -10
- data/test/command/test-truncate.rb +9 -10
- data/test/groonga-command-test-utils.rb +1 -81
- metadata +60 -95
- data/lib/groonga/command/parser.rb +0 -449
- data/test/test-parser.rb +0 -377
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4654fec50cf4403398ad01e35a8044936faa2a0c
|
4
|
+
data.tar.gz: 4060b65fbf62018cea9469f357f1fc9069315f66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0017d4332d7d050a4cf37417a05089faba2fbf6081530a0880a39a01012e16c34fd75c81c3cbae9e6eec8cdb242baa19ffeaa402746f1b19c5920493ae1747b0
|
7
|
+
data.tar.gz: 57f9e10c322527640118ea6e0539437a9629687d3fd3cd668b0e9f903cadede2461dd42ab434ac066d292f7fddf96d5c95c73bbd782e470f27dbee325e7c6648
|
data/README.md
CHANGED
@@ -6,9 +6,9 @@ groonga-command
|
|
6
6
|
|
7
7
|
## Description
|
8
8
|
|
9
|
-
Groonga-command is a library
|
10
|
-
[groonga](http://groonga.org/)'s command
|
11
|
-
|
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.
|
12
12
|
|
13
13
|
## Install
|
14
14
|
|
data/doc/text/news.md
CHANGED
data/groonga-command.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- mode: ruby; 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
|
@@ -52,8 +52,6 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.licenses = ["LGPLv2.1+"]
|
53
53
|
spec.require_paths = ["lib"]
|
54
54
|
|
55
|
-
spec.add_runtime_dependency("yajl-ruby")
|
56
|
-
|
57
55
|
spec.add_development_dependency("test-unit")
|
58
56
|
spec.add_development_dependency("test-unit-notify")
|
59
57
|
spec.add_development_dependency("rake")
|
@@ -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
|
@@ -18,6 +18,6 @@
|
|
18
18
|
|
19
19
|
module Groonga
|
20
20
|
module Command
|
21
|
-
VERSION = "1.0.
|
21
|
+
VERSION = "1.0.5"
|
22
22
|
end
|
23
23
|
end
|
data/lib/groonga/command.rb
CHANGED
@@ -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
|
@@ -17,4 +17,20 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
require "groonga/command/version"
|
20
|
-
|
20
|
+
|
21
|
+
require "groonga/command/error"
|
22
|
+
|
23
|
+
require "groonga/command/column-create"
|
24
|
+
require "groonga/command/column-remove"
|
25
|
+
require "groonga/command/column-rename"
|
26
|
+
require "groonga/command/delete"
|
27
|
+
require "groonga/command/dump"
|
28
|
+
require "groonga/command/get"
|
29
|
+
require "groonga/command/load"
|
30
|
+
require "groonga/command/register"
|
31
|
+
require "groonga/command/select"
|
32
|
+
require "groonga/command/suggest"
|
33
|
+
require "groonga/command/table-create"
|
34
|
+
require "groonga/command/table-remove"
|
35
|
+
require "groonga/command/table-rename"
|
36
|
+
require "groonga/command/truncate"
|
@@ -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-213 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
|
@@ -17,9 +17,14 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
class ColumnCreateCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
20
|
+
private
|
21
|
+
def column_create_command(pair_arguments={}, ordered_arguments=[])
|
22
|
+
Groonga::Command::ColumnCreate.new("column_create",
|
23
|
+
pair_arguments,
|
24
|
+
ordered_arguments)
|
25
|
+
end
|
22
26
|
|
27
|
+
class ConstructorTest < self
|
23
28
|
def test_ordered_arguments
|
24
29
|
table = "Lexicon"
|
25
30
|
name = "content_index"
|
@@ -27,8 +32,7 @@ class ColumnCreateCommandTest < Test::Unit::TestCase
|
|
27
32
|
type = "Posts"
|
28
33
|
source = "content"
|
29
34
|
|
30
|
-
command =
|
31
|
-
assert_instance_of(Groonga::Command::ColumnCreate, command)
|
35
|
+
command = column_create_command({}, [table, name, flags, type, source])
|
32
36
|
assert_equal({
|
33
37
|
:table => table,
|
34
38
|
:name => name,
|
@@ -38,120 +42,115 @@ class ColumnCreateCommandTest < Test::Unit::TestCase
|
|
38
42
|
},
|
39
43
|
command.arguments)
|
40
44
|
end
|
45
|
+
end
|
41
46
|
|
42
|
-
|
43
|
-
def
|
44
|
-
|
47
|
+
class FlagsTest < self
|
48
|
+
def test_multiple
|
49
|
+
command = column_create_command({"flags" => "COLUMN_INDEX|WITH_POSITION"})
|
50
|
+
assert_equal(["COLUMN_INDEX", "WITH_POSITION"],
|
51
|
+
command.flags)
|
45
52
|
end
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
54
|
+
def test_one
|
55
|
+
command = column_create_command({"flags" => "COLUMN_VECTOR"})
|
56
|
+
assert_equal(["COLUMN_VECTOR"],
|
57
|
+
command.flags)
|
58
|
+
end
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
60
|
+
def test_no_flags
|
61
|
+
command = column_create_command({})
|
62
|
+
assert_equal([], command.flags)
|
63
|
+
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
65
|
+
class PredicateTest < self
|
66
|
+
data({
|
67
|
+
"COLUMN_SCALAR" => {
|
68
|
+
:expected => true,
|
69
|
+
:flags => "COLUMN_SCALAR",
|
70
|
+
},
|
71
|
+
"other flag" => {
|
72
|
+
:expected => false,
|
73
|
+
:flags => "COLUMN_VECTOR",
|
74
|
+
}
|
75
|
+
})
|
76
|
+
def test_column_scalar?(data)
|
77
|
+
command = column_create_command({"flags" => data[:flags]})
|
78
|
+
assert_equal(data[:expected], command.column_scalar?)
|
63
79
|
end
|
64
80
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
data({
|
82
|
-
"COLUMN_VECTOR" => {
|
83
|
-
:expected => true,
|
84
|
-
:flags => "COLUMN_VECTOR",
|
85
|
-
},
|
86
|
-
"other flag" => {
|
87
|
-
:expected => false,
|
88
|
-
:flags => "COLUMN_INDEX",
|
89
|
-
}
|
90
|
-
})
|
91
|
-
def test_column_vector?(data)
|
92
|
-
command = parse({"flags" => data[:flags]})
|
93
|
-
assert_equal(data[:expected], command.column_vector?)
|
94
|
-
end
|
81
|
+
data({
|
82
|
+
"COLUMN_VECTOR" => {
|
83
|
+
:expected => true,
|
84
|
+
:flags => "COLUMN_VECTOR",
|
85
|
+
},
|
86
|
+
"other flag" => {
|
87
|
+
:expected => false,
|
88
|
+
:flags => "COLUMN_INDEX",
|
89
|
+
}
|
90
|
+
})
|
91
|
+
def test_column_vector?(data)
|
92
|
+
command = column_create_command({"flags" => data[:flags]})
|
93
|
+
assert_equal(data[:expected], command.column_vector?)
|
94
|
+
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
96
|
+
data({
|
97
|
+
"COLUMN_INDEX" => {
|
98
|
+
:expected => true,
|
99
|
+
:flags => "COLUMN_INDEX",
|
100
|
+
},
|
101
|
+
"other flag" => {
|
102
|
+
:expected => false,
|
103
|
+
:flags => "COLUMN_SCALAR",
|
104
|
+
}
|
105
|
+
})
|
106
|
+
def test_column_index?(data)
|
107
|
+
command = column_create_command({"flags" => data[:flags]})
|
108
|
+
assert_equal(data[:expected], command.column_index?)
|
109
|
+
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
111
|
+
data({
|
112
|
+
"WITH_SECTION" => {
|
113
|
+
:expected => true,
|
114
|
+
:flags => "COLUMN_INDEX|WITH_SECTION",
|
115
|
+
},
|
116
|
+
"other flag" => {
|
117
|
+
:expected => false,
|
118
|
+
:flags => "COLUMN_INDEX|WITH_WEIGHT",
|
119
|
+
}
|
120
|
+
})
|
121
|
+
def test_with_section?(data)
|
122
|
+
command = column_create_command({"flags" => data[:flags]})
|
123
|
+
assert_equal(data[:expected], command.with_section?)
|
124
|
+
end
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
126
|
+
data({
|
127
|
+
"WITH_WEIGHT" => {
|
128
|
+
:expected => true,
|
129
|
+
:flags => "COLUMN_INDEX|WITH_WEIGHT",
|
130
|
+
},
|
131
|
+
"other flag" => {
|
132
|
+
:expected => false,
|
133
|
+
:flags => "COLUMN_INDEX|WITH_POSITION",
|
134
|
+
}
|
135
|
+
})
|
136
|
+
def test_with_weight?(data)
|
137
|
+
command = column_create_command({"flags" => data[:flags]})
|
138
|
+
assert_equal(data[:expected], command.with_weight?)
|
139
|
+
end
|
140
140
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
end
|
141
|
+
data({
|
142
|
+
"WITH_POSITION" => {
|
143
|
+
:expected => true,
|
144
|
+
:flags => "COLUMN_INDEX|WITH_POSITION",
|
145
|
+
},
|
146
|
+
"other flag" => {
|
147
|
+
:expected => false,
|
148
|
+
:flags => "COLUMN_INDEX|WITH_SECTION",
|
149
|
+
}
|
150
|
+
})
|
151
|
+
def test_with_position?(data)
|
152
|
+
command = column_create_command({"flags" => data[:flags]})
|
153
|
+
assert_equal(data[:expected], command.with_position?)
|
155
154
|
end
|
156
155
|
end
|
157
156
|
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
|
@@ -17,25 +17,24 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
class ColumnRemoveCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
20
|
+
private
|
21
|
+
def column_remove_command(pair_arguments={}, ordered_arguments=[])
|
22
|
+
Groonga::Command::ColumnRemove.new("column_remove",
|
23
|
+
pair_arguments,
|
24
|
+
ordered_arguments)
|
25
|
+
end
|
22
26
|
|
27
|
+
class ConstructorTest < self
|
23
28
|
def test_ordered_arguments
|
24
29
|
table = "Users"
|
25
30
|
name = "age"
|
26
31
|
|
27
|
-
command =
|
28
|
-
assert_instance_of(Groonga::Command::ColumnRemove, command)
|
32
|
+
command = column_remove_command({}, [table, name])
|
29
33
|
assert_equal({
|
30
34
|
:table => table,
|
31
35
|
:name => name,
|
32
36
|
},
|
33
37
|
command.arguments)
|
34
38
|
end
|
35
|
-
|
36
|
-
private
|
37
|
-
def parse(*arguments)
|
38
|
-
super("column_remove", arguments, :output_type => false)
|
39
|
-
end
|
40
39
|
end
|
41
40
|
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
|
@@ -17,16 +17,20 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
class ColumnRenameCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
20
|
+
private
|
21
|
+
def column_rename_command(pair_arguments={}, ordered_arguments=[])
|
22
|
+
Groonga::Command::ColumnRename.new("column_rename",
|
23
|
+
pair_arguments,
|
24
|
+
ordered_arguments)
|
25
|
+
end
|
22
26
|
|
27
|
+
class ConstructorTest < self
|
23
28
|
def test_ordered_arguments
|
24
29
|
table = "Users"
|
25
30
|
name = "name"
|
26
31
|
new_name = "nick"
|
27
32
|
|
28
|
-
command =
|
29
|
-
assert_instance_of(Groonga::Command::ColumnRename, command)
|
33
|
+
command = column_rename_command({}, [table, name, new_name])
|
30
34
|
assert_equal({
|
31
35
|
:table => table,
|
32
36
|
:name => name,
|
@@ -34,10 +38,5 @@ class ColumnRenameCommandTest < Test::Unit::TestCase
|
|
34
38
|
},
|
35
39
|
command.arguments)
|
36
40
|
end
|
37
|
-
|
38
|
-
private
|
39
|
-
def parse(*arguments)
|
40
|
-
super("column_rename", arguments, :output_type => false)
|
41
|
-
end
|
42
41
|
end
|
43
42
|
end
|
data/test/command/test-delete.rb
CHANGED
@@ -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
|
@@ -17,17 +17,21 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
class DeleteCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
20
|
+
private
|
21
|
+
def delete_command(pair_arguments={}, ordered_arguments=[])
|
22
|
+
Groonga::Command::Delete.new("delete",
|
23
|
+
pair_arguments,
|
24
|
+
ordered_arguments)
|
25
|
+
end
|
22
26
|
|
27
|
+
class ConstructorTest < self
|
23
28
|
def test_ordered_arguments
|
24
29
|
table = "Users"
|
25
30
|
key = "Alice"
|
26
31
|
id = "29"
|
27
32
|
filter = "age == 20"
|
28
33
|
|
29
|
-
command =
|
30
|
-
assert_instance_of(Groonga::Command::Delete, command)
|
34
|
+
command = delete_command({}, [table, key, id, filter])
|
31
35
|
assert_equal({
|
32
36
|
:table => table,
|
33
37
|
:key => key,
|
@@ -36,10 +40,5 @@ class DeleteCommandTest < Test::Unit::TestCase
|
|
36
40
|
},
|
37
41
|
command.arguments)
|
38
42
|
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def parse(*arguments)
|
42
|
-
super("delete", arguments, :output_type => false)
|
43
|
-
end
|
44
43
|
end
|
45
44
|
end
|
data/test/command/test-dump.rb
CHANGED
@@ -17,14 +17,14 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
class DumpCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
assert_equal(:none, command.output_type)
|
20
|
+
private
|
21
|
+
def dump_command(pair_arguments={}, ordered_arguments=[])
|
22
|
+
Groonga::Command::Dump.new("dump", pair_arguments, ordered_arguments)
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
class OutputTypeTest < self
|
26
|
+
def test_none
|
27
|
+
assert_equal(:none, dump_command.output_type)
|
28
|
+
end
|
29
29
|
end
|
30
30
|
end
|
data/test/command/test-get.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
+
# Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
|
3
4
|
# Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
|
4
5
|
#
|
5
6
|
# This library is free software; you can redistribute it and/or
|
@@ -17,28 +18,24 @@
|
|
17
18
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
19
|
|
19
20
|
class GetCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
21
|
+
private
|
22
|
+
def get_command(pair_arguments={}, ordered_arguments=[])
|
23
|
+
Groonga::Command::Get.new("get", pair_arguments, ordered_arguments)
|
24
|
+
end
|
22
25
|
|
26
|
+
class ConstructorTest < self
|
23
27
|
def test_ordered_arguments
|
24
28
|
table = "Users"
|
25
29
|
key = "Alice"
|
26
30
|
output_columns = "name, address"
|
27
31
|
|
28
|
-
command =
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
36
|
-
assert_equal(expected_arguments, command.arguments)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
def parse(*arguments)
|
41
|
-
super("get", arguments, :output_type => false)
|
32
|
+
command = get_command({}, [table, key, output_columns])
|
33
|
+
assert_equal({
|
34
|
+
:table => table,
|
35
|
+
:key => key,
|
36
|
+
:output_columns => output_columns,
|
37
|
+
},
|
38
|
+
command.arguments)
|
42
39
|
end
|
43
40
|
end
|
44
41
|
end
|
data/test/command/test-load.rb
CHANGED
@@ -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
|
@@ -17,9 +17,14 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
class LoadCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
20
|
+
private
|
21
|
+
def load_command(pair_arguments={}, ordered_arguments=[])
|
22
|
+
Groonga::Command::Load.new("load",
|
23
|
+
pair_arguments,
|
24
|
+
ordered_arguments)
|
25
|
+
end
|
22
26
|
|
27
|
+
class ConstructorTest < self
|
23
28
|
def test_ordered_arguments
|
24
29
|
values = "[[\"Alice\"], [\"Bob\"]]"
|
25
30
|
table = "Users"
|
@@ -28,8 +33,15 @@ class LoadCommandTest < Test::Unit::TestCase
|
|
28
33
|
input_type = "json"
|
29
34
|
each = "strlen(_key)"
|
30
35
|
|
31
|
-
|
32
|
-
|
36
|
+
ordered_arguments = [
|
37
|
+
values,
|
38
|
+
table,
|
39
|
+
columns,
|
40
|
+
ifexists,
|
41
|
+
input_type,
|
42
|
+
each,
|
43
|
+
]
|
44
|
+
command = load_command({}, ordered_arguments)
|
33
45
|
assert_equal({
|
34
46
|
:values => values,
|
35
47
|
:table => table,
|
@@ -40,10 +52,5 @@ class LoadCommandTest < Test::Unit::TestCase
|
|
40
52
|
},
|
41
53
|
command.arguments)
|
42
54
|
end
|
43
|
-
|
44
|
-
private
|
45
|
-
def parse(*arguments)
|
46
|
-
super("load", arguments, :output_type => false)
|
47
|
-
end
|
48
55
|
end
|
49
56
|
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
|
@@ -17,23 +17,22 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
18
|
|
19
19
|
class RegisterCommandTest < Test::Unit::TestCase
|
20
|
-
|
21
|
-
|
20
|
+
private
|
21
|
+
def register_command(pair_arguments={}, ordered_arguments=[])
|
22
|
+
Groonga::Command::Register.new("register",
|
23
|
+
pair_arguments,
|
24
|
+
ordered_arguments)
|
25
|
+
end
|
22
26
|
|
27
|
+
class ConstructorTest < self
|
23
28
|
def test_ordered_arguments
|
24
29
|
path = "tokenizers/mecab"
|
25
30
|
|
26
|
-
command =
|
27
|
-
assert_instance_of(Groonga::Command::Register, command)
|
31
|
+
command = register_command({}, [path])
|
28
32
|
assert_equal({
|
29
33
|
:path => path,
|
30
34
|
},
|
31
35
|
command.arguments)
|
32
36
|
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def parse(*arguments)
|
36
|
-
super("register", arguments, :output_type => false)
|
37
|
-
end
|
38
37
|
end
|
39
38
|
end
|