marilyn-rpc 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/benchmark/client.rb +42 -14
- data/doc/MarilynRPC.html +108 -0
- data/doc/MarilynRPC/CallRequestMail.html +578 -0
- data/doc/MarilynRPC/CallResponseMail.html +418 -0
- data/doc/MarilynRPC/Envelope.html +705 -0
- data/doc/MarilynRPC/ExceptionMail.html +338 -0
- data/doc/MarilynRPC/Gentleman.html +658 -0
- data/doc/MarilynRPC/MailFactory.html +284 -0
- data/doc/MarilynRPC/MailHelper.html +489 -0
- data/doc/MarilynRPC/NativeClient.html +579 -0
- data/doc/MarilynRPC/NativeClientProxy.html +303 -0
- data/doc/MarilynRPC/Server.html +406 -0
- data/doc/MarilynRPC/Service.html +599 -0
- data/doc/MarilynRPC/ServiceCache.html +481 -0
- data/doc/_index.html +219 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +318 -0
- data/doc/file.README.html +154 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +154 -0
- data/doc/js/app.js +203 -0
- data/doc/js/full_list.js +149 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +467 -0
- data/doc/top-level-namespace.html +88 -0
- data/lib/marilyn-rpc/client.rb +20 -21
- data/lib/marilyn-rpc/envelope.rb +27 -10
- data/lib/marilyn-rpc/gentleman.rb +8 -1
- data/lib/marilyn-rpc/mails.rb +40 -55
- data/lib/marilyn-rpc/server.rb +4 -11
- data/lib/marilyn-rpc/service.rb +1 -1
- data/lib/marilyn-rpc/service_cache.rb +7 -4
- data/lib/marilyn-rpc/version.rb +1 -1
- data/marilyn-rpc-0.0.2.gem +0 -0
- data/spec/envelope_spec.rb +18 -9
- data/spec/gentleman_spec.rb +14 -3
- data/spec/mails_spec.rb +2 -1
- data/spec/server_spec.rb +4 -4
- data/spec/service_cache_spec.rb +8 -0
- data/spec/spec_helper.rb +9 -2
- metadata +30 -22
data/lib/marilyn-rpc/version.rb
CHANGED
Binary file
|
data/spec/envelope_spec.rb
CHANGED
@@ -3,68 +3,77 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe MarilynRPC::Envelope do
|
4
4
|
before(:each) do
|
5
5
|
@envelope = MarilynRPC::Envelope.new
|
6
|
+
@enc = MarilynRPC::Envelope::HEADER_ENCODING
|
6
7
|
end
|
7
8
|
|
8
9
|
it "should be possible to parse really small envelope pieces" do
|
9
10
|
size = 100
|
10
11
|
content = "X" * size
|
11
|
-
data = [size].pack(
|
12
|
+
data = [size, 1].pack(@enc) + content
|
12
13
|
data.each_byte do |byte|
|
13
14
|
overhang = @envelope.parse!(byte.chr)
|
14
15
|
overhang.should == nil
|
15
16
|
end
|
16
17
|
@envelope.finished?.should == true
|
17
18
|
@envelope.content.should == content
|
19
|
+
@envelope.type.should == 1
|
18
20
|
end
|
19
21
|
|
20
22
|
it "should be possible to parse complete envelopes" do
|
21
23
|
size = 100
|
22
24
|
content = "X" * size
|
23
|
-
overhang = @envelope.parse!([size].pack(
|
25
|
+
overhang = @envelope.parse!([size, 1].pack(@enc) + content)
|
24
26
|
overhang.should == nil
|
25
27
|
@envelope.finished?.should == true
|
26
28
|
@envelope.content.should == content
|
29
|
+
@envelope.type.should == 1
|
27
30
|
end
|
28
31
|
|
29
32
|
it "shold be possible to parse an empty envelope" do
|
30
|
-
overhang = @envelope.parse!([0].pack(
|
33
|
+
overhang = @envelope.parse!([0, 1].pack(@enc))
|
31
34
|
overhang.should == nil
|
32
35
|
@envelope.content.should == ""
|
36
|
+
@envelope.type.should == 1
|
33
37
|
@envelope.finished?.should == true
|
34
38
|
end
|
35
39
|
|
36
40
|
it "should be possible to detect overhangs correctly" do
|
37
41
|
content = "X" * 120
|
38
|
-
overhang = @envelope.parse!([100].pack(
|
42
|
+
overhang = @envelope.parse!([100, 1].pack(@enc) + content)
|
39
43
|
overhang.should == "X" * 20
|
40
44
|
@envelope.finished?.should == true
|
41
45
|
@envelope.content.should == "X" * 100
|
46
|
+
@envelope.type.should == 1
|
42
47
|
end
|
43
48
|
|
44
49
|
it "should be possible to lead an envelope from the overhang" do
|
45
|
-
content = ([20].pack(
|
50
|
+
content = ([20, 1].pack(@enc) + ("X" * 20)) * 2
|
46
51
|
overhang = @envelope.parse!(content)
|
47
|
-
overhang.should == ([20].pack(
|
52
|
+
overhang.should == ([20, 1].pack(@enc) + ("X" * 20))
|
48
53
|
@envelope.finished?.should == true
|
49
54
|
@envelope.content.should == "X" * 20
|
55
|
+
@envelope.type.should == 1
|
50
56
|
@envelope = MarilynRPC::Envelope.new
|
51
57
|
overhang = @envelope.parse!(overhang)
|
52
58
|
overhang.should == nil
|
53
59
|
@envelope.finished?.should == true
|
54
60
|
@envelope.content.should == "X" * 20
|
61
|
+
@envelope.type.should == 1
|
55
62
|
end
|
56
63
|
|
57
|
-
it "should be possible to encode a envelope correctly" do
|
64
|
+
it "should be possible to @encode a envelope correctly" do
|
58
65
|
content = "Hallo Welt"
|
59
66
|
@envelope.content = content
|
60
|
-
@envelope.
|
67
|
+
@envelope.type = 1
|
68
|
+
@envelope.encode.should == [content.size, 1].pack(@enc) + content
|
61
69
|
end
|
62
70
|
|
63
71
|
it "should be possible to create a envelope using the initalizer" do
|
64
72
|
size = 100
|
65
73
|
content = "X" * size
|
66
|
-
@envelope = MarilynRPC::Envelope.new(content)
|
74
|
+
@envelope = MarilynRPC::Envelope.new(content, 1)
|
67
75
|
@envelope.finished?.should == true
|
68
76
|
@envelope.content.should == content
|
77
|
+
@envelope.type == 1
|
69
78
|
end
|
70
79
|
end
|
data/spec/gentleman_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe MarilynRPC::Gentleman do
|
|
22
22
|
|
23
23
|
class ConnectionMock
|
24
24
|
attr_accessor :data
|
25
|
-
def
|
25
|
+
def send_data(obj)
|
26
26
|
@data = obj
|
27
27
|
end
|
28
28
|
end
|
@@ -36,7 +36,18 @@ describe MarilynRPC::Gentleman do
|
|
36
36
|
end
|
37
37
|
g.connection = ConnectionMock.new
|
38
38
|
deferable.call(1, 2)
|
39
|
-
g.connection.data.result.should == 3
|
39
|
+
unpack_envelope(g.connection.data).result.should == 3
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be possible to defer a process to a gentleman" do
|
43
|
+
deferable = DeferObjectMock.new
|
44
|
+
|
45
|
+
g = MarilynRPC::Gentleman.new(deferable) do |a, b|
|
46
|
+
raise Exception.new
|
47
|
+
end
|
48
|
+
g.connection = ConnectionMock.new
|
49
|
+
deferable.call(1, 2)
|
50
|
+
unpack_envelope(g.connection.data).exception.should be_a(Exception)
|
40
51
|
end
|
41
52
|
|
42
53
|
it "should be possible to create a gentleman helper" do
|
@@ -52,6 +63,6 @@ describe MarilynRPC::Gentleman do
|
|
52
63
|
|
53
64
|
g.connection = ConnectionMock.new
|
54
65
|
callback.call(1, 2)
|
55
|
-
g.connection.data.result.should == 3
|
66
|
+
unpack_envelope(g.connection.data).result.should == 3
|
56
67
|
end
|
57
68
|
end
|
data/spec/mails_spec.rb
CHANGED
@@ -62,7 +62,8 @@ describe "MarilynRPC Mails" do
|
|
62
62
|
tag = Time.now.to_f
|
63
63
|
mail = MarilynRPC::CallRequestMail.new(
|
64
64
|
tag, "/user", :find_by_name, ["mr.x"])
|
65
|
-
envelope = MarilynRPC::Envelope.new(mail.encode
|
65
|
+
envelope = MarilynRPC::Envelope.new(mail.encode,
|
66
|
+
MarilynRPC::CallRequestMail::TYPE)
|
66
67
|
mail = MarilynRPC::MailFactory.unpack(envelope)
|
67
68
|
mail.should be_a(MarilynRPC::CallRequestMail)
|
68
69
|
end
|
data/spec/server_spec.rb
CHANGED
@@ -20,14 +20,14 @@ describe MarilynRPC::Server do
|
|
20
20
|
|
21
21
|
it "should be possible to send multiple letters to the server" do
|
22
22
|
@server.post_init
|
23
|
-
@server.receive_data(MarilynRPC::Envelope.new("Test1").encode)
|
23
|
+
@server.receive_data(MarilynRPC::Envelope.new("Test1", 1).encode)
|
24
24
|
envelope = MarilynRPC::Envelope.new
|
25
25
|
envelope.parse!(@server.data)
|
26
26
|
mail = MarilynRPC::ExceptionMail.new
|
27
27
|
mail.decode(envelope.content)
|
28
|
-
mail.exception.message.should
|
29
|
-
@server.receive_data(MarilynRPC::Envelope.new("Test2").encode)
|
30
|
-
@server.receive_data(MarilynRPC::Envelope.new("Test3").encode)
|
28
|
+
mail.exception.message.should include("incompatible marshal file format")
|
29
|
+
@server.receive_data(MarilynRPC::Envelope.new("Test2", 1).encode)
|
30
|
+
@server.receive_data(MarilynRPC::Envelope.new("Test3", 1).encode)
|
31
31
|
@server.unbind
|
32
32
|
end
|
33
33
|
end
|
data/spec/service_cache_spec.rb
CHANGED
@@ -59,6 +59,7 @@ describe MarilynRPC::ServiceCache do
|
|
59
59
|
|
60
60
|
it "should be possible to call a sync method" do
|
61
61
|
answer = @cache.call(envelope_call(1, "/test", :sync_method, 1, 2))
|
62
|
+
answer = unpack_envelope(answer)
|
62
63
|
answer.should be_a(MarilynRPC::CallResponseMail)
|
63
64
|
answer.result.should == 3
|
64
65
|
end
|
@@ -100,11 +101,13 @@ describe MarilynRPC::ServiceCache do
|
|
100
101
|
|
101
102
|
it "should be possible to call the normal method" do
|
102
103
|
answer = @cache.call(envelope_call(1, "/test", :normal))
|
104
|
+
answer = unpack_envelope(answer)
|
103
105
|
answer.result.should == true
|
104
106
|
end
|
105
107
|
|
106
108
|
it "should not be possible to call an secure method without authentication" do
|
107
109
|
answer = @cache.call(envelope_call(1, "/test", :secure))
|
110
|
+
answer = unpack_envelope(answer)
|
108
111
|
answer.should be_a(MarilynRPC::ExceptionMail)
|
109
112
|
answer.exception.should be_a(MarilynRPC::PermissionDeniedError)
|
110
113
|
end
|
@@ -113,27 +116,32 @@ describe MarilynRPC::ServiceCache do
|
|
113
116
|
@cache.call(envelope_call(1, MarilynRPC::Service::AUTHENTICATION_PATH,
|
114
117
|
:authenticate_plain, "testuserid", "secret"))
|
115
118
|
answer = @cache.call(envelope_call(1, "/test", :secure))
|
119
|
+
answer = unpack_envelope(answer)
|
116
120
|
answer.result.should == true
|
117
121
|
end
|
118
122
|
|
119
123
|
it "should be possible to call the username from within the service without an authenticated user" do
|
120
124
|
answer = @cache.call(envelope_call(1, "/test", :username))
|
125
|
+
answer = unpack_envelope(answer)
|
121
126
|
answer.result.should == nil
|
122
127
|
end
|
123
128
|
|
124
129
|
it "should be possible to call the username from within the service with an authenticated user" do
|
125
130
|
@cache.username = "test"
|
126
131
|
answer = @cache.call(envelope_call(1, "/test", :username))
|
132
|
+
answer = unpack_envelope(answer)
|
127
133
|
answer.result.should == "test"
|
128
134
|
end
|
129
135
|
|
130
136
|
it "should be possible to call the authentication from within the service" do
|
131
137
|
answer = @cache.call(envelope_call(1, "/test", :logged_in?))
|
138
|
+
answer = unpack_envelope(answer)
|
132
139
|
answer.result.should == false
|
133
140
|
|
134
141
|
# set the username
|
135
142
|
@cache.username = "test"
|
136
143
|
answer = @cache.call(envelope_call(1, "/test", :logged_in?))
|
144
|
+
answer = unpack_envelope(answer)
|
137
145
|
answer.result.should == true
|
138
146
|
end
|
139
147
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,13 @@ $:.push(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
2
2
|
require "marilyn-rpc"
|
3
3
|
|
4
4
|
def envelope_call(tag, path, method, *args)
|
5
|
-
|
6
|
-
MarilynRPC::
|
5
|
+
e = MarilynRPC::Envelope.new
|
6
|
+
e.parse!(MarilynRPC::MailFactory.build_call(tag, path, method, args))
|
7
|
+
e
|
8
|
+
end
|
9
|
+
|
10
|
+
def unpack_envelope(data)
|
11
|
+
envelope = MarilynRPC::Envelope.new
|
12
|
+
envelope.parse!(data)
|
13
|
+
MarilynRPC::MailFactory.unpack(envelope)
|
7
14
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marilyn-rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
5
|
+
version: 0.0.4
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Vincent Landgraf
|
@@ -26,11 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ~>
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 59
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 12
|
33
|
-
- 10
|
34
24
|
version: 0.12.10
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -42,10 +32,6 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ~>
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 11
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 4
|
49
35
|
version: "2.4"
|
50
36
|
type: :development
|
51
37
|
version_requirements: *id002
|
@@ -62,6 +48,33 @@ extra_rdoc_files: []
|
|
62
48
|
files:
|
63
49
|
- benchmark/client.rb
|
64
50
|
- benchmark/server.rb
|
51
|
+
- doc/_index.html
|
52
|
+
- doc/class_list.html
|
53
|
+
- doc/css/common.css
|
54
|
+
- doc/css/full_list.css
|
55
|
+
- doc/css/style.css
|
56
|
+
- doc/file.README.html
|
57
|
+
- doc/file_list.html
|
58
|
+
- doc/frames.html
|
59
|
+
- doc/index.html
|
60
|
+
- doc/js/app.js
|
61
|
+
- doc/js/full_list.js
|
62
|
+
- doc/js/jquery.js
|
63
|
+
- doc/MarilynRPC/CallRequestMail.html
|
64
|
+
- doc/MarilynRPC/CallResponseMail.html
|
65
|
+
- doc/MarilynRPC/Envelope.html
|
66
|
+
- doc/MarilynRPC/ExceptionMail.html
|
67
|
+
- doc/MarilynRPC/Gentleman.html
|
68
|
+
- doc/MarilynRPC/MailFactory.html
|
69
|
+
- doc/MarilynRPC/MailHelper.html
|
70
|
+
- doc/MarilynRPC/NativeClient.html
|
71
|
+
- doc/MarilynRPC/NativeClientProxy.html
|
72
|
+
- doc/MarilynRPC/Server.html
|
73
|
+
- doc/MarilynRPC/Service.html
|
74
|
+
- doc/MarilynRPC/ServiceCache.html
|
75
|
+
- doc/MarilynRPC.html
|
76
|
+
- doc/method_list.html
|
77
|
+
- doc/top-level-namespace.html
|
65
78
|
- examples/async/client.rb
|
66
79
|
- examples/async/server.rb
|
67
80
|
- examples/authentication/client.rb
|
@@ -82,6 +95,7 @@ files:
|
|
82
95
|
- lib/marilyn-rpc/version.rb
|
83
96
|
- lib/marilyn-rpc.rb
|
84
97
|
- LICENCE
|
98
|
+
- marilyn-rpc-0.0.2.gem
|
85
99
|
- marilyn-rpc.gemspec
|
86
100
|
- README.md
|
87
101
|
- spec/envelope_spec.rb
|
@@ -105,23 +119,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
119
|
requirements:
|
106
120
|
- - ">="
|
107
121
|
- !ruby/object:Gem::Version
|
108
|
-
hash: 3
|
109
|
-
segments:
|
110
|
-
- 0
|
111
122
|
version: "0"
|
112
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
124
|
none: false
|
114
125
|
requirements:
|
115
126
|
- - ">="
|
116
127
|
- !ruby/object:Gem::Version
|
117
|
-
hash: 3
|
118
|
-
segments:
|
119
|
-
- 0
|
120
128
|
version: "0"
|
121
129
|
requirements: []
|
122
130
|
|
123
131
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.6.
|
132
|
+
rubygems_version: 1.6.1
|
125
133
|
signing_key:
|
126
134
|
specification_version: 3
|
127
135
|
summary: Simple, beautiful event-based RPC
|