jstp 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/jstp.rb +3 -5
- data/lib/jstp/api.rb +7 -3
- data/lib/jstp/version.rb +1 -1
- data/spec/jstp/api_spec.rb +16 -0
- metadata +1 -1
data/lib/jstp.rb
CHANGED
data/lib/jstp/api.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module JSTP
|
2
2
|
module API
|
3
|
-
def dispatch &block
|
4
|
-
|
3
|
+
def dispatch *args, &block
|
4
|
+
if args.empty? and block
|
5
|
+
JSTP::Registry.instance.set block
|
5
6
|
|
6
|
-
|
7
|
+
::EventMachine.run &JSTP::EventMachine
|
8
|
+
else
|
9
|
+
Connector.instance.dispatch args.first
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
data/lib/jstp/version.rb
CHANGED
data/spec/jstp/api_spec.rb
CHANGED
@@ -20,5 +20,21 @@ describe JSTP::API do
|
|
20
20
|
o.dispatch &block
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
context 'an argument is passed' do
|
25
|
+
it 'should dispatch the message via the Connector' do
|
26
|
+
message = stub 'message'
|
27
|
+
JSTP::Connector.instance.should_receive(:dispatch)
|
28
|
+
.with message
|
29
|
+
|
30
|
+
o = Object.new
|
31
|
+
o.extend JSTP::API
|
32
|
+
o.dispatch message
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#port' do
|
38
|
+
it 'should configure the port number'
|
23
39
|
end
|
24
40
|
end
|