amq-protocol 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/codegen/codegen_helpers.py +5 -5
- data/codegen/protocol.rb.pytemplate +5 -3
- data/lib/amq/endianness.rb +15 -0
- data/lib/amq/hacks.rb +33 -13
- data/lib/amq/protocol/client.rb +12 -14
- data/lib/amq/protocol/frame.rb +1 -1
- data/lib/amq/protocol/table_value_decoder.rb +6 -9
- data/lib/amq/protocol/type_constants.rb +8 -8
- data/lib/amq/protocol/version.rb +1 -1
- data/spec/amq/hacks_spec.rb +10 -10
- data/spec/amq/protocol/table_spec.rb +13 -9
- data/spec/spec_helper.rb +3 -1
- metadata +3 -3
data/codegen/codegen_helpers.py
CHANGED
@@ -16,9 +16,9 @@ def genSingleEncode(spec, cValue, unresolved_domain):
|
|
16
16
|
elif type == 'long':
|
17
17
|
buffer.append("buffer << [%s].pack(PACK_UINT32)" % (cValue,))
|
18
18
|
elif type == 'longlong':
|
19
|
-
buffer.append("buffer << AMQ::Hacks.
|
19
|
+
buffer.append("buffer << AMQ::Hacks.pack_uint64_big_endian(%s)" % (cValue,))
|
20
20
|
elif type == 'timestamp':
|
21
|
-
buffer.append("buffer << AMQ::Hacks.
|
21
|
+
buffer.append("buffer << AMQ::Hacks.pack_uint64_big_endian(%s)" % (cValue,))
|
22
22
|
elif type == 'bit':
|
23
23
|
raise "Can't encode bit in genSingleEncode"
|
24
24
|
elif type == 'table':
|
@@ -58,7 +58,7 @@ def genSingleDecode(spec, field):
|
|
58
58
|
buffer.append("%s = data[offset, 4].unpack(PACK_UINT32).first" % (cLvalue,))
|
59
59
|
buffer.append("offset += 4")
|
60
60
|
elif type == 'longlong':
|
61
|
-
buffer.append("%s = AMQ::Hacks.
|
61
|
+
buffer.append("%s = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first" % (cLvalue,))
|
62
62
|
buffer.append("offset += 8")
|
63
63
|
elif type == 'timestamp':
|
64
64
|
buffer.append("%s = data[offset, 8].unpack(PACK_UINT32_X2).first" % (cLvalue,))
|
@@ -91,13 +91,13 @@ def genSingleSimpleDecode(spec, field):
|
|
91
91
|
elif type == 'longstr':
|
92
92
|
buffer.append("data.to_s")
|
93
93
|
elif type == 'octet':
|
94
|
-
buffer.append("data.unpack(
|
94
|
+
buffer.append("data.unpack(PACK_INT8).first")
|
95
95
|
elif type == 'short':
|
96
96
|
buffer.append("data.unpack(PACK_UINT16).first")
|
97
97
|
elif type == 'long':
|
98
98
|
buffer.append("data.unpack(PACK_UINT32).first")
|
99
99
|
elif type == 'longlong':
|
100
|
-
buffer.append("AMQ::Hacks.
|
100
|
+
buffer.append("AMQ::Hacks.unpack_uint64_big_endian(data).first")
|
101
101
|
elif type == 'timestamp':
|
102
102
|
buffer.append("Time.at(data.unpack(PACK_UINT32_X2).last)")
|
103
103
|
elif type == 'bit':
|
@@ -20,6 +20,7 @@ module AMQ
|
|
20
20
|
# caching
|
21
21
|
EMPTY_STRING = "".freeze
|
22
22
|
|
23
|
+
PACK_INT8 = 'c'.freeze
|
23
24
|
PACK_CHAR = 'C'.freeze
|
24
25
|
PACK_UINT16 = 'n'.freeze
|
25
26
|
PACK_UINT16_X2 = 'n2'.freeze
|
@@ -30,7 +31,7 @@ module AMQ
|
|
30
31
|
PACK_CHAR_UINT16_UINT32 = 'cnN'.freeze
|
31
32
|
|
32
33
|
PACK_32BIT_FLOAT = 'f'.freeze
|
33
|
-
PACK_64BIT_FLOAT = '
|
34
|
+
PACK_64BIT_FLOAT = 'G'.freeze
|
34
35
|
|
35
36
|
|
36
37
|
|
@@ -262,7 +263,7 @@ module AMQ
|
|
262
263
|
|
263
264
|
# result = [${klass.index}, 0, body_size, flags].pack('n2Qn')
|
264
265
|
result = [${klass.index}, 0].pack(PACK_UINT16_X2)
|
265
|
-
result += AMQ::Hacks.
|
266
|
+
result += AMQ::Hacks.pack_uint64_big_endian(body_size)
|
266
267
|
result += [flags].pack(PACK_UINT16)
|
267
268
|
result + pieces.join(EMPTY_STRING)
|
268
269
|
end
|
@@ -392,7 +393,8 @@ module AMQ
|
|
392
393
|
frames << HeaderFrame.new(properties_payload, channel)
|
393
394
|
% endif
|
394
395
|
% if "payload" in method.args():
|
395
|
-
frames
|
396
|
+
frames += self.encode_body(payload, channel, frame_size)
|
397
|
+
frames
|
396
398
|
% endif
|
397
399
|
% else:
|
398
400
|
MethodFrame.new(buffer, channel)
|
data/lib/amq/hacks.rb
CHANGED
@@ -1,33 +1,53 @@
|
|
1
1
|
# encoding: binary
|
2
2
|
|
3
|
+
require 'amq/endianness'
|
4
|
+
|
3
5
|
# Ruby doesn't support pack to/unpack from
|
4
6
|
# 64bit string in network byte order.
|
5
7
|
module AMQ
|
6
8
|
module Hacks
|
7
|
-
|
8
|
-
|
9
|
+
UINT64 = "Q".freeze
|
10
|
+
INT16 = "c".freeze
|
11
|
+
|
12
|
+
if Endianness.big_endian?
|
13
|
+
def self.pack_uint64_big_endian(long_long)
|
14
|
+
[long_long].pack(UINT64)
|
15
|
+
end
|
9
16
|
|
10
|
-
|
11
|
-
|
12
|
-
[long_long].pack(Q)
|
17
|
+
def self.unpack_uint64_big_endian(data)
|
18
|
+
data.unpack(UINT64)
|
13
19
|
end
|
14
20
|
|
15
|
-
def self.
|
16
|
-
|
21
|
+
def self.pack_int16_big_endian(short)
|
22
|
+
[long_long].pack(INT16)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.unpack_int16_big_endian(data)
|
26
|
+
data.unpack(INT16)
|
17
27
|
end
|
18
28
|
else
|
19
|
-
def self.
|
20
|
-
result = [long_long].pack(
|
29
|
+
def self.pack_uint64_big_endian(long_long)
|
30
|
+
result = [long_long].pack(UINT64)
|
31
|
+
result.bytes.to_a.reverse.map(&:chr).join
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.unpack_uint64_big_endian(data)
|
35
|
+
data = data.bytes.to_a.reverse.map(&:chr).join
|
36
|
+
data.unpack(UINT64)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.pack_int16_big_endian(short)
|
40
|
+
result = [long_long].pack(INT16)
|
21
41
|
result.bytes.to_a.reverse.map(&:chr).join
|
22
42
|
end
|
23
43
|
|
24
|
-
def self.
|
44
|
+
def self.unpack_int16_big_endian(data)
|
25
45
|
data = data.bytes.to_a.reverse.map(&:chr).join
|
26
|
-
data.unpack(
|
46
|
+
data.unpack(INT16)
|
27
47
|
end
|
28
48
|
end
|
29
49
|
end
|
30
50
|
end
|
31
51
|
|
32
|
-
# AMQ::Hacks.
|
33
|
-
# AMQ::Hacks.
|
52
|
+
# AMQ::Hacks.pack_uint64_big_endian(17)
|
53
|
+
# AMQ::Hacks.unpack_uint64_big_endian("\x00\x00\x00\x00\x00\x00\x00\x11")
|
data/lib/amq/protocol/client.rb
CHANGED
@@ -19,6 +19,7 @@ module AMQ
|
|
19
19
|
# caching
|
20
20
|
EMPTY_STRING = "".freeze
|
21
21
|
|
22
|
+
PACK_INT8 = 'c'.freeze
|
22
23
|
PACK_CHAR = 'C'.freeze
|
23
24
|
PACK_UINT16 = 'n'.freeze
|
24
25
|
PACK_UINT16_X2 = 'n2'.freeze
|
@@ -29,10 +30,7 @@ module AMQ
|
|
29
30
|
PACK_CHAR_UINT16_UINT32 = 'cnN'.freeze
|
30
31
|
|
31
32
|
PACK_32BIT_FLOAT = 'f'.freeze
|
32
|
-
PACK_64BIT_FLOAT = '
|
33
|
-
|
34
|
-
PACK_SIGNED_8BIT = 'c'.freeze
|
35
|
-
PACK_SIGNED_16BIT = 's'.freeze
|
33
|
+
PACK_64BIT_FLOAT = 'G'.freeze
|
36
34
|
|
37
35
|
|
38
36
|
|
@@ -268,6 +266,7 @@ module AMQ
|
|
268
266
|
array = Array.new
|
269
267
|
while body
|
270
268
|
payload, body = body[0, limit], body[limit, body.length - limit]
|
269
|
+
# array << [0x03, payload]
|
271
270
|
array << BodyFrame.new(payload, channel)
|
272
271
|
end
|
273
272
|
|
@@ -1438,7 +1437,7 @@ module AMQ
|
|
1438
1437
|
# 1 << 6
|
1439
1438
|
def self.encode_timestamp(value)
|
1440
1439
|
buffer = ''
|
1441
|
-
buffer << AMQ::Hacks.
|
1440
|
+
buffer << AMQ::Hacks.pack_uint64_big_endian(value)
|
1442
1441
|
[9, 0x0040, buffer]
|
1443
1442
|
end
|
1444
1443
|
|
@@ -1487,7 +1486,7 @@ module AMQ
|
|
1487
1486
|
|
1488
1487
|
# result = [60, 0, body_size, flags].pack('n2Qn')
|
1489
1488
|
result = [60, 0].pack(PACK_UINT16_X2)
|
1490
|
-
result += AMQ::Hacks.
|
1489
|
+
result += AMQ::Hacks.pack_uint64_big_endian(body_size)
|
1491
1490
|
result += [flags].pack(PACK_UINT16)
|
1492
1491
|
result + pieces.join(EMPTY_STRING)
|
1493
1492
|
end
|
@@ -1796,7 +1795,6 @@ module AMQ
|
|
1796
1795
|
properties_payload = Basic.encode_properties(payload.bytesize, properties)
|
1797
1796
|
frames << HeaderFrame.new(properties_payload, channel)
|
1798
1797
|
frames += self.encode_body(payload, channel, frame_size)
|
1799
|
-
|
1800
1798
|
frames
|
1801
1799
|
end
|
1802
1800
|
|
@@ -1856,7 +1854,7 @@ module AMQ
|
|
1856
1854
|
offset += 1
|
1857
1855
|
consumer_tag = data[offset, length]
|
1858
1856
|
offset += length
|
1859
|
-
delivery_tag = AMQ::Hacks.
|
1857
|
+
delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
|
1860
1858
|
offset += 8
|
1861
1859
|
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
1862
1860
|
offset += 1
|
@@ -1925,7 +1923,7 @@ module AMQ
|
|
1925
1923
|
# @return
|
1926
1924
|
def self.decode(data)
|
1927
1925
|
offset = 0
|
1928
|
-
delivery_tag = AMQ::Hacks.
|
1926
|
+
delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
|
1929
1927
|
offset += 8
|
1930
1928
|
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
1931
1929
|
offset += 1
|
@@ -1996,7 +1994,7 @@ module AMQ
|
|
1996
1994
|
# @return
|
1997
1995
|
def self.decode(data)
|
1998
1996
|
offset = 0
|
1999
|
-
delivery_tag = AMQ::Hacks.
|
1997
|
+
delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
|
2000
1998
|
offset += 8
|
2001
1999
|
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
2002
2000
|
offset += 1
|
@@ -2019,7 +2017,7 @@ module AMQ
|
|
2019
2017
|
def self.encode(channel, delivery_tag, multiple)
|
2020
2018
|
buffer = ''
|
2021
2019
|
buffer << @packed_indexes
|
2022
|
-
buffer << AMQ::Hacks.
|
2020
|
+
buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag)
|
2023
2021
|
bit_buffer = 0
|
2024
2022
|
bit_buffer = bit_buffer | (1 << 0) if multiple
|
2025
2023
|
buffer << [bit_buffer].pack(PACK_CHAR)
|
@@ -2044,7 +2042,7 @@ module AMQ
|
|
2044
2042
|
def self.encode(channel, delivery_tag, requeue)
|
2045
2043
|
buffer = ''
|
2046
2044
|
buffer << @packed_indexes
|
2047
|
-
buffer << AMQ::Hacks.
|
2045
|
+
buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag)
|
2048
2046
|
bit_buffer = 0
|
2049
2047
|
bit_buffer = bit_buffer | (1 << 0) if requeue
|
2050
2048
|
buffer << [bit_buffer].pack(PACK_CHAR)
|
@@ -2132,7 +2130,7 @@ module AMQ
|
|
2132
2130
|
# @return
|
2133
2131
|
def self.decode(data)
|
2134
2132
|
offset = 0
|
2135
|
-
delivery_tag = AMQ::Hacks.
|
2133
|
+
delivery_tag = AMQ::Hacks.unpack_uint64_big_endian(data[offset, 8]).first
|
2136
2134
|
offset += 8
|
2137
2135
|
bit_buffer = data[offset, 1].unpack(PACK_CHAR).first
|
2138
2136
|
offset += 1
|
@@ -2157,7 +2155,7 @@ module AMQ
|
|
2157
2155
|
def self.encode(channel, delivery_tag, multiple, requeue)
|
2158
2156
|
buffer = ''
|
2159
2157
|
buffer << @packed_indexes
|
2160
|
-
buffer << AMQ::Hacks.
|
2158
|
+
buffer << AMQ::Hacks.pack_uint64_big_endian(delivery_tag)
|
2161
2159
|
bit_buffer = 0
|
2162
2160
|
bit_buffer = bit_buffer | (1 << 0) if multiple
|
2163
2161
|
bit_buffer = bit_buffer | (1 << 1) if requeue
|
data/lib/amq/protocol/frame.rb
CHANGED
@@ -161,7 +161,7 @@ This functionality is part of the https://github.com/ruby-amqp/amq-client librar
|
|
161
161
|
# the total size of the content body, that is, the sum of the body sizes for the
|
162
162
|
# following content body frames. Zero indicates that there are no content body frames.
|
163
163
|
# So this is NOT related to this very header frame!
|
164
|
-
@body_size = AMQ::Hacks.
|
164
|
+
@body_size = AMQ::Hacks.unpack_uint64_big_endian(@payload[4..11]).first
|
165
165
|
@data = @payload[12..-1]
|
166
166
|
@properties = Basic.decode_properties(@data)
|
167
167
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: binary
|
2
2
|
|
3
|
+
require "amq/endianness"
|
3
4
|
require "amq/protocol/client"
|
4
5
|
require "amq/protocol/type_constants"
|
5
6
|
require "amq/protocol/table"
|
@@ -20,10 +21,6 @@ module AMQ
|
|
20
21
|
# API
|
21
22
|
#
|
22
23
|
|
23
|
-
BIG_ENDIAN = ([1].pack("s") == "\x00\x01")
|
24
|
-
Q = "q".freeze
|
25
|
-
|
26
|
-
|
27
24
|
def self.decode_array(data, initial_offset)
|
28
25
|
array_length = data.slice(initial_offset, 4).unpack(PACK_UINT32).first
|
29
26
|
|
@@ -102,9 +99,9 @@ module AMQ
|
|
102
99
|
end # self.decode_integer(data, offset)
|
103
100
|
|
104
101
|
|
105
|
-
if
|
102
|
+
if AMQ::Endianness.big_endian?
|
106
103
|
def self.decode_long(data, offset)
|
107
|
-
v = data.slice(offset, 8).unpack(
|
104
|
+
v = data.slice(offset, 8).unpack(PACK_INT64)
|
108
105
|
|
109
106
|
offset += 8
|
110
107
|
[v, offset]
|
@@ -112,7 +109,7 @@ module AMQ
|
|
112
109
|
else
|
113
110
|
def self.decode_long(data, offset)
|
114
111
|
slice = data.slice(offset, 8).bytes.to_a.reverse.map(&:chr).join
|
115
|
-
v = slice.unpack(
|
112
|
+
v = slice.unpack(PACK_INT64).first
|
116
113
|
|
117
114
|
offset += 8
|
118
115
|
[v, offset]
|
@@ -177,13 +174,13 @@ module AMQ
|
|
177
174
|
|
178
175
|
|
179
176
|
def self.decode_short_short(data, offset)
|
180
|
-
v = data.slice(offset, 1).unpack(
|
177
|
+
v = data.slice(offset, 1).unpack(PACK_INT8).first
|
181
178
|
offset += 1
|
182
179
|
[v, offset]
|
183
180
|
end
|
184
181
|
|
185
182
|
def self.decode_short(data, offset)
|
186
|
-
v = data.slice(offset, 2)
|
183
|
+
v = AMQ::Hacks.unpack_int16_big_endian(data.slice(offset, 2)).first
|
187
184
|
offset += 2
|
188
185
|
[v, offset]
|
189
186
|
end
|
@@ -5,18 +5,18 @@ module AMQ
|
|
5
5
|
module TypeConstants
|
6
6
|
TYPE_STRING = 'S'.freeze
|
7
7
|
TYPE_INTEGER = 'I'.freeze
|
8
|
-
TYPE_HASH = 'F'.freeze
|
9
8
|
TYPE_TIME = 'T'.freeze
|
10
9
|
TYPE_DECIMAL = 'D'.freeze
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
TYPE_SIGNED_64BIT = 'l'.freeze
|
15
|
-
TYPE_32BIT_FLOAT = 'f'.freeze
|
10
|
+
TYPE_HASH = 'F'.freeze
|
11
|
+
TYPE_ARRAY = 'A'.freeze
|
12
|
+
TYPE_SIGNED_8BIT = 'b'.freeze
|
16
13
|
TYPE_64BIT_FLOAT = 'd'.freeze
|
17
|
-
|
14
|
+
TYPE_32BIT_FLOAT = 'f'.freeze
|
15
|
+
TYPE_SIGNED_64BIT = 'l'.freeze
|
16
|
+
TYPE_SIGNED_16BIT = 's'.freeze
|
17
|
+
TYPE_BOOLEAN = 't'.freeze
|
18
18
|
TYPE_BYTE_ARRAY = 'x'.freeze
|
19
|
-
|
19
|
+
TYPE_VOID = 'V'.freeze
|
20
20
|
TEN = '10'.freeze
|
21
21
|
|
22
22
|
BOOLEAN_TRUE = "\x01".freeze
|
data/lib/amq/protocol/version.rb
CHANGED
data/spec/amq/hacks_spec.rb
CHANGED
@@ -21,40 +21,40 @@ module AMQ
|
|
21
21
|
|
22
22
|
it "packs integers into big-endian string" do
|
23
23
|
examples.each do |key, value|
|
24
|
-
described_class.
|
24
|
+
described_class.pack_uint64_big_endian(key).should == value
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should unpack string representation into integer" do
|
29
29
|
examples.each do |key, value|
|
30
|
-
described_class.
|
30
|
+
described_class.unpack_uint64_big_endian(value)[0].should == key
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
if RUBY_VERSION < '1.9'
|
35
35
|
describe "with utf encoding" do
|
36
36
|
before do
|
37
37
|
$KCODE = 'u'
|
38
38
|
end
|
39
|
-
|
40
|
-
after do
|
39
|
+
|
40
|
+
after do
|
41
41
|
$KCODE = 'NONE'
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "packs integers into big-endian string" do
|
45
45
|
examples.each do |key, value|
|
46
|
-
described_class.
|
46
|
+
described_class.pack_uint64_big_endian(key).should == value
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should unpack string representation into integer" do
|
51
51
|
examples.each do |key, value|
|
52
|
-
described_class.
|
52
|
+
described_class.unpack_uint64_big_endian(value)[0].should == key
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
end
|
59
59
|
end
|
60
|
-
end
|
60
|
+
end
|
@@ -18,7 +18,7 @@ module AMQ
|
|
18
18
|
{
|
19
19
|
{} => "\000\000\000\000",
|
20
20
|
{"test" => 1} => "\000\000\000\n\004testI\000\000\000\001",
|
21
|
-
{"float" => 1.87} => "\000\000\000\017\005floatd\
|
21
|
+
{"float" => 1.87} => "\000\000\000\017\005floatd?\375\353\205\036\270Q\354",
|
22
22
|
{"test" => "string"} => "\000\000\000\020\004testS\000\000\000\006string",
|
23
23
|
{"test" => {}} => "\000\000\000\n\004testF\000\000\000\000",
|
24
24
|
{"test" => bigdecimal_1} => "\000\000\000\v\004testD\000\000\000\000\001",
|
@@ -29,7 +29,7 @@ module AMQ
|
|
29
29
|
{
|
30
30
|
{} => "\x00\x00\x00\x00",
|
31
31
|
{"test" => 1} => "\x00\x00\x00\n\x04testI\x00\x00\x00\x01",
|
32
|
-
{"float" => 1.92} => "\x00\x00\x00\x0F\x05floatd\
|
32
|
+
{"float" => 1.92} => "\x00\x00\x00\x0F\x05floatd?\xFE\xB8Q\xEB\x85\x1E\xB8",
|
33
33
|
{"test" => "string"} => "\x00\x00\x00\x10\x04testS\x00\x00\x00\x06string",
|
34
34
|
{"test" => {}} => "\x00\x00\x00\n\x04testF\x00\x00\x00\x00",
|
35
35
|
{"test" => bigdecimal_1} => "\x00\x00\x00\v\x04testD\x00\x00\x00\x00\x01",
|
@@ -49,20 +49,20 @@ module AMQ
|
|
49
49
|
Table.encode(nil).should eql(encoded_value)
|
50
50
|
end
|
51
51
|
|
52
|
-
it "should
|
52
|
+
it "should serialize { :test => true }" do
|
53
53
|
Table.encode(:test => true).should eql("\x00\x00\x00\a\x04testt\x01")
|
54
54
|
end
|
55
55
|
|
56
|
-
it "should
|
56
|
+
it "should serialize { :test => false }" do
|
57
57
|
Table.encode(:test => false).should eql("\x00\x00\x00\a\x04testt\x00")
|
58
58
|
end
|
59
59
|
|
60
|
-
it "should
|
61
|
-
Table.encode(:coordinates => { :latitude => 59.35 }).should eql("\
|
60
|
+
it "should serialize { :coordinates => { :latitude => 59.35 } }" do
|
61
|
+
Table.encode(:coordinates => { :latitude => 59.35 }).should eql("\x00\x00\x00#\vcoordinatesF\x00\x00\x00\x12\blatituded@M\xAC\xCC\xCC\xCC\xCC\xCD")
|
62
62
|
end
|
63
63
|
|
64
|
-
it "should
|
65
|
-
Table.encode(:coordinates => { :longitude => 18.066667 }).should eql("\
|
64
|
+
it "should serialize { :coordinates => { :longitude => 18.066667 } }" do
|
65
|
+
Table.encode(:coordinates => { :longitude => 18.066667 }).should eql("\x00\x00\x00$\vcoordinatesF\x00\x00\x00\x13\tlongituded@2\x11\x11\x16\xA8\xB8\xF1")
|
66
66
|
end
|
67
67
|
|
68
68
|
DATA.each do |data, encoded|
|
@@ -109,6 +109,10 @@ module AMQ
|
|
109
109
|
Table.decode(Table.encode(input)).should == input
|
110
110
|
end
|
111
111
|
|
112
|
+
it "is capable of decoding string table values with UTF-8 characters" do
|
113
|
+
input = { "строка" => "значение" }
|
114
|
+
Table.decode(Table.encode(input)).should == input
|
115
|
+
end
|
112
116
|
|
113
117
|
|
114
118
|
it "is capable of decoding integer table values" do
|
@@ -178,7 +182,7 @@ module AMQ
|
|
178
182
|
|
179
183
|
it 'is capable of decoding 16bit signed integers' do
|
180
184
|
output = TableValueDecoder.decode_short("\b\xC0",0).first
|
181
|
-
output.should == -
|
185
|
+
output.should == -64
|
182
186
|
end
|
183
187
|
|
184
188
|
it "is capable of decoding tables" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: amq-protocol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jakub Stastny
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2013-
|
16
|
+
date: 2013-04-10 00:00:00 Z
|
17
17
|
dependencies: []
|
18
18
|
|
19
19
|
description: " amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It is not an\n AMQP client: amq-protocol only handles serialization and deserialization.\n If you want to write your own AMQP client, this gem can help you with that.\n"
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- codegen/protocol.rb.pytemplate
|
45
45
|
- generate.rb
|
46
46
|
- lib/amq/bit_set.rb
|
47
|
+
- lib/amq/endianness.rb
|
47
48
|
- lib/amq/hacks.rb
|
48
49
|
- lib/amq/int_allocator.rb
|
49
50
|
- lib/amq/protocol.rb
|
@@ -104,4 +105,3 @@ specification_version: 3
|
|
104
105
|
summary: AMQP 0.9.1 encoder & decoder.
|
105
106
|
test_files: []
|
106
107
|
|
107
|
-
has_rdoc:
|