amq-protocol 0.9.5 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,13 +84,9 @@ 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
- 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
87
+ when TYPE_SIGNED_8BIT then raise NotImplementedError.new
88
+ when TYPE_SIGNED_16BIT then raise NotImplementedError.new
89
+ when TYPE_SIGNED_64BIT then raise NotImplementedError.new
94
90
  when TYPE_32BIT_FLOAT then
95
91
  v, offset = TableValueDecoder.decode_32bit_float(data, offset)
96
92
  v
@@ -20,10 +20,6 @@ module AMQ
20
20
  # API
21
21
  #
22
22
 
23
- BIG_ENDIAN = ([1].pack("s") == "\x00\x01")
24
- Q = "Q".freeze
25
-
26
-
27
23
  def self.decode_array(data, initial_offset)
28
24
  array_length = data.slice(initial_offset, 4).unpack(PACK_UINT32).first
29
25
 
@@ -34,47 +30,41 @@ module AMQ
34
30
  type, offset = decode_value_type(data, offset)
35
31
 
36
32
  i = case type
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
33
+ when TYPE_STRING
34
+ v, offset = decode_string(data, offset)
35
+ v
36
+ when TYPE_INTEGER
37
+ v, offset = decode_integer(data, offset)
38
+ v
39
+ when TYPE_DECIMAL
40
+ v, offset = decode_big_decimal(data, offset)
41
+ v
42
+ when TYPE_TIME
43
+ v, offset = decode_time(data, offset)
44
+ v
45
+ when TYPE_HASH
46
+ v, offset = decode_hash(data, offset)
47
+ v
48
+ when TYPE_BOOLEAN
49
+ v, offset = decode_boolean(data, offset)
50
+ v
51
+ when TYPE_SIGNED_8BIT then raise NotImplementedError.new
52
+ when TYPE_SIGNED_16BIT then raise NotImplementedError.new
53
+ when TYPE_SIGNED_64BIT then raise NotImplementedError.new
54
+ when TYPE_32BIT_FLOAT then
55
+ v, offset = decode_32bit_float(data, offset)
56
+ v
57
+ when TYPE_64BIT_FLOAT then
58
+ v, offset = decode_64bit_float(data, offset)
59
+ v
60
+ when TYPE_VOID
61
+ nil
62
+ when TYPE_ARRAY
63
+ v, offset = TableValueDecoder.decode_array(data, offset)
64
+ v
65
+ else
66
+ raise ArgumentError.new("unsupported type: #{type.inspect}")
67
+ end
78
68
 
79
69
  ary << i
80
70
  end
@@ -102,24 +92,6 @@ module AMQ
102
92
  end # self.decode_integer(data, offset)
103
93
 
104
94
 
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
-
123
95
  def self.decode_big_decimal(data, offset)
124
96
  decimals, raw = data.slice(offset, 5).unpack(PACK_UCHAR_UINT32)
125
97
  offset += 5
@@ -1,5 +1,5 @@
1
1
  module AMQ
2
2
  module Protocol
3
- VERSION = "0.9.5"
3
+ VERSION = "1.0.0.pre1"
4
4
  end # Protocol
5
5
  end # AMQ
@@ -244,8 +244,8 @@ module AMQ
244
244
  def self.encode_properties(body_size, properties)
245
245
  pieces, flags = [], 0
246
246
 
247
- properties.reject {|key, value| value.nil?}.each do |key, value|
248
- i, f, result = self.__send__(:"encode_#{key}", value)
247
+ properties.each do |key, value|
248
+ i, f, result = self.send(:"encode_#{key}", value)
249
249
  flags |= f
250
250
  pieces[i] = result
251
251
  end
@@ -25,24 +25,10 @@ module AMQ
25
25
  end
26
26
  end
27
27
 
28
- describe Declare, "encoded with a symbol name" do
29
- describe '.encode' do
30
- it 'encodes the parameters into a MethodFrame' do
31
- channel = 1
32
- exchange = :exchange2
33
- type = 'fanout'
34
- passive = false
35
- durable = false
36
- auto_delete = false
37
- internal = false
38
- nowait = false
39
- arguments = nil
40
- method_frame = Declare.encode(channel, exchange, type, passive, durable, auto_delete, internal, nowait, arguments)
41
- method_frame.payload.should == "\x00(\x00\n\x00\x00\texchange2\x06fanout\x00\x00\x00\x00\x00"
42
- method_frame.channel.should == 1
43
- end
44
- end
45
- end
28
+ # describe DeclareOk do
29
+ # describe '.decode' do
30
+ # end
31
+ # end
46
32
 
47
33
  describe Delete do
48
34
  describe '.encode' do
@@ -25,11 +25,11 @@ module AMQ
25
25
  end
26
26
  end
27
27
 
28
- context 'when the body is too big to fit in a single frame' do
28
+ context 'when the body is to big to fit in a single frame' do
29
29
  it 'encodes a body into a list of BodyFrames that each fit within the frame size' do
30
30
  lipsum = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
31
31
  frame_size = 100
32
- expected_payload_size = 92
32
+ expected_payload_size = 93
33
33
  body_frames = Method.encode_body(lipsum, 1, frame_size)
34
34
  body_frames.map(&:payload).should == lipsum.split('').each_slice(expected_payload_size).map(&:join)
35
35
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amq-protocol
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
5
- prerelease:
4
+ hash: -2644121904
5
+ prerelease: 6
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 9
9
- - 5
10
- version: 0.9.5
9
+ - 0
10
+ - pre
11
+ - 1
12
+ version: 1.0.0.pre1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Jakub Stastny
@@ -18,7 +20,7 @@ autorequire:
18
20
  bindir: bin
19
21
  cert_chain: []
20
22
 
21
- date: 2012-09-24 00:00:00 Z
23
+ date: 2012-06-22 00:00:00 Z
22
24
  dependencies: []
23
25
 
24
26
  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"
@@ -94,16 +96,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
96
  required_rubygems_version: !ruby/object:Gem::Requirement
95
97
  none: false
96
98
  requirements:
97
- - - ">="
99
+ - - ">"
98
100
  - !ruby/object:Gem::Version
99
- hash: 3
101
+ hash: 25
100
102
  segments:
101
- - 0
102
- version: "0"
103
+ - 1
104
+ - 3
105
+ - 1
106
+ version: 1.3.1
103
107
  requirements: []
104
108
 
105
109
  rubyforge_project: amq-protocol
106
- rubygems_version: 1.8.24
110
+ rubygems_version: 1.8.15
107
111
  signing_key:
108
112
  specification_version: 3
109
113
  summary: AMQP 0.9.1 encoder & decoder.