fleet 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fleet.rb +4 -2
- metadata +1 -1
data/lib/fleet.rb
CHANGED
@@ -6,14 +6,16 @@ class Fleet
|
|
6
6
|
@host = host
|
7
7
|
@port = port
|
8
8
|
@socket = TCPSocket.new(host, port)
|
9
|
+
@json_encoder = Yajl::Encoder
|
10
|
+
@json_parser = Yajl::Parser
|
9
11
|
end
|
10
12
|
|
11
13
|
def query(q)
|
12
|
-
request =
|
14
|
+
request = @json_encoder.encode(q)
|
13
15
|
@socket.write(request)
|
14
16
|
@socket.write("\r\n")
|
15
17
|
response = @socket.gets
|
16
|
-
status, value =
|
18
|
+
status, value = @json_parser.parse(response)
|
17
19
|
status == 0 ? value : raise(value)
|
18
20
|
end
|
19
21
|
|