protoplasm-em-server 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/protoplasm/client/blocking_client.rb +14 -1
- data/lib/protoplasm/version.rb +1 -1
- data/test/protoplasm_test.rb +16 -0
- metadata +48 -82
@@ -10,6 +10,19 @@ module Protoplasm
|
|
10
10
|
cls
|
11
11
|
end
|
12
12
|
|
13
|
+
def close
|
14
|
+
_socket.close if _socket && !_socket.closed?
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.client(*args)
|
18
|
+
client = new(*args)
|
19
|
+
begin
|
20
|
+
yield client
|
21
|
+
ensure
|
22
|
+
client.close
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
13
26
|
private
|
14
27
|
def host_port
|
15
28
|
raise "Must be implemented by the client class"
|
@@ -24,7 +37,7 @@ module Protoplasm
|
|
24
37
|
s.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
|
25
38
|
s
|
26
39
|
end
|
27
|
-
yield @socket
|
40
|
+
yield @socket if block_given?
|
28
41
|
rescue Errno::EPIPE, Errno::ECONNRESET
|
29
42
|
count += 1
|
30
43
|
if count > 3
|
data/lib/protoplasm/version.rb
CHANGED
data/test/protoplasm_test.rb
CHANGED
@@ -43,6 +43,22 @@ describe "Protoplasm test server" do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
it "should allow a self closing client" do
|
47
|
+
with_proto_server(ProtoplasmTest::EMServer) do |port|
|
48
|
+
ProtoplasmTest::Client.client('127.0.0.1', port) do |client|
|
49
|
+
client.ping
|
50
|
+
assert_equal "LOWER", client.upcase('lower')
|
51
|
+
assert_equal "UPPER", client.upcase('upper')
|
52
|
+
nums = []
|
53
|
+
client.evens(10) do |resp|
|
54
|
+
nums << resp
|
55
|
+
end
|
56
|
+
assert_equal [2, 4, 6, 8], nums
|
57
|
+
client.ping
|
58
|
+
assert_equal "LOWER", client.upcase('lower')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
46
62
|
it "should do constant lookups" do
|
47
63
|
assert_equal :PING, ProtoplasmTest::Types::Command::Type.lookup(1)
|
48
64
|
assert_equal :UPCASE, ProtoplasmTest::Types::Command::Type.lookup(2)
|
metadata
CHANGED
@@ -1,92 +1,67 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: protoplasm-em-server
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 5
|
10
|
-
version: 0.1.5
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Josh Hull
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: eventmachine
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70249433648200 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: beefcake
|
36
23
|
prerelease: false
|
37
|
-
|
24
|
+
version_requirements: *70249433648200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: beefcake
|
27
|
+
requirement: &70249433663300 !ruby/object:Gem::Requirement
|
38
28
|
none: false
|
39
|
-
requirements:
|
29
|
+
requirements:
|
40
30
|
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 29
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
- 3
|
46
|
-
- 7
|
31
|
+
- !ruby/object:Gem::Version
|
47
32
|
version: 0.3.7
|
48
33
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rake
|
52
34
|
prerelease: false
|
53
|
-
|
35
|
+
version_requirements: *70249433663300
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70249433661880 !ruby/object:Gem::Requirement
|
54
39
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
62
44
|
type: :development
|
63
|
-
version_requirements: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: minitest
|
66
45
|
prerelease: false
|
67
|
-
|
46
|
+
version_requirements: *70249433661880
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: minitest
|
49
|
+
requirement: &70249433658340 !ruby/object:Gem::Requirement
|
68
50
|
none: false
|
69
|
-
requirements:
|
51
|
+
requirements:
|
70
52
|
- - ~>
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
hash: 21
|
73
|
-
segments:
|
74
|
-
- 2
|
75
|
-
- 6
|
76
|
-
- 1
|
53
|
+
- !ruby/object:Gem::Version
|
77
54
|
version: 2.6.1
|
78
55
|
type: :development
|
79
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70249433658340
|
80
58
|
description: A protoplasm server backed by EventMachine.
|
81
|
-
email:
|
59
|
+
email:
|
82
60
|
- joshbuddy@gmail.com
|
83
61
|
executables: []
|
84
|
-
|
85
62
|
extensions: []
|
86
|
-
|
87
63
|
extra_rdoc_files: []
|
88
|
-
|
89
|
-
files:
|
64
|
+
files:
|
90
65
|
- .gitignore
|
91
66
|
- Gemfile
|
92
67
|
- README.md
|
@@ -102,38 +77,29 @@ files:
|
|
102
77
|
- test/test_helper.rb
|
103
78
|
homepage: https://github.com/bazaarlabs/protoplasm
|
104
79
|
licenses: []
|
105
|
-
|
106
80
|
post_install_message:
|
107
81
|
rdoc_options: []
|
108
|
-
|
109
|
-
require_paths:
|
82
|
+
require_paths:
|
110
83
|
- lib
|
111
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
85
|
none: false
|
113
|
-
requirements:
|
114
|
-
- -
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
|
117
|
-
|
118
|
-
- 0
|
119
|
-
version: "0"
|
120
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
91
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
|
126
|
-
segments:
|
127
|
-
- 0
|
128
|
-
version: "0"
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
129
96
|
requirements: []
|
130
|
-
|
131
97
|
rubyforge_project: protoplasm-em-server
|
132
98
|
rubygems_version: 1.8.15
|
133
99
|
signing_key:
|
134
100
|
specification_version: 3
|
135
101
|
summary: A protoplasm server backed by EventMachine
|
136
|
-
test_files:
|
102
|
+
test_files:
|
137
103
|
- test/protoplasm_test.rb
|
138
104
|
- test/test_helper.rb
|
139
105
|
has_rdoc:
|