amq-protocol 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/amq/protocol/table.rb +7 -3
- data/lib/amq/protocol/table_value_decoder.rb +63 -35
- data/lib/amq/protocol/version.rb +1 -1
- metadata +5 -5
data/lib/amq/protocol/table.rb
CHANGED
@@ -84,9 +84,13 @@ module AMQ
|
|
84
84
|
when TYPE_BOOLEAN
|
85
85
|
v, offset = TableValueDecoder.decode_boolean(data, offset)
|
86
86
|
v
|
87
|
-
when TYPE_SIGNED_8BIT then
|
88
|
-
|
89
|
-
when
|
87
|
+
when TYPE_SIGNED_8BIT then
|
88
|
+
raise NotImplementedError.new
|
89
|
+
when TYPE_SIGNED_16BIT then
|
90
|
+
raise NotImplementedError.new
|
91
|
+
when TYPE_SIGNED_64BIT then
|
92
|
+
v, offset = TableValueDecoder.decode_long(data, offset)
|
93
|
+
v
|
90
94
|
when TYPE_32BIT_FLOAT then
|
91
95
|
v, offset = TableValueDecoder.decode_32bit_float(data, offset)
|
92
96
|
v
|
@@ -20,6 +20,10 @@ module AMQ
|
|
20
20
|
# API
|
21
21
|
#
|
22
22
|
|
23
|
+
BIG_ENDIAN = ([1].pack("s") == "\x00\x01")
|
24
|
+
Q = "Q".freeze
|
25
|
+
|
26
|
+
|
23
27
|
def self.decode_array(data, initial_offset)
|
24
28
|
array_length = data.slice(initial_offset, 4).unpack(PACK_UINT32).first
|
25
29
|
|
@@ -30,41 +34,47 @@ module AMQ
|
|
30
34
|
type, offset = decode_value_type(data, offset)
|
31
35
|
|
32
36
|
i = case type
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
37
|
+
when TYPE_STRING
|
38
|
+
v, offset = decode_string(data, offset)
|
39
|
+
v
|
40
|
+
when TYPE_INTEGER
|
41
|
+
v, offset = decode_integer(data, offset)
|
42
|
+
v
|
43
|
+
when TYPE_DECIMAL
|
44
|
+
v, offset = decode_big_decimal(data, offset)
|
45
|
+
v
|
46
|
+
when TYPE_TIME
|
47
|
+
v, offset = decode_time(data, offset)
|
48
|
+
v
|
49
|
+
when TYPE_HASH
|
50
|
+
v, offset = decode_hash(data, offset)
|
51
|
+
v
|
52
|
+
when TYPE_BOOLEAN
|
53
|
+
v, offset = decode_boolean(data, offset)
|
54
|
+
v
|
55
|
+
when TYPE_SIGNED_8BIT then
|
56
|
+
# TODO
|
57
|
+
raise NotImplementedError.new
|
58
|
+
when TYPE_SIGNED_16BIT then
|
59
|
+
# TODO
|
60
|
+
raise NotImplementedError.new
|
61
|
+
when TYPE_SIGNED_64BIT then
|
62
|
+
v, offset = decode_long(data, offset)
|
63
|
+
v
|
64
|
+
when TYPE_32BIT_FLOAT then
|
65
|
+
v, offset = decode_32bit_float(data, offset)
|
66
|
+
v
|
67
|
+
when TYPE_64BIT_FLOAT then
|
68
|
+
v, offset = decode_64bit_float(data, offset)
|
69
|
+
v
|
70
|
+
when TYPE_VOID
|
71
|
+
nil
|
72
|
+
when TYPE_ARRAY
|
73
|
+
v, offset = TableValueDecoder.decode_array(data, offset)
|
74
|
+
v
|
75
|
+
else
|
76
|
+
raise ArgumentError.new("unsupported type in a table value: #{type.inspect}, do not know how to decode!")
|
77
|
+
end
|
68
78
|
|
69
79
|
ary << i
|
70
80
|
end
|
@@ -92,6 +102,24 @@ module AMQ
|
|
92
102
|
end # self.decode_integer(data, offset)
|
93
103
|
|
94
104
|
|
105
|
+
if BIG_ENDIAN
|
106
|
+
def self.decode_long(data, offset)
|
107
|
+
v = data.slice(offset, 8).unpack(Q)
|
108
|
+
|
109
|
+
offset += 8
|
110
|
+
[v, offset]
|
111
|
+
end
|
112
|
+
else
|
113
|
+
def self.decode_long(data, offset)
|
114
|
+
slice = data.slice(offset, 8).bytes.to_a.reverse.map(&:chr).join
|
115
|
+
v = slice.unpack(Q).first
|
116
|
+
|
117
|
+
offset += 8
|
118
|
+
[v, offset]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
95
123
|
def self.decode_big_decimal(data, offset)
|
96
124
|
decimals, raw = data.slice(offset, 5).unpack(PACK_UCHAR_UINT32)
|
97
125
|
offset += 5
|
data/lib/amq/protocol/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amq-protocol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 4
|
10
|
+
version: 0.9.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jakub Stastny
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2012-
|
21
|
+
date: 2012-07-02 00:00:00 Z
|
22
22
|
dependencies: []
|
23
23
|
|
24
24
|
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"
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements: []
|
104
104
|
|
105
105
|
rubyforge_project: amq-protocol
|
106
|
-
rubygems_version: 1.8.
|
106
|
+
rubygems_version: 1.8.24
|
107
107
|
signing_key:
|
108
108
|
specification_version: 3
|
109
109
|
summary: AMQP 0.9.1 encoder & decoder.
|