groonga-client 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -10
- data/doc/text/news.md +10 -0
- data/lib/groonga/client/response/base.rb +25 -0
- data/lib/groonga/client/response/error.rb +5 -0
- data/lib/groonga/client/version.rb +1 -1
- data/test/response/test-base.rb +95 -0
- data/test/response/test-error.rb +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24d9b067756feca3932e30fc97c2b30b51f164d1
|
4
|
+
data.tar.gz: 007f34f0eb3767476411ef0cf30cf367fc4de47a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67cff454d8de8faecb954f4151aa5187db57da7b0e087df24ab5d3da9221629e38a2a93151ec2a699482762c2e8240413eb0d4e739fa2c93b6c1d7f643f9dde7
|
7
|
+
data.tar.gz: 66c4c1282b138064e7e6b2613f684d5448c65a155e3831670a94ac4ab045a9bbdac135c800d7082bb7d7349154b8d125df6a92e83e8e933ff0eeed9e10354508
|
data/README.md
CHANGED
@@ -25,21 +25,21 @@ TODO: use commands with parameters for examples
|
|
25
25
|
|
26
26
|
### GQTP
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
Groonga::Client.open(:host => host, :port => port, :protocol => :gqtp) do |client|
|
29
|
+
tables = client.table_list
|
30
|
+
tables.each do |table|
|
31
|
+
table.name
|
32
|
+
end
|
32
33
|
end
|
33
|
-
end
|
34
34
|
|
35
35
|
### HTTP
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
Groonga::Client.open(:host => host, :port => port, :protocol => :http) do |client|
|
38
|
+
tables = client.table_list
|
39
|
+
tables.each do |table|
|
40
|
+
table.name
|
41
|
+
end
|
41
42
|
end
|
42
|
-
end
|
43
43
|
|
44
44
|
## Dependencies
|
45
45
|
|
data/doc/text/news.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# NEWS
|
2
2
|
|
3
|
+
## 0.1.0 - 2014-11-05
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* response: Added {Groonga::Client::Response::Error#message}.
|
8
|
+
* response: Added {Groonga::Client::Response::Base#status_code}.
|
9
|
+
* response: Added {Groonga::Client::Response::Base#start_time}.
|
10
|
+
* response: Added {Groonga::Client::Response::Base#elapsed_time}.
|
11
|
+
* response: Added {Groonga::Client::Response::Base#success?}.
|
12
|
+
|
3
13
|
## 0.0.9 - 2014-09-30
|
4
14
|
|
5
15
|
### Improvements
|
@@ -142,6 +142,31 @@ module Groonga
|
|
142
142
|
self.body = body
|
143
143
|
self.raw = nil
|
144
144
|
end
|
145
|
+
|
146
|
+
# @return [Integer] The status code of the response.
|
147
|
+
# @since 0.1.0
|
148
|
+
def status_code
|
149
|
+
(header || [0])[0]
|
150
|
+
end
|
151
|
+
|
152
|
+
# @return [Time] The time of the request is accepted.
|
153
|
+
# @since 0.1.0
|
154
|
+
def start_time
|
155
|
+
Time.at((header || [0, 0])[1])
|
156
|
+
end
|
157
|
+
|
158
|
+
# @return [Time] The elapsed time of the request.
|
159
|
+
# @since 0.1.0
|
160
|
+
def elapsed_time
|
161
|
+
(header || [0, 0, 0.0])[2]
|
162
|
+
end
|
163
|
+
|
164
|
+
# @return [Boolean] `true` if the request is processed successfully,
|
165
|
+
# `false` otherwise.
|
166
|
+
# @since 0.1.0
|
167
|
+
def success?
|
168
|
+
status_code.zero?
|
169
|
+
end
|
145
170
|
end
|
146
171
|
end
|
147
172
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Copyright (C) 2014 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 "response/helper"
|
18
|
+
|
19
|
+
class TestResponseBase < Test::Unit::TestCase
|
20
|
+
class TestHeader < self
|
21
|
+
class TestStatusCode < self
|
22
|
+
def test_have_header
|
23
|
+
header = [
|
24
|
+
-21,
|
25
|
+
1396012478.14975,
|
26
|
+
0.00050806999206543,
|
27
|
+
]
|
28
|
+
response = Groonga::Client::Response::Base.new(nil, header, nil)
|
29
|
+
assert_equal(-21, response.status_code)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_no_header
|
33
|
+
response = Groonga::Client::Response::Error.new(nil, nil, nil)
|
34
|
+
assert_equal(0, response.status_code)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class TestStartTime < self
|
39
|
+
def test_have_header
|
40
|
+
start_time = 1396012478.14975
|
41
|
+
header = [
|
42
|
+
-21,
|
43
|
+
start_time,
|
44
|
+
0.00050806999206543,
|
45
|
+
]
|
46
|
+
response = Groonga::Client::Response::Base.new(nil, header, nil)
|
47
|
+
assert_equal(Time.at(start_time), response.start_time)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_no_header
|
51
|
+
response = Groonga::Client::Response::Error.new(nil, nil, nil)
|
52
|
+
assert_equal(Time.at(0), response.start_time)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class TestElapsedTime < self
|
57
|
+
def test_have_header
|
58
|
+
elapsed_time = 0.00050806999206543
|
59
|
+
header = [
|
60
|
+
-21,
|
61
|
+
1396012478.14975,
|
62
|
+
elapsed_time,
|
63
|
+
]
|
64
|
+
response = Groonga::Client::Response::Base.new(nil, header, nil)
|
65
|
+
assert_equal(elapsed_time, response.elapsed_time)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_no_header
|
69
|
+
response = Groonga::Client::Response::Error.new(nil, nil, nil)
|
70
|
+
assert_equal(0.0, response.elapsed_time)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class TestSuccess < self
|
75
|
+
def test_have_header
|
76
|
+
header = [
|
77
|
+
-21,
|
78
|
+
1396012478.14975,
|
79
|
+
0.00050806999206543,
|
80
|
+
]
|
81
|
+
response = Groonga::Client::Response::Base.new(nil, header, nil)
|
82
|
+
assert do
|
83
|
+
not response.success?
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_no_header
|
88
|
+
response = Groonga::Client::Response::Error.new(nil, nil, nil)
|
89
|
+
assert do
|
90
|
+
response.success?
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/test/response/test-error.rb
CHANGED
@@ -36,4 +36,26 @@ class TestResponseError < Test::Unit::TestCase
|
|
36
36
|
assert_equal(Groonga::Client::Response::Error, response.class)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
class TestMessage < self
|
41
|
+
def test_have_header
|
42
|
+
header = [
|
43
|
+
-22,
|
44
|
+
1396012478.14975,
|
45
|
+
0.00050806999206543,
|
46
|
+
"invalid table name: <Nonexistent>",
|
47
|
+
[
|
48
|
+
["grn_select", "proc.c", 897],
|
49
|
+
],
|
50
|
+
]
|
51
|
+
response = Groonga::Client::Response::Error.new(nil, header, nil)
|
52
|
+
assert_equal("invalid table name: <Nonexistent>",
|
53
|
+
response.message)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_no_header
|
57
|
+
response = Groonga::Client::Response::Error.new(nil, nil, nil)
|
58
|
+
assert_equal("", response.message)
|
59
|
+
end
|
60
|
+
end
|
39
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groonga-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Haruka Yoshihara
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gqtp
|
@@ -194,6 +194,7 @@ files:
|
|
194
194
|
- test/protocol/test-gqtp.rb
|
195
195
|
- test/protocol/test-http.rb
|
196
196
|
- test/response/helper.rb
|
197
|
+
- test/response/test-base.rb
|
197
198
|
- test/response/test-column-list.rb
|
198
199
|
- test/response/test-error.rb
|
199
200
|
- test/response/test-select.rb
|
@@ -237,6 +238,7 @@ test_files:
|
|
237
238
|
- test/response/test-table-list.rb
|
238
239
|
- test/response/test-column-list.rb
|
239
240
|
- test/response/helper.rb
|
241
|
+
- test/response/test-base.rb
|
240
242
|
- test/response/test-status.rb
|
241
243
|
- test/results/test-table-list.rb
|
242
244
|
- test/results/test-column-list.rb
|