bertrpc 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bertrpc.gemspec +2 -2
- data/lib/bertrpc/action.rb +2 -2
- data/lib/bertrpc/errors.rb +15 -2
- data/test/action_test.rb +8 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/bertrpc.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{bertrpc}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Tom Preston-Werner"]
|
9
|
-
s.date = %q{2009-09-
|
9
|
+
s.date = %q{2009-09-07}
|
10
10
|
s.email = %q{tom@mojombo.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
data/lib/bertrpc/action.rb
CHANGED
@@ -36,10 +36,10 @@ module BERTRPC
|
|
36
36
|
|
37
37
|
write(sock, bert_request)
|
38
38
|
lenheader = sock.read(4)
|
39
|
-
raise ProtocolError.new(
|
39
|
+
raise ProtocolError.new(ProtocolError::NO_HEADER) unless lenheader
|
40
40
|
len = lenheader.unpack('N').first
|
41
41
|
bert_response = sock.read(len)
|
42
|
-
raise ProtocolError.new(
|
42
|
+
raise ProtocolError.new(ProtocolError::NO_DATA) unless bert_response
|
43
43
|
sock.close
|
44
44
|
bert_response
|
45
45
|
rescue Errno::ECONNREFUSED
|
data/lib/bertrpc/errors.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
module BERTRPC
|
2
2
|
class BERTRPCError < StandardError
|
3
|
-
|
3
|
+
attr_accessor :code
|
4
|
+
def initialize(msg = nil)
|
5
|
+
case msg
|
6
|
+
when Array
|
7
|
+
self.code = msg[0]
|
8
|
+
super(msg[1])
|
9
|
+
when String
|
10
|
+
self.code = nil
|
11
|
+
super(msg)
|
12
|
+
else
|
13
|
+
super(msg)
|
14
|
+
end
|
15
|
+
end
|
4
16
|
end
|
5
17
|
|
6
18
|
class ConnectionError < BERTRPCError
|
@@ -8,7 +20,8 @@ module BERTRPC
|
|
8
20
|
end
|
9
21
|
|
10
22
|
class ProtocolError < BERTRPCError
|
11
|
-
|
23
|
+
NO_HEADER = [0, "Unable to read length header from server."]
|
24
|
+
NO_DATA = [1, "Unable to read data from server."]
|
12
25
|
end
|
13
26
|
|
14
27
|
class ServerError < BERTRPCError
|
data/test/action_test.rb
CHANGED
@@ -67,8 +67,11 @@ class ActionTest < Test::Unit::TestCase
|
|
67
67
|
io.expects(:write).with("foo")
|
68
68
|
io.expects(:read).with(4).returns(nil)
|
69
69
|
TCPSocket.expects(:new).returns(io)
|
70
|
-
|
70
|
+
begin
|
71
71
|
@call.transaction("foo")
|
72
|
+
fail "Should have thrown an error"
|
73
|
+
rescue BERTRPC::ProtocolError => e
|
74
|
+
assert_equal 0, e.code
|
72
75
|
end
|
73
76
|
end
|
74
77
|
|
@@ -79,8 +82,11 @@ class ActionTest < Test::Unit::TestCase
|
|
79
82
|
io.expects(:read).with(4).returns("\000\000\000\003")
|
80
83
|
io.expects(:read).with(3).returns(nil)
|
81
84
|
TCPSocket.expects(:new).returns(io)
|
82
|
-
|
85
|
+
begin
|
83
86
|
@call.transaction("foo")
|
87
|
+
fail "Should have thrown an error"
|
88
|
+
rescue BERTRPC::ProtocolError => e
|
89
|
+
assert_equal 1, e.code
|
84
90
|
end
|
85
91
|
end
|
86
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bertrpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|