nebulous_stomp 3.0.5 → 3.0.6
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.
- checksums.yaml +4 -4
- data/lib/nebulous_stomp/msg/body.rb +16 -1
- data/lib/nebulous_stomp/version.rb +1 -1
- data/spec/message_spec.rb +7 -1
- data/spec/request_spec.rb +16 -0
- data/tags +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6f4a2145417269d91fb5af909112fc156acedd3
|
4
|
+
data.tar.gz: 239d92f6a514118ed89f5aef198e83bd241e9d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96fe76be982ddb17d8461b713f83be0cd69c8e566656c41d6727eac05222a7acff7ff1ece6021129837ecaaa40766b8d4fcf9a9e284333da348f827bd38959d
|
7
|
+
data.tar.gz: efc8c9a69b4c5d8a443f5a095b7c4893f75df7c9a2160a40109e44c7497f717a308e5db3d9f0f40e7f121b0e6aa1d5de10928480ce77b0d40a6b46200bc346c2
|
@@ -27,7 +27,7 @@ module NebulousStomp
|
|
27
27
|
#
|
28
28
|
def initialize(is_json, hash)
|
29
29
|
@is_json = !!is_json
|
30
|
-
@stomp_body = hash[:stompBody]
|
30
|
+
@stomp_body = fix_bad_encoding( hash[:stompBody] )
|
31
31
|
@body = hash[:body]
|
32
32
|
@verb = hash[:verb]
|
33
33
|
@params = hash[:parameters] || hash[:params]
|
@@ -162,6 +162,21 @@ module NebulousStomp
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
+
##
|
166
|
+
# Deal with encoding problems. Try ISO8859-1 first. (Sorry for the Western bias, but this
|
167
|
+
# solves a lot of use-cases for us.)
|
168
|
+
#
|
169
|
+
def fix_bad_encoding(string)
|
170
|
+
return nil if string.nil?
|
171
|
+
|
172
|
+
unless string.valid_encoding?
|
173
|
+
s = string.encode("UTF-8", "ISO8859-1")
|
174
|
+
string = s if s.valid_encoding?
|
175
|
+
end
|
176
|
+
|
177
|
+
string.encode!(invalid: :replace, undef: :replace) unless string.valid_encoding?
|
178
|
+
string
|
179
|
+
end
|
165
180
|
|
166
181
|
end # Message::Body
|
167
182
|
|
data/spec/message_spec.rb
CHANGED
@@ -126,7 +126,7 @@ describe Message do
|
|
126
126
|
expect( m.body ).to eq "wigi wigi"
|
127
127
|
end
|
128
128
|
|
129
|
-
it "leaves body alone if it
|
129
|
+
it "leaves body alone if it's an empty array and there is no protocol and no stompbody" do
|
130
130
|
# rather than processing a nil stompbody and ending up with nil/NULL
|
131
131
|
m = Message.new(body: [])
|
132
132
|
expect( m.body ).to eq([])
|
@@ -147,6 +147,12 @@ describe Message do
|
|
147
147
|
expect{ Message.new(body: 'bar') }.not_to raise_exception
|
148
148
|
end
|
149
149
|
|
150
|
+
it "encodes the stompbody if the encoding is not valid" do
|
151
|
+
m = Message.new(stompBody: "foo \xa2 bar")
|
152
|
+
expect( m.body ).to match /foo.*bar/
|
153
|
+
expect( m.body ).to be_valid_encoding
|
154
|
+
end
|
155
|
+
|
150
156
|
end # of Message.new
|
151
157
|
|
152
158
|
|
data/spec/request_spec.rb
CHANGED
@@ -54,6 +54,12 @@ describe Request do
|
|
54
54
|
request
|
55
55
|
end
|
56
56
|
|
57
|
+
let(:request2) do
|
58
|
+
request = new_request(target1, message1)
|
59
|
+
@stomp_handler.insert_fake Message.new(inReplyTo: request.message.reply_id, stompBody: "1 \xa2 2")
|
60
|
+
request
|
61
|
+
end
|
62
|
+
|
57
63
|
before(:each) do
|
58
64
|
# We shouldn't be calling Stomp or Redis in these tests. If we are, this will give us an error.
|
59
65
|
fakestomp = double("fakestomp")
|
@@ -170,6 +176,11 @@ describe Request do
|
|
170
176
|
expect( request.send_no_cache ).to be_nil
|
171
177
|
end
|
172
178
|
|
179
|
+
it "encodes the response message body from Stomp if the encoding was not valid" do
|
180
|
+
response = request2.send_no_cache
|
181
|
+
expect( response.body ).to be_valid_encoding
|
182
|
+
end
|
183
|
+
|
173
184
|
end # of #send_no_cache
|
174
185
|
|
175
186
|
|
@@ -254,6 +265,11 @@ describe Request do
|
|
254
265
|
expect( request.send ).to be_nil
|
255
266
|
end
|
256
267
|
|
268
|
+
it "encodes the response message body from Stomp if the encoding was not valid" do
|
269
|
+
response = request2.send
|
270
|
+
expect( response.body ).to be_valid_encoding
|
271
|
+
end
|
272
|
+
|
257
273
|
end # of #send
|
258
274
|
|
259
275
|
|
data/tags
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
2
2
|
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
3
|
+
Body lib/nebulous_stomp/msg/body.rb /^ class Body$/;" c class:NebulousStomp.Msg
|
3
4
|
ConnectionError lib/nebulous.rb /^ class ConnectionError < NebulousError; end$/;" c class:Nebulous inherits:NebulousError
|
4
5
|
DocNoPending spec/doc_no_pending.rb /^class DocNoPending < RSpec::Core::Formatters::DocumentationFormatter$/;" c inherits:RSpec.Core.Formatters.DocumentationFormatter
|
5
6
|
Helpers spec/helpers.rb /^module Helpers$/;" m
|
6
7
|
Message lib/nebulous/message.rb /^ class Message$/;" c class:Nebulous
|
8
|
+
Message lib/nebulous_stomp/message.rb /^ class Message$/;" c class:NebulousStomp
|
9
|
+
Msg lib/nebulous_stomp/msg/body.rb /^ module Msg$/;" m class:NebulousStomp
|
7
10
|
NebRequest lib/nebulous/nebrequest.rb /^ class NebRequest$/;" c class:Nebulous
|
8
11
|
NebRequestNull lib/nebulous/nebrequest_null.rb /^ class NebRequestNull < NebRequest$/;" c class:Nebulous inherits:NebRequest
|
9
12
|
Nebulous lib/nebulous.rb /^module Nebulous$/;" m
|
@@ -17,6 +20,8 @@ Nebulous lib/nebulous/stomp_handler.rb /^module Nebulous$/;" m
|
|
17
20
|
Nebulous lib/nebulous/stomp_handler_null.rb /^module Nebulous$/;" m
|
18
21
|
Nebulous lib/nebulous/version.rb /^module Nebulous$/;" m
|
19
22
|
NebulousError lib/nebulous.rb /^ class NebulousError < StandardError; end$/;" c class:Nebulous inherits:StandardError
|
23
|
+
NebulousStomp lib/nebulous_stomp/message.rb /^module NebulousStomp$/;" m
|
24
|
+
NebulousStomp lib/nebulous_stomp/msg/body.rb /^module NebulousStomp$/;" m
|
20
25
|
NebulousStomp lib/nebulous_stomp/redis_handler.rb /^module NebulousStomp$/;" m
|
21
26
|
NebulousStomp lib/nebulous_stomp/request.rb /^module NebulousStomp$/;" m
|
22
27
|
NebulousStomp lib/nebulous_stomp/stomp_handler.rb /^module NebulousStomp$/;" m
|
@@ -38,6 +43,7 @@ VERSION lib/nebulous/version.rb /^ VERSION = "1.1.5"$/;" C class:Nebulous
|
|
38
43
|
add_target lib/nebulous.rb /^ def self.add_target(name, targetHash) # -> nil$/;" F class:Nebulous
|
39
44
|
add_target lib/nebulous/param.rb /^ def add_target(n, t)$/;" f class:Nebulous.Param
|
40
45
|
body_for_stomp lib/nebulous/message.rb /^ def body_for_stomp$/;" f class:Nebulous.Message
|
46
|
+
body_for_stomp lib/nebulous_stomp/msg/body.rb /^ def body_for_stomp$/;" f class:NebulousStomp.Msg.Body
|
41
47
|
body_to_h lib/nebulous/message.rb /^ def body_to_h$/;" f class:Nebulous.Message
|
42
48
|
body_to_hash lib/nebulous/stomp_handler.rb /^ def body_to_hash(headers, body, contentType=nil)$/;" F class:Nebulous.StompHandler
|
43
49
|
cTimeout lib/nebulous/nebrequest.rb /^ attr_reader :cTimeout$/;" f class:Nebulous.NebRequest
|
@@ -73,9 +79,13 @@ example_pending spec/doc_no_pending.rb /^ def example_pending(notifications); e
|
|
73
79
|
fake_mess lib/nebulous/stomp_handler_null.rb /^ attr_reader :fake_mess$/;" f class:Nebulous.StompHandlerNull
|
74
80
|
fake_pair lib/nebulous/redis_handler_null.rb /^ attr_reader :fake_pair$/;" f class:Nebulous.RedisHandlerNull
|
75
81
|
fill_from_message lib/nebulous/message.rb /^ def fill_from_message$/;" f class:Nebulous.Message
|
82
|
+
fill_from_stomp lib/nebulous_stomp/msg/body.rb /^ def fill_from_stomp$/;" f class:NebulousStomp.Msg.Body
|
83
|
+
fix_bad_encoding lib/nebulous_stomp/msg/body.rb /^ def fix_bad_encoding(string)$/;" f class:NebulousStomp.Msg.Body
|
76
84
|
from_cache lib/nebulous/message.rb /^ def from_cache(json)$/;" F class:Nebulous.Message
|
85
|
+
from_cache lib/nebulous_stomp/message.rb /^ def from_cache(json)$/;" f class:NebulousStomp.Message
|
77
86
|
from_parts lib/nebulous/message.rb /^ def from_parts(replyTo, inReplyTo, verb, params, desc)$/;" F class:Nebulous.Message
|
78
87
|
from_stomp lib/nebulous/message.rb /^ def from_stomp(stompMsg)$/;" F class:Nebulous.Message
|
88
|
+
from_stomp lib/nebulous_stomp/message.rb /^ def from_stomp(stompMsg)$/;" f class:NebulousStomp.Message
|
79
89
|
get lib/nebulous/param.rb /^ def get(p)$/;" f class:Nebulous.Param
|
80
90
|
get lib/nebulous/redis_handler_null.rb /^ def get(key); @fake_pair.values.first; end$/;" f class:Nebulous.RedisHandlerNull
|
81
91
|
get_all lib/nebulous/param.rb /^ def get_all()$/;" f class:Nebulous.Param
|
@@ -84,6 +94,7 @@ get_target lib/nebulous/param.rb /^ def get_target(name)$/;" f class:Nebulous
|
|
84
94
|
headers_for_stomp lib/nebulous/message.rb /^ def headers_for_stomp$/;" f class:Nebulous.Message
|
85
95
|
in_reply_to lib/nebulous/message.rb /^ def in_reply_to(msg, verb, params=nil, desc=nil, replyTo=nil)$/;" F class:Nebulous.Message
|
86
96
|
in_reply_to lib/nebulous/message.rb /^ attr_reader :reply_to, :in_reply_to $/;" f class:Nebulous.Message
|
97
|
+
in_reply_to lib/nebulous_stomp/message.rb /^ def in_reply_to(msg, args)$/;" f class:NebulousStomp.Message
|
87
98
|
init lib/nebulous.rb /^ def self.init(paramHash={}) $/;" F class:Nebulous
|
88
99
|
initialize lib/nebulous/message.rb /^ def initialize(hash)$/;" f class:Nebulous.Message
|
89
100
|
initialize lib/nebulous/nebrequest.rb /^ def initialize( target, $/;" f class:Nebulous.NebRequest
|
@@ -92,6 +103,8 @@ initialize lib/nebulous/redis_handler.rb /^ def initialize(connectHash, testR
|
|
92
103
|
initialize lib/nebulous/redis_handler_null.rb /^ def initialize(connectHash={})$/;" f class:Nebulous.RedisHandlerNull
|
93
104
|
initialize lib/nebulous/stomp_handler.rb /^ def initialize(connectHash, testClient=nil)$/;" f class:Nebulous.StompHandler
|
94
105
|
initialize lib/nebulous/stomp_handler_null.rb /^ def initialize(hash={})$/;" f class:Nebulous.StompHandlerNull
|
106
|
+
initialize lib/nebulous_stomp/message.rb /^ def initialize(hash)$/;" f class:NebulousStomp
|
107
|
+
initialize lib/nebulous_stomp/msg/body.rb /^ def initialize(is_json, hash)$/;" f class:NebulousStomp.Msg.Body
|
95
108
|
initialize lib/nebulous_stomp/redis_handler.rb /^ def initialize(connectHash=nil, testRedis=nil)$/;" f class:NebulousStomp.RedisHandler
|
96
109
|
initialize lib/nebulous_stomp/request.rb /^ def initialize(target, message)$/;" f class:NebulousStomp.Request
|
97
110
|
initialize lib/nebulous_stomp/stomp_handler.rb /^ def initialize(connectHash=nil, testClient=nil)$/;" f class:NebulousStomp
|
@@ -127,10 +140,14 @@ on? lib/nebulous.rb /^ def self.on?$/;" F class:Nebulous
|
|
127
140
|
parameters lib/nebulous/message.rb /^ alias :parameters :params$/;" a class:Nebulous.Message
|
128
141
|
params lib/nebulous/message.rb /^ attr_reader :verb, :params, :desc$/;" f class:Nebulous.Message
|
129
142
|
params lib/nebulous/nebrequest.rb /^ attr_reader :params $/;" f class:Nebulous.NebRequest
|
143
|
+
parse_body lib/nebulous_stomp/msg/body.rb /^ def parse_body$/;" f class:NebulousStomp.Msg.Body
|
130
144
|
parse_message lib/nebulous_stomp/request.rb /^ def parse_message(message, target)$/;" f class:NebulousStomp.Request
|
145
|
+
parse_stomp_body lib/nebulous_stomp/msg/body.rb /^ def parse_stomp_body$/;" f class:NebulousStomp.Msg.Body
|
131
146
|
parse_target lib/nebulous_stomp/request.rb /^ def parse_target(target)$/;" f class:NebulousStomp.Request
|
132
147
|
protocol_hash lib/nebulous/message.rb /^ def protocol_hash$/;" f class:Nebulous.Message
|
148
|
+
protocol_hash lib/nebulous_stomp/msg/body.rb /^ def protocol_hash$/;" f class:NebulousStomp.Msg.Body
|
133
149
|
protocol_json lib/nebulous/message.rb /^ def protocol_json$/;" f class:Nebulous.Message
|
150
|
+
protocol_json lib/nebulous_stomp/msg/body.rb /^ def protocol_json$/;" f class:NebulousStomp.Msg.Body
|
134
151
|
quit lib/nebulous/redis_handler.rb /^ def quit$/;" f class:Nebulous.RedisHandler
|
135
152
|
quit lib/nebulous/redis_handler_null.rb /^ def quit$/;" f class:Nebulous.RedisHandlerNull
|
136
153
|
quit lib/nebulous_stomp/redis_handler.rb /^ def quit$/;" f class:NebulousStomp.RedisHandler
|
@@ -146,12 +163,16 @@ reply_id= lib/nebulous/message.rb /^ attr_accessor :reply_id$/;" f class:Nebu
|
|
146
163
|
reply_to lib/nebulous/message.rb /^ attr_reader :reply_to, :in_reply_to $/;" f class:Nebulous.Message
|
147
164
|
requestQ lib/nebulous/nebrequest.rb /^ attr_reader :requestQ$/;" f class:Nebulous.NebRequest
|
148
165
|
reset lib/nebulous/param.rb /^ def reset$/;" f class:Nebulous.Param
|
166
|
+
respond lib/nebulous_stomp/message.rb /^ def respond(body)$/;" f class:NebulousStomp
|
149
167
|
respond_error lib/nebulous/message.rb /^ def respond_error(err,fields=[])$/;" f class:Nebulous.Message
|
150
168
|
respond_error lib/nebulous/stomp_handler_null.rb /^ def respond_error(nebMess,err,fields=[])$/;" f class:Nebulous.StompHandlerNull
|
151
169
|
respond_error lib/nebulous_stomp/stomp_handler_null.rb /^ def respond_error(nebMess,err,fields=[])$/;" f class:NebulousStomp.StompHandlerNull
|
152
170
|
respond_success lib/nebulous/message.rb /^ def respond_success$/;" f class:Nebulous.Message
|
153
171
|
respond_success lib/nebulous/stomp_handler_null.rb /^ def respond_success(nebMess)$/;" f class:Nebulous.StompHandlerNull
|
154
172
|
respond_success lib/nebulous_stomp/stomp_handler_null.rb /^ def respond_success(nebMess)$/;" f class:NebulousStomp.StompHandlerNull
|
173
|
+
respond_with_error lib/nebulous_stomp/message.rb /^ def respond_with_error(err, fields=[])$/;" f class:NebulousStomp
|
174
|
+
respond_with_protocol lib/nebulous_stomp/message.rb /^ def respond_with_protocol(verb, params=[], desc="")$/;" f class:NebulousStomp
|
175
|
+
respond_with_success lib/nebulous_stomp/message.rb /^ def respond_with_success$/;" f class:NebulousStomp
|
155
176
|
responseQ lib/nebulous/nebrequest.rb /^ attr_reader :responseQ$/;" f class:Nebulous.NebRequest
|
156
177
|
run_listen spec/stomp_handler_null_spec.rb /^ def run_listen(secs)$/;" f
|
157
178
|
run_listen_with_timeout spec/stomp_handler_null_spec.rb /^ def run_listen_with_timeout(secs)$/;" f
|
@@ -168,6 +189,8 @@ set lib/nebulous/redis_handler_null.rb /^ def set(key, value, hash=nil); inse
|
|
168
189
|
set_logger lib/nebulous.rb /^ def self.set_logger(logger)$/;" F class:Nebulous
|
169
190
|
set_logger lib/nebulous/param.rb /^ def set_logger(lg)$/;" f class:Nebulous.Param
|
170
191
|
stomp_body lib/nebulous/message.rb /^ attr_reader :stomp_headers, :stomp_body$/;" f class:Nebulous.Message
|
192
|
+
stomp_body_from_json lib/nebulous_stomp/msg/body.rb /^ def stomp_body_from_json$/;" f class:NebulousStomp.Msg.Body
|
193
|
+
stomp_body_from_text lib/nebulous_stomp/msg/body.rb /^ def stomp_body_from_text$/;" f class:NebulousStomp.Msg.Body
|
171
194
|
stomp_connect lib/nebulous/stomp_handler.rb /^ def stomp_connect$/;" f class:Nebulous.StompHandler
|
172
195
|
stomp_connect lib/nebulous/stomp_handler_null.rb /^ def stomp_connect$/;" f class:Nebulous.StompHandlerNull
|
173
196
|
stomp_connect lib/nebulous_stomp/stomp_handler.rb /^ def stomp_connect$/;" f class:NebulousStomp
|
@@ -183,7 +206,10 @@ stomp_message spec/helpers.rb /^ def stomp_message(contentType, body, inReplyTo
|
|
183
206
|
symbolise spec/message_spec.rb /^ def symbolise(hash)$/;" f
|
184
207
|
target lib/nebulous/nebrequest.rb /^ attr_reader :target$/;" f class:Nebulous.NebRequest
|
185
208
|
to_cache lib/nebulous/message.rb /^ def to_cache$/;" f class:Nebulous.Message
|
209
|
+
to_h lib/nebulous_stomp/message.rb /^ def to_h$/;" f class:NebulousStomp
|
210
|
+
to_h lib/nebulous_stomp/msg/body.rb /^ def to_h$/;" f class:NebulousStomp.Msg.Body
|
186
211
|
to_s lib/nebulous/message.rb /^ def to_s$/;" f class:Nebulous.Message
|
212
|
+
to_s lib/nebulous_stomp/message.rb /^ def to_s$/;" f class:NebulousStomp
|
187
213
|
turn_off_nebulous spec/request_spec.rb /^ def turn_off_nebulous$/;" f
|
188
214
|
turn_off_redis spec/request_spec.rb /^ def turn_off_redis$/;" f
|
189
215
|
validate lib/nebulous/param.rb /^ def validate(exemplar, hash, message)$/;" f class:Nebulous.Param
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nebulous_stomp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|