fleet 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -2
- data/lib/fleet.rb +4 -4
- metadata +1 -1
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Download and start FleetDB as described in the [FleetDB getting started guide](h
|
|
13
13
|
require "rubygems"
|
14
14
|
require "fleet"
|
15
15
|
|
16
|
-
client = Fleet.new
|
16
|
+
client = Fleet.new
|
17
17
|
|
18
18
|
client.query(["ping"])
|
19
19
|
#=> "pong"
|
@@ -25,6 +25,9 @@ The client will raise an exception in the case of an error:
|
|
25
25
|
|
26
26
|
client.query(["bogus"])
|
27
27
|
RuntimeError: Malformed query: unrecognized query type '"bogus"'
|
28
|
-
|
28
|
+
|
29
|
+
You can optionally specify a host and port other than the default `"127.0.0.1"` and `3400`:
|
30
|
+
|
31
|
+
client = Fleet.new(:host => "68.127.150.103", :port => 3401)
|
29
32
|
|
30
33
|
See the [FleetDB getting started guide](http://fleetdb.org/docs/getting_started.html) and the [FleetDB query reference](http://fleetdb.org/docs/queries.html) for documentation on the queries available to clients.
|
data/lib/fleet.rb
CHANGED
@@ -2,10 +2,10 @@ require "socket"
|
|
2
2
|
require "yajl"
|
3
3
|
|
4
4
|
class Fleet
|
5
|
-
def initialize(
|
6
|
-
@host = host
|
7
|
-
@port = port
|
8
|
-
@socket = TCPSocket.new(host, port)
|
5
|
+
def initialize(options = {})
|
6
|
+
@host = options[:host] || "127.0.0.1"
|
7
|
+
@port = options[:port] || 3400
|
8
|
+
@socket = TCPSocket.new(@host, @port)
|
9
9
|
@json_encoder = Yajl::Encoder
|
10
10
|
@json_parser = Yajl::Parser
|
11
11
|
end
|