fleet 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/fleet.rb +14 -2
  2. metadata +1 -1
data/lib/fleet.rb CHANGED
@@ -2,8 +2,10 @@ require "socket"
2
2
  require "yajl"
3
3
  require "system_timer"
4
4
 
5
-
6
5
  class Fleet
6
+ class ClientError < StandardError ; end
7
+ class ServerError < StandardError ; end
8
+
7
9
  def initialize(options = {})
8
10
  @host = options[:host] || "127.0.0.1"
9
11
  @port = options[:port] || 3400
@@ -18,7 +20,14 @@ class Fleet
18
20
  request = @json_encoder.encode(q)
19
21
  response = write_and_read_with_retry(request)
20
22
  status, value = @json_parser.parse(response)
21
- status == 0 ? value : raise(value)
23
+ case status
24
+ when 0
25
+ value
26
+ when 1
27
+ raise ClientError, value
28
+ else
29
+ raise ServerError, value
30
+ end
22
31
  end
23
32
 
24
33
  def close
@@ -38,6 +47,9 @@ class Fleet
38
47
  socket.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
39
48
  socket
40
49
  end
50
+ if @password
51
+ query(["auth", @password]).inspect
52
+ end
41
53
  end
42
54
 
43
55
  def disconnect
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fleet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark McGranaghan