groonga-command 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -16,6 +16,6 @@
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
- source :rubygems
19
+ source "https://rubygems.org/"
20
20
 
21
21
  gemspec
data/doc/text/news.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # News
2
2
 
3
+ ## 1.0.3: 2013-07-23
4
+
5
+ ### Improvements
6
+
7
+ * Added predicate methods of table_create flags
8
+ to {Groonga::Command::TableCreate}
9
+ * {Groonga::Command::TableCreate#table_no_key?}
10
+ * {Groonga::Command::TableCreate#table_hash_key?}
11
+ * {Groonga::Command::TableCreate#table_pat_key?}
12
+ * {Groonga::Command::TableCreate#table_dat_key?}
13
+ * {Groonga::Command::TableCreate#key_with_sis?}
14
+ * Added predicate methods of column_create flags
15
+ to {Groonga::Command::ColumnCreate}
16
+ * {Groonga::Command::ColumnCreate#column_scalar?}
17
+ * {Groonga::Command::ColumnCreate#column_vector?}
18
+ * {Groonga::Command::ColumnCreate#column_index?}
19
+ * {Groonga::Command::ColumnCreate#with_section?}
20
+ * {Groonga::Command::ColumnCreate#with_weight?}
21
+ * {Groonga::Command::ColumnCreate#with_position?}
22
+
3
23
  ## 1.0.2: 2013-06-27
4
24
 
5
25
  ### Improvements
@@ -34,6 +34,52 @@ module Groonga
34
34
  ]
35
35
  end
36
36
  end
37
+
38
+ def flags
39
+ @flags ||= (self[:flags] || "").split(/\s*\|\s*/)
40
+ end
41
+
42
+ # @return [Boolean] true if "COLUMN_SCALAR" is specified in {#flags},
43
+ # false otherwise.
44
+ # @since 1.0.3
45
+ def column_scalar?
46
+ flags.include?("COLUMN_SCALAR")
47
+ end
48
+
49
+ # @return [Boolean] true if "COLUMN_VECTOR" is specified in {#flags},
50
+ # false otherwise.
51
+ # @since 1.0.3
52
+ def column_vector?
53
+ flags.include?("COLUMN_VECTOR")
54
+ end
55
+
56
+ # @return [Boolean] true if "COLUMN_INDEX" is specified in {#flags},
57
+ # false otherwise.
58
+ # @since 1.0.3
59
+ def column_index?
60
+ flags.include?("COLUMN_INDEX")
61
+ end
62
+
63
+ # @return [Boolean] true if "WITH_SECTION" is specified in {#flags},
64
+ # false otherwise.
65
+ # @since 1.0.3
66
+ def with_section?
67
+ flags.include?("WITH_SECTION")
68
+ end
69
+
70
+ # @return [Boolean] true if "WITH_WEIGHT" is specified in {#flags},
71
+ # false otherwise.
72
+ # @since 1.0.3
73
+ def with_weight?
74
+ flags.include?("WITH_WEIGHT")
75
+ end
76
+
77
+ # @return [Boolean] true if "WITH_POSITION" is specified in {#flags},
78
+ # false otherwise.
79
+ # @since 1.0.3
80
+ def with_position?
81
+ flags.include?("WITH_POSITION")
82
+ end
37
83
  end
38
84
  end
39
85
  end
@@ -34,6 +34,45 @@ module Groonga
34
34
  ]
35
35
  end
36
36
  end
37
+
38
+ def flags
39
+ @flags ||= (self[:flags] || "").split(/\s*\|\s*/)
40
+ end
41
+
42
+ # @return [Boolean] true if "TABLE_NO_KEY" is specified in {#flags},
43
+ # false otherwise.
44
+ # @since 1.0.3
45
+ def table_no_key?
46
+ flags.include?("TABLE_NO_KEY")
47
+ end
48
+
49
+ # @return [Boolean] true if "TABLE_HASH_KEY" is specified in {#flags},
50
+ # false otherwise.
51
+ # @since 1.0.3
52
+ def table_hash_key?
53
+ flags.include?("TABLE_HASH_KEY")
54
+ end
55
+
56
+ # @return [Boolean] true if "TABLE_PAT_KEY" is specified in {#flags},
57
+ # false otherwise.
58
+ # @since 1.0.3
59
+ def table_pat_key?
60
+ flags.include?("TABLE_PAT_KEY")
61
+ end
62
+
63
+ # @return [Boolean] true if "TABLE_DAT_KEY" is specified in {#flags},
64
+ # false otherwise.
65
+ # @since 1.0.3
66
+ def table_dat_key?
67
+ flags.include?("TABLE_DAT_KEY")
68
+ end
69
+
70
+ # @return [Boolean] true if "KEY_WITH_SIS" is specified in {#flags},
71
+ # false otherwise.
72
+ # @since 1.0.3
73
+ def key_with_sis?
74
+ flags.include?("KEY_WITH_SIS")
75
+ end
37
76
  end
38
77
  end
39
78
  end
@@ -18,6 +18,6 @@
18
18
 
19
19
  module Groonga
20
20
  module Command
21
- VERSION = "1.0.2"
21
+ VERSION = "1.0.3"
22
22
  end
23
23
  end
@@ -27,7 +27,7 @@ class ColumnCreateCommandTest < Test::Unit::TestCase
27
27
  type = "Posts"
28
28
  source = "content"
29
29
 
30
- command = parse(table, name, flags, type, source)
30
+ command = parse([table, name, flags, type, source])
31
31
  assert_instance_of(Groonga::Command::ColumnCreate, command)
32
32
  assert_equal({
33
33
  :table => table,
@@ -40,8 +40,119 @@ class ColumnCreateCommandTest < Test::Unit::TestCase
40
40
  end
41
41
 
42
42
  private
43
- def parse(*arguments)
43
+ def parse(arguments)
44
44
  super("column_create", arguments, :output_type => false)
45
45
  end
46
+
47
+ class FlagsTest < self
48
+ def test_multiple
49
+ command = parse({"flags" => "COLUMN_INDEX|WITH_POSITION"})
50
+ assert_equal(["COLUMN_INDEX", "WITH_POSITION"],
51
+ command.flags)
52
+ end
53
+
54
+ def test_one
55
+ command = parse({"flags" => "COLUMN_VECTOR"})
56
+ assert_equal(["COLUMN_VECTOR"],
57
+ command.flags)
58
+ end
59
+
60
+ def test_no_flags
61
+ command = parse({})
62
+ assert_equal([], command.flags)
63
+ end
64
+
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 = parse({"flags" => data[:flags]})
78
+ assert_equal(data[:expected], command.column_scalar?)
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
95
+
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 = parse({"flags" => data[:flags]})
108
+ assert_equal(data[:expected], command.column_index?)
109
+ end
110
+
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 = parse({"flags" => data[:flags]})
123
+ assert_equal(data[:expected], command.with_section?)
124
+ end
125
+
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 = parse({"flags" => data[:flags]})
138
+ assert_equal(data[:expected], command.with_weight?)
139
+ end
140
+
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 = parse({"flags" => data[:flags]})
153
+ assert_equal(data[:expected], command.with_position?)
154
+ end
155
+ end
156
+ end
46
157
  end
47
158
  end
@@ -27,8 +27,7 @@ class TableCreateCommandTest < Test::Unit::TestCase
27
27
  value_type = "UInt32"
28
28
  default_tokenizer = "TokenBigram"
29
29
 
30
- command = parse(name, flags, key_type, value_type,
31
- default_tokenizer)
30
+ command = parse([name, flags, key_type, value_type, default_tokenizer])
32
31
  assert_instance_of(Groonga::Command::TableCreate, command)
33
32
  assert_equal({
34
33
  :name => name,
@@ -41,8 +40,104 @@ class TableCreateCommandTest < Test::Unit::TestCase
41
40
  end
42
41
 
43
42
  private
44
- def parse(*arguments)
43
+ def parse(arguments)
45
44
  super("table_create", arguments, :output_type => false)
46
45
  end
46
+
47
+ class FlagsTest < self
48
+ def test_multiple
49
+ command = parse({"flags" => "TABLE_PAT_KEY|KEY_WITH_SIS"})
50
+ assert_equal(["TABLE_PAT_KEY", "KEY_WITH_SIS"],
51
+ command.flags)
52
+ end
53
+
54
+ def test_one
55
+ command = parse({"flags" => "TABLE_NO_KEY"})
56
+ assert_equal(["TABLE_NO_KEY"],
57
+ command.flags)
58
+ end
59
+
60
+ def test_no_flags
61
+ command = parse({})
62
+ assert_equal([], command.flags)
63
+ end
64
+
65
+ class PredicateTest < self
66
+ data({
67
+ "TABLE_NO_KEY" => {
68
+ :expected => true,
69
+ :flags => "TABLE_NO_KEY",
70
+ },
71
+ "other flag" => {
72
+ :expected => false,
73
+ :flags => "TABLE_HASH_KEY",
74
+ }
75
+ })
76
+ def test_table_no_key?(data)
77
+ command = parse({"flags" => data[:flags]})
78
+ assert_equal(data[:expected], command.table_no_key?)
79
+ end
80
+
81
+ data({
82
+ "TABLE_HASH_KEY" => {
83
+ :expected => true,
84
+ :flags => "TABLE_HASH_KEY",
85
+ },
86
+ "other flag" => {
87
+ :expected => false,
88
+ :flags => "TABLE_PAT_KEY",
89
+ }
90
+ })
91
+ def test_table_hash_key?(data)
92
+ command = parse({"flags" => data[:flags]})
93
+ assert_equal(data[:expected], command.table_hash_key?)
94
+ end
95
+
96
+ data({
97
+ "TABLE_PAT_KEY" => {
98
+ :expected => true,
99
+ :flags => "TABLE_PAT_KEY",
100
+ },
101
+ "other flag" => {
102
+ :expected => false,
103
+ :flags => "TABLE_DAT_KEY",
104
+ }
105
+ })
106
+ def test_table_pat_key?(data)
107
+ command = parse({"flags" => data[:flags]})
108
+ assert_equal(data[:expected], command.table_pat_key?)
109
+ end
110
+
111
+ data({
112
+ "TABLE_DAT_KEY" => {
113
+ :expected => true,
114
+ :flags => "TABLE_DAT_KEY",
115
+ },
116
+ "other flag" => {
117
+ :expected => false,
118
+ :flags => "TABLE_NO_KEY",
119
+ }
120
+ })
121
+ def test_table_dat_key?(data)
122
+ command = parse({"flags" => data[:flags]})
123
+ assert_equal(data[:expected], command.table_dat_key?)
124
+ end
125
+
126
+ data({
127
+ "KEY_WITH_SIS" => {
128
+ :expected => true,
129
+ :flags => "KEY_WITH_SIS|TABLE_PAT_KEY",
130
+ },
131
+ "other flag" => {
132
+ :expected => false,
133
+ :flags => "TABLE_NO_KEY",
134
+ }
135
+ })
136
+ def test_key_with_sis?(data)
137
+ command = parse({"flags" => data[:flags]})
138
+ assert_equal(data[:expected], command.key_with_sis?)
139
+ end
140
+ end
141
+ end
47
142
  end
48
143
  end
metadata CHANGED
@@ -1,125 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groonga-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
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-06-27 00:00:00.000000000 Z
12
+ date: 2013-07-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: yajl-ruby
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: test-unit
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: test-unit-notify
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: bundler
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: packnga
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - '>='
99
+ - - ! '>='
88
100
  - !ruby/object:Gem::Version
89
101
  version: '0'
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - '>='
107
+ - - ! '>='
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: yard
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - '>='
115
+ - - ! '>='
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - '>='
123
+ - - ! '>='
109
124
  - !ruby/object:Gem::Version
110
125
  version: '0'
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: redcarpet
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - '>='
131
+ - - ! '>='
116
132
  - !ruby/object:Gem::Version
117
133
  version: '0'
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - '>='
139
+ - - ! '>='
123
140
  - !ruby/object:Gem::Version
124
141
  version: '0'
125
142
  description: ''
@@ -176,26 +193,27 @@ files:
176
193
  homepage: https://github.com/groonga/groonga-command
177
194
  licenses:
178
195
  - LGPLv2.1+
179
- metadata: {}
180
196
  post_install_message:
181
197
  rdoc_options: []
182
198
  require_paths:
183
199
  - lib
184
200
  required_ruby_version: !ruby/object:Gem::Requirement
201
+ none: false
185
202
  requirements:
186
- - - '>='
203
+ - - ! '>='
187
204
  - !ruby/object:Gem::Version
188
205
  version: '0'
189
206
  required_rubygems_version: !ruby/object:Gem::Requirement
207
+ none: false
190
208
  requirements:
191
- - - '>='
209
+ - - ! '>='
192
210
  - !ruby/object:Gem::Version
193
211
  version: '0'
194
212
  requirements: []
195
213
  rubyforge_project:
196
- rubygems_version: 2.0.2
214
+ rubygems_version: 1.8.23
197
215
  signing_key:
198
- specification_version: 4
216
+ specification_version: 3
199
217
  summary: Groonga-command is a library to process [groonga](http://groonga.org/)'s
200
218
  command syntax. You can write a program to process groonga's command by using groonga-command.
201
219
  test_files:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: cfe3f7636980048811df9b36b3553cf2b868cf2c
4
- data.tar.gz: 8d48249afba06e16dd6165091d4b016a6488e77e
5
- SHA512:
6
- metadata.gz: 549c80ac84a5023436fae2fdb6ca1dc846658749ef2adec2db3e658573d1df13393c61e37e7a3b41ebef72caae763d9106d89d414b180aeeb31b156b903e7e96
7
- data.tar.gz: 8f32bb87c46960b0623ed3501d0ad5ed6d432b8571dfdc6a464908dbc214dad4a16fad54c1ae0dd154e4abe8dc83ba8af8fc68d85ed3a40cfd71dc19a348eb0e