em_json_connection 0.0.1 → 0.0.2
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/lib/em_json_connection.rb +9 -4
- data/lib/em_json_connection/version.rb +1 -1
- data/spec/em_json_connection_spec.rb +21 -0
- metadata +18 -5
data/lib/em_json_connection.rb
CHANGED
@@ -7,6 +7,7 @@ module EM::JsonConnection::Base
|
|
7
7
|
def post_init
|
8
8
|
init_parser
|
9
9
|
@encoder = Yajl::Encoder.new
|
10
|
+
@connect_status = true
|
10
11
|
end
|
11
12
|
|
12
13
|
def init_parser
|
@@ -15,7 +16,6 @@ module EM::JsonConnection::Base
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def receive_data(data)
|
18
|
-
# p data
|
19
19
|
@parser << data
|
20
20
|
rescue Yajl::ParseError => error
|
21
21
|
puts "Yajl::ParseError: #{error}"
|
@@ -28,9 +28,14 @@ module EM::JsonConnection::Base
|
|
28
28
|
|
29
29
|
def send_data(data)
|
30
30
|
super @encoder.encode(data)
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
end
|
32
|
+
|
33
|
+
def connected?
|
34
|
+
@connect_status
|
35
|
+
end
|
36
|
+
|
37
|
+
def unbind
|
38
|
+
@connect_status = false
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
@@ -77,6 +77,27 @@ describe EM::JsonConnection::Base do
|
|
77
77
|
@connection.send_data({:a => 1})
|
78
78
|
end
|
79
79
|
end
|
80
|
+
describe "when connected" do
|
81
|
+
before(:each) do
|
82
|
+
@connection.post_init
|
83
|
+
end
|
84
|
+
describe "#connected?" do
|
85
|
+
it "should be true" do
|
86
|
+
@connection.connected?.should be_true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
describe "when NOT connected" do
|
91
|
+
before(:each) do
|
92
|
+
@connection.post_init
|
93
|
+
@connection.unbind
|
94
|
+
end
|
95
|
+
describe "#connected?" do
|
96
|
+
it "should be false" do
|
97
|
+
@connection.connected?.should be_false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
80
101
|
end
|
81
102
|
|
82
103
|
describe EM::JsonConnection::Server do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Niko Dittmann
|
@@ -14,11 +14,11 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-26 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
21
|
+
name: eventmachine
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
@@ -28,8 +28,21 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 0
|
30
30
|
version: "0"
|
31
|
-
type: :
|
31
|
+
type: :runtime
|
32
32
|
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
33
46
|
description: Adds a JSON layer to a plain Eventmachine socket connection
|
34
47
|
email: mail+git@niko-dittmann.com
|
35
48
|
executables: []
|