gibson 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -0
- data/LICENSE +28 -0
- data/README.md +105 -0
- data/Rakefile +3 -0
- data/gibson.gemspec +23 -0
- data/lib/gibson/connection.rb +83 -0
- data/lib/gibson/gibson.rb +121 -0
- data/lib/gibson/protocol.rb +89 -0
- data/lib/gibson/version.rb +30 -0
- data/lib/gibson.rb +27 -0
- metadata +71 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Software License Agreement (BSD License)
|
2
|
+
|
3
|
+
Copyright (c) 2013, Simone Margaritelli <evilsocket at gmail dot com>
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer.
|
11
|
+
* Redistributions in binary form must reproduce the above copyright
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
13
|
+
documentation and/or other materials provided with the distribution.
|
14
|
+
* Neither the name of Gibson nor the names of its contributors may be used
|
15
|
+
to endorse or promote products derived from this software without
|
16
|
+
specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
21
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
22
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
23
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
Ruby Gibson client
|
2
|
+
========================
|
3
|
+
|
4
|
+
A pure Ruby Gibson client library.
|
5
|
+
|
6
|
+
<http://gibson-db.in/>
|
7
|
+
|
8
|
+
Supported Ruby versions and implementations
|
9
|
+
------------------------------------------------
|
10
|
+
|
11
|
+
This module should work identically on:
|
12
|
+
|
13
|
+
* JRuby 1.6+
|
14
|
+
* Ruby 1.9.2+
|
15
|
+
* Ruby 1.8.7+
|
16
|
+
* Rubinius 2.0
|
17
|
+
|
18
|
+
If you have problems, please enter an issue.
|
19
|
+
|
20
|
+
Installation and Usage
|
21
|
+
------------------------
|
22
|
+
|
23
|
+
You can verify your installation using this piece of code:
|
24
|
+
|
25
|
+
gem install gibson
|
26
|
+
|
27
|
+
And
|
28
|
+
|
29
|
+
require 'gibson'
|
30
|
+
g = Gibson::Client.new
|
31
|
+
g.set 0, 'foo', 'bar'
|
32
|
+
p g.get 'foo'
|
33
|
+
|
34
|
+
Connection
|
35
|
+
----------
|
36
|
+
|
37
|
+
Create a Client object to start working.
|
38
|
+
|
39
|
+
require 'gibson'
|
40
|
+
|
41
|
+
gibson = Gibson::Client.new
|
42
|
+
|
43
|
+
The following options can be used in the constructor:
|
44
|
+
|
45
|
+
* **socket**: String, the path of the unix socket to connect to, default to /var/run/gibson.sock.
|
46
|
+
* **address**: String, the tcp address to connect to, setting this option will exclude the :socket option, default to nil.
|
47
|
+
* **port**: Integer, the tcp port of Gibson instance, default to 10128.
|
48
|
+
* **timeout**: Integer, timeout in milliseconds for socket I/O, default to 100.
|
49
|
+
* **keepalive**: Boolean, true to set SO_KEEPALIVE option on the tcp socket, default true.
|
50
|
+
|
51
|
+
Tcp connection example:
|
52
|
+
|
53
|
+
gibson = Gibson::Client.new :address => 'localhost'
|
54
|
+
|
55
|
+
Custom unix socket connection example with 50ms timeout:
|
56
|
+
|
57
|
+
gibson = Gibson::Client.new :socket => '/tmp/socket', :timeout => 50
|
58
|
+
|
59
|
+
Runtime Errors
|
60
|
+
--------------
|
61
|
+
|
62
|
+
Every Gibson protocol error is mapped to a RuntimeError derived class.
|
63
|
+
|
64
|
+
* **GenericError** Generic protocol error.
|
65
|
+
* **NotFoundError** Key or prefix not found.
|
66
|
+
* **NaNError** The object is not a number.
|
67
|
+
* **OutOfMemoryError** Server is out of memory.
|
68
|
+
* **LockedError** Object is locked.
|
69
|
+
|
70
|
+
Methods
|
71
|
+
-------
|
72
|
+
|
73
|
+
After connecting, you can start to make requests.
|
74
|
+
|
75
|
+
# will retrieve the 'key' value
|
76
|
+
gibson.get 'key'
|
77
|
+
|
78
|
+
# create ( or replace ) a value with a TTL of 3600 seconds.
|
79
|
+
# set the TTL to zero and the value will never expire.
|
80
|
+
gibson.set 3600, 'key', 'value'
|
81
|
+
|
82
|
+
# delete a key from cache.
|
83
|
+
gibson.del 'key'
|
84
|
+
|
85
|
+
# will print server stats
|
86
|
+
gibson.stats.each do |name,value|
|
87
|
+
puts "#{name}: #{value}"
|
88
|
+
end
|
89
|
+
|
90
|
+
Every available command is automatically mapped to a client method, so follow the
|
91
|
+
[official reference](http://gibson-db.in/commands.php) of Gibson commands.
|
92
|
+
|
93
|
+
Once you're done, close the connection.
|
94
|
+
|
95
|
+
gibson.close
|
96
|
+
|
97
|
+
License
|
98
|
+
---
|
99
|
+
|
100
|
+
Released under the BSD license.
|
101
|
+
Copyright © 2013, Simone Margaritelli
|
102
|
+
<evilsocket@gmail.com>
|
103
|
+
|
104
|
+
<http://www.evilsocket.net/>
|
105
|
+
All rights reserved.
|
data/Rakefile
ADDED
data/gibson.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require './lib/gibson/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{gibson}
|
5
|
+
s.version = Gibson::VERSION
|
6
|
+
s.license = "BSD"
|
7
|
+
|
8
|
+
s.authors = ["Simone Margaritelli"]
|
9
|
+
s.description = %q{High performance Gibson client for Ruby}
|
10
|
+
s.email = %q{evilsocket@gmail.com}
|
11
|
+
s.files = Dir.glob("lib/**/*") + [
|
12
|
+
"LICENSE",
|
13
|
+
"README.md",
|
14
|
+
"Rakefile",
|
15
|
+
"Gemfile",
|
16
|
+
"gibson.gemspec"
|
17
|
+
]
|
18
|
+
s.homepage = %q{http://gibson-db.in/}
|
19
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.summary = %q{High performance Gibson client for Ruby}
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Copyright (c) 2013, Simone Margaritelli <evilsocket at gmail dot com>
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of Gibson nor the names of its contributors may be used
|
13
|
+
# to endorse or promote products derived from this software without
|
14
|
+
# specific prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
20
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
module Gibson
|
28
|
+
require 'socket'
|
29
|
+
|
30
|
+
class Connection
|
31
|
+
DEFAULTS = {
|
32
|
+
:socket => '/var/run/gibson.sock',
|
33
|
+
:address => nil,
|
34
|
+
:port => 10128,
|
35
|
+
:timeout => 100,
|
36
|
+
:keepalive => false
|
37
|
+
}
|
38
|
+
|
39
|
+
def initialize(opts = {})
|
40
|
+
@sock = nil
|
41
|
+
@connected = false
|
42
|
+
@options = DEFAULTS.merge(opts)
|
43
|
+
end
|
44
|
+
|
45
|
+
def connected?
|
46
|
+
@connected
|
47
|
+
end
|
48
|
+
|
49
|
+
def connect
|
50
|
+
if @options[:address] != nil
|
51
|
+
@sock = TCPSocket.new( @options[:address], @options[:port] )
|
52
|
+
@sock.setsockopt( Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true )
|
53
|
+
@sock.setsockopt( Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true ) if @options[:keepalive]
|
54
|
+
else
|
55
|
+
@sock = UNIXSocket.open( @options[:socket] )
|
56
|
+
end
|
57
|
+
|
58
|
+
@connected = true
|
59
|
+
end
|
60
|
+
|
61
|
+
def close
|
62
|
+
@sock.close
|
63
|
+
end
|
64
|
+
|
65
|
+
def wait_writable
|
66
|
+
IO.select(nil, [@sock], nil, @options[:timeout] ) || raise(Timeout::Error, "IO timeout")
|
67
|
+
end
|
68
|
+
|
69
|
+
def wait_readable
|
70
|
+
IO.select( [@sock], nil, nil, @options[:timeout] ) || raise(Timeout::Error, "IO timeout")
|
71
|
+
end
|
72
|
+
|
73
|
+
def write(data)
|
74
|
+
wait_writable
|
75
|
+
@sock.write data
|
76
|
+
end
|
77
|
+
|
78
|
+
def read(n)
|
79
|
+
wait_readable
|
80
|
+
@sock.recv n
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# Copyright (c) 2013, Simone Margaritelli <evilsocket at gmail dot com>
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of Gibson nor the names of its contributors may be used
|
13
|
+
# to endorse or promote products derived from this software without
|
14
|
+
# specific prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
20
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
require 'gibson/protocol'
|
28
|
+
require 'gibson/connection'
|
29
|
+
|
30
|
+
module Gibson
|
31
|
+
class Client
|
32
|
+
def initialize(opts = {})
|
33
|
+
@connection = nil
|
34
|
+
@options = opts
|
35
|
+
end
|
36
|
+
|
37
|
+
def connect
|
38
|
+
@connection = Connection.new( @options )
|
39
|
+
@connection.connect
|
40
|
+
end
|
41
|
+
|
42
|
+
def decode_val( encoding, size, data )
|
43
|
+
# plain string
|
44
|
+
if encoding == Protocol::ENCODINGS[:plain]
|
45
|
+
data.unpack( 'Z' + size.to_s )[0]
|
46
|
+
# number
|
47
|
+
elsif encoding == Protocol::ENCODINGS[:number]
|
48
|
+
# 32 bit integer ?
|
49
|
+
if size == 4:
|
50
|
+
data.unpack( 'l<' )[0]
|
51
|
+
else
|
52
|
+
data.unpack( 'q<' )[0]
|
53
|
+
end
|
54
|
+
else
|
55
|
+
raise 'Unknown data encoding.'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def decode_kval( data, size )
|
60
|
+
left = size - 4
|
61
|
+
count, data = data.unpack( 'L<a' + left.to_s )
|
62
|
+
obj = {}
|
63
|
+
|
64
|
+
count.times { |i|
|
65
|
+
left -= 4
|
66
|
+
klen, data = data.unpack( 'L<a' + left.to_s )
|
67
|
+
|
68
|
+
left -= klen
|
69
|
+
key, data = data.unpack( 'a' + klen.to_s + 'a' + left.to_s )
|
70
|
+
|
71
|
+
left -= 1
|
72
|
+
enc, data = data.unpack( 'ca' + left.to_s )
|
73
|
+
|
74
|
+
left -= 4
|
75
|
+
vsize, data = data.unpack( 'L<a' + left.to_s )
|
76
|
+
|
77
|
+
left -= vsize
|
78
|
+
value, data = data.unpack( 'a' + vsize.to_s + 'a' + left.to_s )
|
79
|
+
|
80
|
+
obj[key] = decode Protocol::REPLIES[:val], enc, vsize, value
|
81
|
+
}
|
82
|
+
|
83
|
+
obj
|
84
|
+
end
|
85
|
+
|
86
|
+
def decode( code, encoding, size, data )
|
87
|
+
if code == Protocol::REPLIES[:val]
|
88
|
+
decode_val encoding, size, data
|
89
|
+
elsif code == Protocol::REPLIES[:kval]
|
90
|
+
decode_kval data, size
|
91
|
+
elsif code == Protocol::REPLIES[:ok]
|
92
|
+
true
|
93
|
+
elsif Protocol.error? code
|
94
|
+
raise Protocol::ERRORS[code]
|
95
|
+
|
96
|
+
else
|
97
|
+
data
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def query( opcode, payload = '' )
|
102
|
+
connect if @connection == nil or not @connection.connected?
|
103
|
+
|
104
|
+
psize = payload.length
|
105
|
+
packet = [ 2 + psize, opcode, payload ].pack( 'L<S<Z' + psize.to_s )
|
106
|
+
|
107
|
+
@connection.write packet
|
108
|
+
|
109
|
+
code, encoding, size = @connection.read(7).unpack('S<cL<' )
|
110
|
+
data = @connection.read size
|
111
|
+
|
112
|
+
decode code, encoding, size, data
|
113
|
+
end
|
114
|
+
|
115
|
+
def method_missing(name, *arguments)
|
116
|
+
if Protocol::COMMANDS.has_key? name
|
117
|
+
query Protocol::COMMANDS[name], arguments.join(' ')
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Copyright (c) 2013, Simone Margaritelli <evilsocket at gmail dot com>
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of Gibson nor the names of its contributors may be used
|
13
|
+
# to endorse or promote products derived from this software without
|
14
|
+
# specific prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
20
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
module Gibson
|
28
|
+
class GenericError < RuntimeError; end
|
29
|
+
class NotFoundError < RuntimeError; end
|
30
|
+
class NaNError < RuntimeError; end
|
31
|
+
class OutOfMemoryError < RuntimeError; end
|
32
|
+
class LockedError < RuntimeError; end
|
33
|
+
|
34
|
+
class Protocol
|
35
|
+
COMMANDS = {
|
36
|
+
:set => 1,
|
37
|
+
:ttl => 2,
|
38
|
+
:get => 3,
|
39
|
+
:del => 4,
|
40
|
+
:inc => 5,
|
41
|
+
:dec => 6,
|
42
|
+
:lock => 7,
|
43
|
+
:unlock => 8,
|
44
|
+
:mset => 9,
|
45
|
+
:mttl => 10,
|
46
|
+
:mget => 11,
|
47
|
+
:mdel => 12,
|
48
|
+
:minc => 13,
|
49
|
+
:mdec => 14,
|
50
|
+
:mlock => 15,
|
51
|
+
:munlock => 16,
|
52
|
+
:count => 17,
|
53
|
+
:stats => 18,
|
54
|
+
:ping => 19,
|
55
|
+
:meta => 20,
|
56
|
+
:keys => 21,
|
57
|
+
:end => 0xff
|
58
|
+
}
|
59
|
+
|
60
|
+
REPLIES = {
|
61
|
+
:error => 0, # Generic error
|
62
|
+
:not_found => 1, # Key/Prefix not found
|
63
|
+
:nan => 2, # Not a number
|
64
|
+
:mem => 3, # Out of memory
|
65
|
+
:locked => 4, # Object is locked
|
66
|
+
:ok => 5, # Ok, no data follows
|
67
|
+
:val => 6, # Ok, scalar value follows
|
68
|
+
:kval => 7 # Ok, [ key => value, ... ] follows
|
69
|
+
}
|
70
|
+
|
71
|
+
ERRORS = {
|
72
|
+
0 => GenericError,
|
73
|
+
1 => NotFoundError,
|
74
|
+
2 => NaNError,
|
75
|
+
3 => OutOfMemoryError,
|
76
|
+
4 => LockedError
|
77
|
+
}
|
78
|
+
|
79
|
+
ENCODINGS = {
|
80
|
+
:plain => 0x00, # the item is in plain encoding and data points to its buffer
|
81
|
+
:lzf => 0x01, # PLAIN but compressed data with lzf
|
82
|
+
:number => 0x02 # the item contains a number and data pointer is actually that number
|
83
|
+
}
|
84
|
+
|
85
|
+
def self.error? (code)
|
86
|
+
code >= REPLIES[:error] && code <= REPLIES[:locked]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright (c) 2013, Simone Margaritelli <evilsocket at gmail dot com>
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of Gibson nor the names of its contributors may be used
|
13
|
+
# to endorse or promote products derived from this software without
|
14
|
+
# specific prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
20
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
module Gibson
|
28
|
+
VERSION = '1.0.1'
|
29
|
+
end
|
30
|
+
|
data/lib/gibson.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copyright (c) 2013, Simone Margaritelli <evilsocket at gmail dot com>
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# * Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of Gibson nor the names of its contributors may be used
|
13
|
+
# to endorse or promote products derived from this software without
|
14
|
+
# specific prior written permission.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
20
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
require 'gibson/gibson'
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gibson
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Simone Margaritelli
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-08-07 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: High performance Gibson client for Ruby
|
22
|
+
email: evilsocket@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/gibson/connection.rb
|
31
|
+
- lib/gibson/gibson.rb
|
32
|
+
- lib/gibson/protocol.rb
|
33
|
+
- lib/gibson/version.rb
|
34
|
+
- lib/gibson.rb
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- Gemfile
|
39
|
+
- gibson.gemspec
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://gibson-db.in/
|
42
|
+
licenses:
|
43
|
+
- BSD
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options:
|
46
|
+
- --charset=UTF-8
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.6
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: High performance Gibson client for Ruby
|
70
|
+
test_files: []
|
71
|
+
|