nebulous_stomp 1.1.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hgtags +1 -0
- data/.rspec +1 -1
- data/lib/{nebulous → nebulous_stomp}/message.rb +7 -9
- data/lib/{nebulous → nebulous_stomp}/nebrequest.rb +2 -6
- data/lib/{nebulous → nebulous_stomp}/nebrequest_null.rb +2 -4
- data/lib/{nebulous → nebulous_stomp}/param.rb +1 -4
- data/lib/{nebulous → nebulous_stomp}/redis_handler.rb +1 -3
- data/lib/{nebulous → nebulous_stomp}/redis_handler_null.rb +1 -3
- data/lib/{nebulous → nebulous_stomp}/stomp_handler.rb +8 -10
- data/lib/{nebulous → nebulous_stomp}/stomp_handler_null.rb +8 -10
- data/lib/nebulous_stomp/version.rb +5 -0
- data/lib/{nebulous.rb → nebulous_stomp.rb} +16 -18
- data/nebulous.gemspec +3 -3
- data/spec/message_spec.rb +2 -4
- data/spec/nebrequest_null_spec.rb +12 -17
- data/spec/nebrequest_spec.rb +14 -16
- data/spec/nebulous_spec.rb +23 -23
- data/spec/param_spec.rb +5 -5
- data/spec/redis_handler_null_spec.rb +2 -4
- data/spec/redis_handler_spec.rb +8 -10
- data/spec/stomp_handler_null_spec.rb +7 -7
- data/spec/stomp_handler_spec.rb +11 -11
- metadata +13 -14
- data/lib/nebulous/version.rb +0 -5
- data/spec/spec_helper_old.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b50d86922e77fc4e61bf8a69424f252d3c91ce41
|
4
|
+
data.tar.gz: 62790af2e03505a506da7f73ff7e772c17d09b16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78f6c7775d04afca9ef387767ad4e7bf3e0f54d37b276cd653ebbccd3297f76f969b376616554855fd90497c30372e1b3716cf44afae53fa07107b6f686684c0
|
7
|
+
data.tar.gz: a085cc52937b783362bc4669797f589aac716a1af5a27fd1a34c674d3d20020fc053a6a89706fef075f0966cfa477f05e93981f09cf167ed9aeffc01642684b6
|
data/.hgtags
CHANGED
data/.rspec
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
# COding: UTF-8
|
2
|
-
|
3
1
|
require 'json'
|
4
2
|
|
5
3
|
require_relative 'stomp_handler'
|
6
4
|
|
7
5
|
|
8
|
-
module
|
6
|
+
module NebulousStomp
|
9
7
|
|
10
8
|
|
11
9
|
##
|
@@ -54,7 +52,7 @@ module Nebulous
|
|
54
52
|
def from_parts(replyTo, inReplyTo, verb, params, desc)
|
55
53
|
raise ArgumentError, "missing parts" unless verb
|
56
54
|
|
57
|
-
|
55
|
+
NebulousStomp.logger.debug(__FILE__){ "New message from parts" }
|
58
56
|
|
59
57
|
p =
|
60
58
|
case params
|
@@ -82,7 +80,7 @@ module Nebulous
|
|
82
80
|
def in_reply_to(msg, verb, params=nil, desc=nil, replyTo=nil)
|
83
81
|
raise ArgumentError, 'bad message' unless msg.kind_of? Message
|
84
82
|
|
85
|
-
|
83
|
+
NebulousStomp.logger.debug(__FILE__){ "New message reply" }
|
86
84
|
|
87
85
|
p =
|
88
86
|
case params
|
@@ -109,7 +107,7 @@ module Nebulous
|
|
109
107
|
raise ArgumentError, 'not a stomp message' \
|
110
108
|
unless stompMsg.kind_of? Stomp::Message
|
111
109
|
|
112
|
-
|
110
|
+
NebulousStomp.logger.debug(__FILE__){ "New message from STOMP" }
|
113
111
|
|
114
112
|
s = Marshal.load( Marshal.dump(stompMsg) )
|
115
113
|
obj = self.new( stompHeaders: s.headers,
|
@@ -127,7 +125,7 @@ module Nebulous
|
|
127
125
|
raise ArgumentError, "That can't be JSON, it's not a string" \
|
128
126
|
unless json.kind_of? String
|
129
127
|
|
130
|
-
|
128
|
+
NebulousStomp.logger.debug(__FILE__){ "New message from cache" }
|
131
129
|
|
132
130
|
# Note that the message body at this point, for a JSON message, is
|
133
131
|
# actually encoded to JSON *twice* - the second time was when the cache
|
@@ -259,7 +257,7 @@ module Nebulous
|
|
259
257
|
def respond_success
|
260
258
|
raise NebulousError, "Don''t know who to reply to" unless @reply_to
|
261
259
|
|
262
|
-
|
260
|
+
NebulousStomp.logger.info(__FILE__) do
|
263
261
|
"Responded to #{self} with 'success' verb"
|
264
262
|
end
|
265
263
|
|
@@ -278,7 +276,7 @@ module Nebulous
|
|
278
276
|
def respond_error(err,fields=[])
|
279
277
|
raise NebulousError, "Don''t know who to reply to" unless @reply_to
|
280
278
|
|
281
|
-
|
279
|
+
NebulousStomp.logger.info(__FILE__) do
|
282
280
|
"Responded to #{self} with 'error': #{err}"
|
283
281
|
end
|
284
282
|
|
@@ -1,13 +1,9 @@
|
|
1
|
-
# coding: UTF-8
|
2
|
-
|
3
|
-
require 'nebulous'
|
4
|
-
|
5
1
|
require_relative 'stomp_handler'
|
6
2
|
require_relative 'redis_handler'
|
7
3
|
require_relative 'message'
|
8
4
|
|
9
5
|
|
10
|
-
module
|
6
|
+
module NebulousStomp
|
11
7
|
|
12
8
|
|
13
9
|
##
|
@@ -74,7 +70,7 @@ module Nebulous
|
|
74
70
|
stompHandler=nil,
|
75
71
|
redisHandler=nil )
|
76
72
|
|
77
|
-
|
73
|
+
NebulousStomp.logger.debug(__FILE__) {"New NebRequest for verb #{verb}"}
|
78
74
|
|
79
75
|
@target = target.to_s
|
80
76
|
@verb = verb.to_s
|
@@ -1,11 +1,9 @@
|
|
1
|
-
# COding: UTF-8
|
2
|
-
|
3
1
|
require 'stomp'
|
4
2
|
require 'json'
|
5
3
|
require 'time'
|
6
4
|
|
7
5
|
|
8
|
-
module
|
6
|
+
module NebulousStomp
|
9
7
|
|
10
8
|
|
11
9
|
##
|
@@ -123,7 +121,7 @@ module Nebulous
|
|
123
121
|
#
|
124
122
|
def stomp_connect
|
125
123
|
return self unless nebulous_on?
|
126
|
-
|
124
|
+
NebulousStomp.logger.info(__FILE__) {"Connecting to STOMP"}
|
127
125
|
|
128
126
|
@client = @test_client || Stomp::Client.new( @stomp_hash.dup )
|
129
127
|
raise ConnectionError, "Stomp Connection failed" unless connected?
|
@@ -145,7 +143,7 @@ module Nebulous
|
|
145
143
|
#
|
146
144
|
def stomp_disconnect
|
147
145
|
if @client
|
148
|
-
|
146
|
+
NebulousStomp.logger.info(__FILE__) {"STOMP Disconnect"}
|
149
147
|
@client.close if @client
|
150
148
|
@client = nil
|
151
149
|
end
|
@@ -183,7 +181,7 @@ module Nebulous
|
|
183
181
|
#
|
184
182
|
def listen(queue)
|
185
183
|
return unless nebulous_on?
|
186
|
-
|
184
|
+
NebulousStomp.logger.info(__FILE__) {"Subscribing to #{queue}"}
|
187
185
|
|
188
186
|
stomp_connect unless @client
|
189
187
|
|
@@ -196,7 +194,7 @@ module Nebulous
|
|
196
194
|
@client.ack(msg)
|
197
195
|
yield Message.from_stomp(msg) unless msg.body == 'boo'
|
198
196
|
rescue =>e
|
199
|
-
|
197
|
+
NebulousStomp.logger.error(__FILE__) {"Error during polling: #{e}" }
|
200
198
|
end
|
201
199
|
end
|
202
200
|
|
@@ -218,7 +216,7 @@ module Nebulous
|
|
218
216
|
def listen_with_timeout(queue, timeout)
|
219
217
|
return unless nebulous_on?
|
220
218
|
|
221
|
-
|
219
|
+
NebulousStomp.logger.info(__FILE__) do
|
222
220
|
"Subscribing to #{queue} with timeout #{timeout}"
|
223
221
|
end
|
224
222
|
|
@@ -239,7 +237,7 @@ module Nebulous
|
|
239
237
|
done = true
|
240
238
|
end
|
241
239
|
rescue =>e
|
242
|
-
|
240
|
+
NebulousStomp.logger.error(__FILE__) {"Error during polling: #{e}" }
|
243
241
|
end
|
244
242
|
|
245
243
|
end # of Stomp client subscribe block
|
@@ -258,7 +256,7 @@ module Nebulous
|
|
258
256
|
#
|
259
257
|
def send_message(queue, mess)
|
260
258
|
return nil unless nebulous_on?
|
261
|
-
raise
|
259
|
+
raise NebulousStomp::NebulousError, "That's not a Message" \
|
262
260
|
unless mess.respond_to?(:body_for_stomp) \
|
263
261
|
&& mess.respond_to?(:headers_for_stomp)
|
264
262
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# COding: UTF-8
|
2
|
-
|
3
1
|
require 'stomp'
|
4
2
|
require 'json'
|
5
3
|
require 'time'
|
@@ -8,7 +6,7 @@ require_relative 'stomp_handler'
|
|
8
6
|
require_relative 'message'
|
9
7
|
|
10
8
|
|
11
|
-
module
|
9
|
+
module NebulousStomp
|
12
10
|
|
13
11
|
|
14
12
|
##
|
@@ -32,7 +30,7 @@ module Nebulous
|
|
32
30
|
|
33
31
|
|
34
32
|
def stomp_connect
|
35
|
-
|
33
|
+
NebulousStomp.logger.info(__FILE__) {"Connecting to STOMP (Null)"}
|
36
34
|
|
37
35
|
@client = true
|
38
36
|
self
|
@@ -40,7 +38,7 @@ module Nebulous
|
|
40
38
|
|
41
39
|
|
42
40
|
def stomp_disconnect
|
43
|
-
|
41
|
+
NebulousStomp.logger.info(__FILE__) {"STOMP Disconnect (Null)"}
|
44
42
|
@client = nil
|
45
43
|
self
|
46
44
|
end
|
@@ -52,19 +50,19 @@ module Nebulous
|
|
52
50
|
|
53
51
|
|
54
52
|
def listen(queue)
|
55
|
-
|
53
|
+
NebulousStomp.logger.info(__FILE__) {"Subscribing to #{queue} (on Null)"}
|
56
54
|
yield @fake_mess
|
57
55
|
end
|
58
56
|
|
59
57
|
|
60
58
|
def listen_with_timeout(queue, timeout)
|
61
|
-
|
59
|
+
NebulousStomp.logger.info(__FILE__) {"Subscribing to #{queue} (on Null)"}
|
62
60
|
|
63
61
|
if @fake_mess
|
64
62
|
yield @fake_mess
|
65
63
|
else
|
66
64
|
sleep timeout
|
67
|
-
raise
|
65
|
+
raise NebulousStomp::NebulousTimeout
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
@@ -75,14 +73,14 @@ module Nebulous
|
|
75
73
|
|
76
74
|
|
77
75
|
def respond_success(nebMess)
|
78
|
-
|
76
|
+
NebulousStomp.logger.info(__FILE__) do
|
79
77
|
"Responded to #{nebMess} with 'success' verb (to Null)"
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
81
|
|
84
82
|
def respond_error(nebMess,err,fields=[])
|
85
|
-
|
83
|
+
NebulousStomp.logger.info(__FILE__) do
|
86
84
|
"Responded to #{nebMess} with 'error' verb: #{err} (to Null)"
|
87
85
|
end
|
88
86
|
end
|
@@ -1,16 +1,14 @@
|
|
1
|
-
# coding: UTF-8
|
2
|
-
|
3
1
|
require 'stomp'
|
4
2
|
require 'redis'
|
5
3
|
require 'logger'
|
6
4
|
require 'devnull'
|
7
5
|
|
8
|
-
require '
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
require '
|
6
|
+
require 'nebulous_stomp/version'
|
7
|
+
require 'nebulous_stomp/param'
|
8
|
+
require 'nebulous_stomp/message'
|
9
|
+
require 'nebulous_stomp/nebrequest'
|
10
|
+
require 'nebulous_stomp/stomp_handler'
|
11
|
+
require 'nebulous_stomp/redis_handler'
|
14
12
|
|
15
13
|
|
16
14
|
##
|
@@ -39,18 +37,18 @@ require 'nebulous/redis_handler'
|
|
39
37
|
#
|
40
38
|
# a complete list of classes & modules:
|
41
39
|
#
|
42
|
-
# *
|
43
|
-
# *
|
44
|
-
# *
|
45
|
-
# *
|
46
|
-
# *
|
47
|
-
# *
|
48
|
-
# *
|
49
|
-
# *
|
50
|
-
# *
|
40
|
+
# * NebulousStomp
|
41
|
+
# * NebulousStomp::Param
|
42
|
+
# * NebulousStomp::NebRequest
|
43
|
+
# * NebulousStomp::NebRequestNull
|
44
|
+
# * NebulousStomp::Message
|
45
|
+
# * NebulousStomp::StompHandler
|
46
|
+
# * NebulousStomp::StompHandlerNull
|
47
|
+
# * NebulousStomp::RedisHandler
|
48
|
+
# * NebulousStomp::RedisHandlerNull
|
51
49
|
#
|
52
50
|
# If you want the null classes, you must require them seperately.
|
53
|
-
module
|
51
|
+
module NebulousStomp
|
54
52
|
|
55
53
|
|
56
54
|
# Thrown when anything goes wrong.
|
data/nebulous.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
lib = File.expand_path('../lib', __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require '
|
3
|
+
require 'nebulous_stomp/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "nebulous_stomp"
|
7
|
-
spec.version =
|
7
|
+
spec.version = NebulousStomp::VERSION
|
8
8
|
spec.authors = ["Andy Jones"]
|
9
9
|
spec.email = ["andy.jones@twosticksconsulting.co.uk"]
|
10
10
|
spec.summary = %q{Handles request-and-response messaging via STOMP}
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
DESC
|
16
16
|
|
17
17
|
spec.license = "MIT"
|
18
|
-
spec.homepage = "https://bitbucket.org/andy-twosticks/
|
18
|
+
spec.homepage = "https://bitbucket.org/andy-twosticks/nebulous_stomp"
|
19
19
|
|
20
20
|
spec.files = `hg status -macn0`.split("\x0")
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
data/spec/message_spec.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
include
|
3
|
+
include NebulousStomp
|
4
4
|
|
5
|
-
require '
|
6
|
-
|
7
|
-
require 'nebulous/message'
|
8
|
-
#require 'nebulous/stomp_handler_null'
|
9
|
-
#require 'nebulous/redis_handler_null'
|
10
|
-
|
11
|
-
require 'pry'
|
5
|
+
require 'nebulous_stomp/nebrequest_null'
|
6
|
+
require 'nebulous_stomp/message'
|
12
7
|
|
13
8
|
|
14
9
|
describe NebRequestNull do
|
@@ -18,12 +13,12 @@ describe NebRequestNull do
|
|
18
13
|
end
|
19
14
|
|
20
15
|
def disable(thing)
|
21
|
-
|
16
|
+
NebulousStomp.init( :stompConnectHash => thing == :stomp ? {} : stomp_hash,
|
22
17
|
:redisConnectHash => thing == :redis ? {} : redis_hash,
|
23
18
|
:messageTimeout => 5,
|
24
19
|
:cacheTimeout => 20 )
|
25
20
|
|
26
|
-
|
21
|
+
NebulousStomp.add_target( :accord,
|
27
22
|
:sendQueue => "/queue/laplace.dev",
|
28
23
|
:receiveQueue => "/queue/laplace.out",
|
29
24
|
:messageTimeout => 1 )
|
@@ -59,7 +54,7 @@ describe NebRequestNull do
|
|
59
54
|
end
|
60
55
|
|
61
56
|
it "falls back to the default if the timeout on the target is not set" do
|
62
|
-
|
57
|
+
NebulousStomp.add_target( :dracula,
|
63
58
|
:sendQueue => "/queue/laplace.dev",
|
64
59
|
:receiveQueue => "/queue/laplace.out" )
|
65
60
|
|
@@ -103,14 +98,14 @@ describe NebRequestNull do
|
|
103
98
|
req.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
104
99
|
response = req.send_no_cache
|
105
100
|
|
106
|
-
expect( response ).to be_a
|
101
|
+
expect( response ).to be_a NebulousStomp::Message
|
107
102
|
expect( response.verb ).to eq('foo')
|
108
103
|
end
|
109
104
|
|
110
105
|
it 'returns a nebulous timeout if there is no response' do
|
111
106
|
request = new_request('accord', 'foo')
|
112
107
|
expect{ request.send_no_cache }.
|
113
|
-
to raise_exception
|
108
|
+
to raise_exception NebulousStomp::NebulousTimeout
|
114
109
|
|
115
110
|
end
|
116
111
|
|
@@ -132,7 +127,7 @@ describe NebRequestNull do
|
|
132
127
|
req.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
133
128
|
|
134
129
|
response = req.send
|
135
|
-
expect( response ).to be_a
|
130
|
+
expect( response ).to be_a NebulousStomp::Message
|
136
131
|
expect( response.verb ).to eq('foo')
|
137
132
|
end
|
138
133
|
|
@@ -142,7 +137,7 @@ describe NebRequestNull do
|
|
142
137
|
req.insert_fake_redis('xxx', {'verb' => 'frog'}.to_json)
|
143
138
|
response = req.send
|
144
139
|
|
145
|
-
expect( response ).to be_a
|
140
|
+
expect( response ).to be_a NebulousStomp::Message
|
146
141
|
expect( response.verb ).to eq('frog')
|
147
142
|
end
|
148
143
|
|
@@ -162,7 +157,7 @@ describe NebRequestNull do
|
|
162
157
|
|
163
158
|
it 'returns a nebulous timeout if there is no response' do
|
164
159
|
req = new_request('accord', 'foo')
|
165
|
-
expect{ req.send }.to raise_exception
|
160
|
+
expect{ req.send }.to raise_exception NebulousStomp::NebulousTimeout
|
166
161
|
end
|
167
162
|
|
168
163
|
it 'still works if Redis is turned off in the config' do
|
@@ -171,7 +166,7 @@ describe NebRequestNull do
|
|
171
166
|
r.insert_fake_stomp( Message.from_parts('', '', 'foo', 'bar', 'baz') )
|
172
167
|
|
173
168
|
response = r.send
|
174
|
-
expect( response ).to be_a
|
169
|
+
expect( response ).to be_a NebulousStomp::Message
|
175
170
|
expect( response.verb ).to eq('foo')
|
176
171
|
end
|
177
172
|
|
data/spec/nebrequest_spec.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
include
|
3
|
+
include NebulousStomp
|
4
4
|
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
9
|
-
|
10
|
-
require 'pry'
|
5
|
+
require 'nebulous_stomp/nebrequest'
|
6
|
+
require 'nebulous_stomp/message'
|
7
|
+
require 'nebulous_stomp/stomp_handler_null'
|
8
|
+
require 'nebulous_stomp/redis_handler_null'
|
11
9
|
|
12
10
|
|
13
11
|
describe NebRequest do
|
@@ -32,12 +30,12 @@ describe NebRequest do
|
|
32
30
|
end
|
33
31
|
|
34
32
|
before do
|
35
|
-
|
33
|
+
NebulousStomp.init( :stompConnectHash => @stomph,
|
36
34
|
:redisConnectHash => @redish,
|
37
35
|
:messageTimeout => 5,
|
38
36
|
:cacheTimeout => 20 )
|
39
37
|
|
40
|
-
|
38
|
+
NebulousStomp.add_target( :accord,
|
41
39
|
:sendQueue => "/queue/laplace.dev",
|
42
40
|
:receiveQueue => "/queue/laplace.out",
|
43
41
|
:messageTimeout => 1 )
|
@@ -58,7 +56,7 @@ describe NebRequest do
|
|
58
56
|
end
|
59
57
|
|
60
58
|
it "falls back to the default if the timeout on the target is not set" do
|
61
|
-
|
59
|
+
NebulousStomp.add_target( :dracula,
|
62
60
|
:sendQueue => "/queue/laplace.dev",
|
63
61
|
:receiveQueue => "/queue/laplace.out" )
|
64
62
|
|
@@ -110,14 +108,14 @@ describe NebRequest do
|
|
110
108
|
request = new_request('accord', 'foo')
|
111
109
|
response = request.send_no_cache
|
112
110
|
|
113
|
-
expect( response ).to be_a
|
111
|
+
expect( response ).to be_a NebulousStomp::Message
|
114
112
|
expect( response.verb ).to eq('foo')
|
115
113
|
end
|
116
114
|
|
117
115
|
it 'returns a nebulous timeout if there is no response' do
|
118
116
|
request = new_request('accord', 'foo')
|
119
117
|
expect{ request.send_no_cache }.
|
120
|
-
to raise_exception
|
118
|
+
to raise_exception NebulousStomp::NebulousTimeout
|
121
119
|
|
122
120
|
end
|
123
121
|
|
@@ -139,7 +137,7 @@ describe NebRequest do
|
|
139
137
|
request = new_request('accord', 'foo')
|
140
138
|
|
141
139
|
response = request.send
|
142
|
-
expect( response ).to be_a
|
140
|
+
expect( response ).to be_a NebulousStomp::Message
|
143
141
|
expect( response.verb ).to eq('foo')
|
144
142
|
end
|
145
143
|
|
@@ -155,7 +153,7 @@ describe NebRequest do
|
|
155
153
|
request = new_request('accord', 'foo')
|
156
154
|
response = request.send
|
157
155
|
|
158
|
-
expect( response ).to be_a
|
156
|
+
expect( response ).to be_a NebulousStomp::Message
|
159
157
|
expect( response.verb ).to eq('frog')
|
160
158
|
end
|
161
159
|
|
@@ -175,7 +173,7 @@ describe NebRequest do
|
|
175
173
|
|
176
174
|
it 'returns a nebulous timeout if there is no response' do
|
177
175
|
request = new_request('accord', 'foo')
|
178
|
-
expect{ request.send }.to raise_exception
|
176
|
+
expect{ request.send }.to raise_exception NebulousStomp::NebulousTimeout
|
179
177
|
end
|
180
178
|
|
181
179
|
it 'still works if Redis is turned off in the config' do
|
@@ -184,7 +182,7 @@ describe NebRequest do
|
|
184
182
|
r = NebRequest.new('accord', 'tom', nil, nil, stomp_h, rh)
|
185
183
|
|
186
184
|
response = r.send
|
187
|
-
expect( response ).to be_a
|
185
|
+
expect( response ).to be_a NebulousStomp::Message
|
188
186
|
expect( response.verb ).to eq('foo')
|
189
187
|
end
|
190
188
|
|
data/spec/nebulous_spec.rb
CHANGED
@@ -2,87 +2,87 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'nebulous_stomp/param'
|
6
6
|
|
7
7
|
|
8
|
-
describe
|
8
|
+
describe NebulousStomp do
|
9
9
|
|
10
|
-
before {
|
11
|
-
after(:all) {
|
10
|
+
before { NebulousStomp::Param.reset }
|
11
|
+
after(:all) { NebulousStomp::Param.reset }
|
12
12
|
|
13
13
|
|
14
14
|
# Magically replaces the real Param module
|
15
|
-
let(:param) { class_double(
|
15
|
+
let(:param) { class_double(NebulousStomp::Param).as_stubbed_const }
|
16
16
|
|
17
17
|
|
18
18
|
it 'has a version number' do
|
19
|
-
expect(
|
19
|
+
expect(NebulousStomp::VERSION).not_to be nil
|
20
20
|
end
|
21
21
|
##
|
22
22
|
|
23
23
|
|
24
|
-
describe "
|
24
|
+
describe "NebulousStomp.set_logger" do
|
25
25
|
|
26
26
|
it "calls Param.set_logger" do
|
27
27
|
l = Logger.new(STDOUT)
|
28
28
|
expect(param).to receive(:set_logger).with(l)
|
29
|
-
|
29
|
+
NebulousStomp.set_logger(l)
|
30
30
|
end
|
31
31
|
|
32
32
|
end
|
33
33
|
##
|
34
34
|
|
35
35
|
|
36
|
-
describe '
|
36
|
+
describe 'NebulousStomp.logger' do
|
37
37
|
|
38
38
|
it 'returns the logger as set' do
|
39
39
|
l = Logger.new(STDOUT)
|
40
|
-
|
40
|
+
NebulousStomp.set_logger(l)
|
41
41
|
|
42
|
-
expect(
|
42
|
+
expect( NebulousStomp.logger ).to eq l
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'still works if no-one set the logger' do
|
46
|
-
expect{
|
47
|
-
expect(
|
46
|
+
expect{ NebulousStomp.logger }.not_to raise_exception
|
47
|
+
expect( NebulousStomp.logger ).to be_a_kind_of Logger
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
51
51
|
##
|
52
52
|
|
53
53
|
|
54
|
-
describe '
|
54
|
+
describe 'NebulousStomp.init' do
|
55
55
|
|
56
56
|
it 'calls Param.set' do
|
57
57
|
h = {one: 1, two: 2}
|
58
58
|
expect(param).to receive(:set).with(h)
|
59
|
-
|
59
|
+
NebulousStomp.init(h)
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
63
63
|
##
|
64
64
|
|
65
65
|
|
66
|
-
describe '
|
66
|
+
describe 'NebulousStomp.add_target' do
|
67
67
|
|
68
68
|
it 'calls Param.add_target' do
|
69
69
|
t1 = :foo; t2 = {bar: 'baz'}
|
70
70
|
expect(param).to receive(:add_target).with(t1, t2)
|
71
|
-
|
71
|
+
NebulousStomp.add_target(t1, t2)
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
75
75
|
##
|
76
76
|
|
77
77
|
|
78
|
-
describe '
|
78
|
+
describe 'NebulousStomp.on?' do
|
79
79
|
|
80
80
|
it 'should be true if there is anything in the stomp hash' do
|
81
81
|
allow(param).to receive(:get).
|
82
82
|
with(:stompConnectHash).
|
83
83
|
and_return( foo: 'bar' )
|
84
84
|
|
85
|
-
expect(
|
85
|
+
expect( NebulousStomp.on? ).to be_truthy
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should be false if the stomp hash is nil' do
|
@@ -90,7 +90,7 @@ describe Nebulous do
|
|
90
90
|
with(:stompConnectHash).
|
91
91
|
and_return( nil, {} )
|
92
92
|
|
93
|
-
expect(
|
93
|
+
expect( NebulousStomp.on? ).to be_falsy
|
94
94
|
end
|
95
95
|
|
96
96
|
|
@@ -98,14 +98,14 @@ describe Nebulous do
|
|
98
98
|
##
|
99
99
|
|
100
100
|
|
101
|
-
describe '
|
101
|
+
describe 'NebulousStomp.redis_on?' do
|
102
102
|
|
103
103
|
it 'is true if there is anything in the Redis connection hash' do
|
104
104
|
allow(param).to receive(:get).
|
105
105
|
with(:redisConnectHash).
|
106
106
|
and_return( foo: 'bar' )
|
107
107
|
|
108
|
-
expect(
|
108
|
+
expect( NebulousStomp.redis_on? ).to be_truthy
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'is false if the Redis hash is nil or empty' do
|
@@ -113,7 +113,7 @@ describe Nebulous do
|
|
113
113
|
with(:redisConnectHash).
|
114
114
|
and_return( nil, {} )
|
115
115
|
|
116
|
-
expect(
|
116
|
+
expect( NebulousStomp.redis_on? ).to be_falsy
|
117
117
|
end
|
118
118
|
|
119
119
|
end
|
data/spec/param_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require '
|
2
|
+
require 'nebulous_stomp/param'
|
3
3
|
|
4
|
-
include
|
4
|
+
include NebulousStomp
|
5
5
|
|
6
6
|
|
7
7
|
describe Param do
|
@@ -131,10 +131,10 @@ describe Param do
|
|
131
131
|
describe "Param.set_logger" do
|
132
132
|
|
133
133
|
it "requires an instance of Logger, or nil" do
|
134
|
-
expect{
|
134
|
+
expect{ NebulousStomp.set_logger(:foo) }.to raise_exception NebulousError
|
135
135
|
|
136
|
-
expect{
|
137
|
-
expect{
|
136
|
+
expect{ NebulousStomp.set_logger(nil) }.not_to raise_exception
|
137
|
+
expect{ NebulousStomp.set_logger( Logger.new(STDOUT) ) }.not_to raise_exception
|
138
138
|
end
|
139
139
|
|
140
140
|
end
|
data/spec/redis_handler_spec.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'nebulous_stomp/redis_handler'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
include Nebulous
|
5
|
+
include NebulousStomp
|
8
6
|
|
9
7
|
|
10
8
|
describe RedisHandler do
|
@@ -116,10 +114,10 @@ describe RedisHandler do
|
|
116
114
|
|
117
115
|
it 'raises ConnectionError if connect has not been called' do
|
118
116
|
expect{ handler.set("foo", {bar:1}) }.
|
119
|
-
to raise_exception
|
117
|
+
to raise_exception NebulousStomp::ConnectionError
|
120
118
|
|
121
|
-
expect{ handler.get("foo") }.to raise_exception
|
122
|
-
expect{ handler.del("foo") }.to raise_exception
|
119
|
+
expect{ handler.get("foo") }.to raise_exception NebulousStomp::ConnectionError
|
120
|
+
expect{ handler.del("foo") }.to raise_exception NebulousStomp::ConnectionError
|
123
121
|
end
|
124
122
|
|
125
123
|
it 'raises ConnectionError if not connected' do
|
@@ -127,10 +125,10 @@ describe RedisHandler do
|
|
127
125
|
handler.connect
|
128
126
|
|
129
127
|
expect{ handler.set("foo", {bar:1}) }.
|
130
|
-
to raise_exception
|
128
|
+
to raise_exception NebulousStomp::ConnectionError
|
131
129
|
|
132
|
-
expect{ handler.get("foo") }.to raise_exception
|
133
|
-
expect{ handler.del("foo") }.to raise_exception
|
130
|
+
expect{ handler.get("foo") }.to raise_exception NebulousStomp::ConnectionError
|
131
|
+
expect{ handler.del("foo") }.to raise_exception NebulousStomp::ConnectionError
|
134
132
|
end
|
135
133
|
|
136
134
|
|
@@ -2,9 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
require 'time'
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'nebulous_stomp/stomp_handler_null'
|
6
6
|
|
7
|
-
include
|
7
|
+
include NebulousStomp
|
8
8
|
|
9
9
|
|
10
10
|
describe StompHandlerNull do
|
@@ -47,7 +47,7 @@ describe StompHandlerNull do
|
|
47
47
|
|
48
48
|
it 'sets the message to send' do
|
49
49
|
handler.insert_fake( Message.from_parts('', '','foo', 'bar', 'baz') )
|
50
|
-
expect( handler.fake_mess ).to be_a_kind_of
|
50
|
+
expect( handler.fake_mess ).to be_a_kind_of NebulousStomp::Message
|
51
51
|
expect( handler.fake_mess.verb ).to eq 'foo'
|
52
52
|
end
|
53
53
|
|
@@ -92,7 +92,7 @@ describe StompHandlerNull do
|
|
92
92
|
|
93
93
|
|
94
94
|
describe "send_message" do
|
95
|
-
let(:mess) {
|
95
|
+
let(:mess) { NebulousStomp::Message.from_parts(nil, nil, 'foo', nil, nil) }
|
96
96
|
|
97
97
|
it "accepts a queue name and a Message" do
|
98
98
|
expect{ handler.send_message('foo', mess) }.not_to raise_exception
|
@@ -125,7 +125,7 @@ describe StompHandlerNull do
|
|
125
125
|
gotMessage = run_listen(1)
|
126
126
|
|
127
127
|
expect(gotMessage).not_to be_nil
|
128
|
-
expect(gotMessage).to be_a_kind_of
|
128
|
+
expect(gotMessage).to be_a_kind_of NebulousStomp::Message
|
129
129
|
end
|
130
130
|
|
131
131
|
end
|
@@ -150,7 +150,7 @@ describe StompHandlerNull do
|
|
150
150
|
gotMessage = run_listen_with_timeout(1)
|
151
151
|
|
152
152
|
expect( gotMessage ).not_to be_nil
|
153
|
-
expect( gotMessage ).to be_a_kind_of
|
153
|
+
expect( gotMessage ).to be_a_kind_of NebulousStomp::Message
|
154
154
|
end
|
155
155
|
|
156
156
|
end
|
@@ -159,7 +159,7 @@ describe StompHandlerNull do
|
|
159
159
|
|
160
160
|
it 'raises NebulousTimeout' do
|
161
161
|
expect{handler.listen_with_timeout('foo', 2)}.
|
162
|
-
to raise_exception
|
162
|
+
to raise_exception NebulousStomp::NebulousTimeout
|
163
163
|
|
164
164
|
end
|
165
165
|
|
data/spec/stomp_handler_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
require '
|
5
|
-
require '
|
4
|
+
require 'nebulous_stomp/stomp_handler'
|
5
|
+
require 'nebulous_stomp/message'
|
6
6
|
|
7
7
|
require_relative 'helpers'
|
8
8
|
|
9
|
-
include
|
9
|
+
include NebulousStomp
|
10
10
|
|
11
11
|
|
12
12
|
RSpec.configure do |c|
|
@@ -171,7 +171,7 @@ describe StompHandler do
|
|
171
171
|
hash = stomp_hash.merge( hosts: {passcode:'flurb'} )
|
172
172
|
sh = StompHandler.new(hash)
|
173
173
|
|
174
|
-
expect{sh.stomp_connect}.to raise_exception
|
174
|
+
expect{sh.stomp_connect}.to raise_exception NebulousStomp::ConnectionError
|
175
175
|
end
|
176
176
|
|
177
177
|
it "returns self" do
|
@@ -241,7 +241,7 @@ describe StompHandler do
|
|
241
241
|
handler.stomp_disconnect
|
242
242
|
|
243
243
|
expect{ handler.calc_reply_id }.
|
244
|
-
to raise_exception
|
244
|
+
to raise_exception NebulousStomp::ConnectionError
|
245
245
|
|
246
246
|
end
|
247
247
|
|
@@ -266,7 +266,7 @@ describe StompHandler do
|
|
266
266
|
# We're kind of navel gazing here because send_message is just one line: a
|
267
267
|
# call to client.publish. Still, call it a warming up exercise....
|
268
268
|
|
269
|
-
let(:mess) {
|
269
|
+
let(:mess) { NebulousStomp::Message.from_parts(nil, nil, 'foo', nil, nil) }
|
270
270
|
|
271
271
|
before do
|
272
272
|
handler.stomp_connect
|
@@ -277,7 +277,7 @@ describe StompHandler do
|
|
277
277
|
expect{ handler.send_message('foo') }.to raise_exception ArgumentError
|
278
278
|
expect{ handler.send_message(1,2,3) }.to raise_exception ArgumentError
|
279
279
|
expect{ handler.send_message('foo', 12) }.
|
280
|
-
to raise_exception
|
280
|
+
to raise_exception NebulousStomp::NebulousError
|
281
281
|
|
282
282
|
expect{ handler.send_message('foo', mess) }.not_to raise_exception
|
283
283
|
end
|
@@ -339,7 +339,7 @@ describe StompHandler do
|
|
339
339
|
gotMessage = run_listen(1)
|
340
340
|
|
341
341
|
expect(gotMessage).not_to be_nil
|
342
|
-
expect(gotMessage).to be_a_kind_of
|
342
|
+
expect(gotMessage).to be_a_kind_of NebulousStomp::Message
|
343
343
|
expect( gotMessage.verb ).to eq 'Foo'
|
344
344
|
end
|
345
345
|
|
@@ -352,7 +352,7 @@ describe StompHandler do
|
|
352
352
|
gotMessage = run_listen(2)
|
353
353
|
|
354
354
|
expect(gotMessage).not_to be_nil
|
355
|
-
expect(gotMessage).to be_a_kind_of
|
355
|
+
expect(gotMessage).to be_a_kind_of NebulousStomp::Message
|
356
356
|
expect( gotMessage.verb ).to eq 'Bar'
|
357
357
|
end
|
358
358
|
|
@@ -399,7 +399,7 @@ describe StompHandler do
|
|
399
399
|
stop = Time.now
|
400
400
|
|
401
401
|
expect( gotMessage ).not_to be_nil
|
402
|
-
expect( gotMessage ).to be_a_kind_of
|
402
|
+
expect( gotMessage ).to be_a_kind_of NebulousStomp::Message
|
403
403
|
expect( gotMessage.verb ).to eq 'Foo'
|
404
404
|
expect(stop - start).to be < 0.5
|
405
405
|
end
|
@@ -413,7 +413,7 @@ describe StompHandler do
|
|
413
413
|
gotMessage = run_listen_with_timeout(2)
|
414
414
|
|
415
415
|
expect( gotMessage ).not_to be_nil
|
416
|
-
expect( gotMessage ).to be_a_kind_of
|
416
|
+
expect( gotMessage ).to be_a_kind_of NebulousStomp::Message
|
417
417
|
expect( gotMessage.verb ).to eq 'Foo'
|
418
418
|
end
|
419
419
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nebulous_stomp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jones
|
@@ -174,16 +174,16 @@ files:
|
|
174
174
|
- Guardfile
|
175
175
|
- README.md
|
176
176
|
- Rakefile
|
177
|
-
- lib/
|
178
|
-
- lib/
|
179
|
-
- lib/
|
180
|
-
- lib/
|
181
|
-
- lib/
|
182
|
-
- lib/
|
183
|
-
- lib/
|
184
|
-
- lib/
|
185
|
-
- lib/
|
186
|
-
- lib/
|
177
|
+
- lib/nebulous_stomp.rb
|
178
|
+
- lib/nebulous_stomp/message.rb
|
179
|
+
- lib/nebulous_stomp/nebrequest.rb
|
180
|
+
- lib/nebulous_stomp/nebrequest_null.rb
|
181
|
+
- lib/nebulous_stomp/param.rb
|
182
|
+
- lib/nebulous_stomp/redis_handler.rb
|
183
|
+
- lib/nebulous_stomp/redis_handler_null.rb
|
184
|
+
- lib/nebulous_stomp/stomp_handler.rb
|
185
|
+
- lib/nebulous_stomp/stomp_handler_null.rb
|
186
|
+
- lib/nebulous_stomp/version.rb
|
187
187
|
- md/LICENSE.txt
|
188
188
|
- md/nebulous_protocol.md
|
189
189
|
- nebulous.gemspec
|
@@ -197,11 +197,10 @@ files:
|
|
197
197
|
- spec/redis_handler_null_spec.rb
|
198
198
|
- spec/redis_handler_spec.rb
|
199
199
|
- spec/spec_helper.rb
|
200
|
-
- spec/spec_helper_old.rb
|
201
200
|
- spec/stomp_handler_null_spec.rb
|
202
201
|
- spec/stomp_handler_spec.rb
|
203
202
|
- tags
|
204
|
-
homepage: https://bitbucket.org/andy-twosticks/
|
203
|
+
homepage: https://bitbucket.org/andy-twosticks/nebulous_stomp
|
205
204
|
licenses:
|
206
205
|
- MIT
|
207
206
|
metadata: {}
|
@@ -240,6 +239,6 @@ test_files:
|
|
240
239
|
- spec/redis_handler_null_spec.rb
|
241
240
|
- spec/redis_handler_spec.rb
|
242
241
|
- spec/spec_helper.rb
|
243
|
-
- spec/spec_helper_old.rb
|
244
242
|
- spec/stomp_handler_null_spec.rb
|
245
243
|
- spec/stomp_handler_spec.rb
|
244
|
+
has_rdoc:
|
data/lib/nebulous/version.rb
DELETED
data/spec/spec_helper_old.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
-
#require 'nebulous'
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
|
6
|
-
config.expect_with :rspec do |expectations|
|
7
|
-
expectations.include_chain_causes_in_custom_matcher_descriptions = true
|
8
|
-
end
|
9
|
-
|
10
|
-
config.mock_with :rspec do |mocks|
|
11
|
-
mocks.verify_partial_doubles = true
|
12
|
-
end
|
13
|
-
|
14
|
-
if config.files_to_run.one?
|
15
|
-
config.default_formatter = 'doc'
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
~
|