amq-protocol 1.9.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1df146ebd04eb15fc2d776b8dc7727da583ac8ba
4
- data.tar.gz: 9ea0a0fadbc0f8d5bf4ae5b4cddb83263c12b51d
3
+ metadata.gz: 6414473e47857ea1786e17fc043ccb0a7de1c51e
4
+ data.tar.gz: 7e20dca497dd7b785a62fbf4f1edd8efde84ffda
5
5
  SHA512:
6
- metadata.gz: dab13ac628ff6c896284702903b702549861e575cba274192802779387e7a2a64cd6126cb1d1fd722e3b5220982494419f2a77f249443807343689de6147ab2f
7
- data.tar.gz: 1e5d034f65ec0ab257e0db1c30879bf29ac15519cda3fbf1b424417d504f5d70f8e8daac27b73fc566f3bc2d80fa65c5a0ae391a26155fa360c7042f310e3d6a
6
+ metadata.gz: bc68b493add7ea27adf4451631bd1137377e6f979feb43e834f48b8ab019688fdad5f726893bb1de9dbbc4a29948f47d4e7fcbd1607b3fea123f594e267fbd29
7
+ data.tar.gz: ca3c1f251925c4bbee125e5b7556579129d00557847b79e797fb780f863bb18ff839f2f773e4e8aa339261f1ade985fdfb27402721dce4f15ca2ddc8cdb77bc3
data/.travis.yml CHANGED
@@ -2,12 +2,10 @@ language: ruby
2
2
  bundler_args: --without development
3
3
  script: "bundle exec rspec spec"
4
4
  rvm:
5
+ - 2.2
6
+ - 2.1
5
7
  - 2.0
6
- - 1.9.3
7
- - jruby
8
- - 1.9.2
9
8
  - ruby-head
10
- - 1.8.7
11
9
  notifications:
12
10
  recipients:
13
11
  - michael@rabbitmq.com
data/ChangeLog.md CHANGED
@@ -1,9 +1,23 @@
1
- ## Changes between 1.9.x and 1.10.0
1
+ ## Changes between 1.9.x and 2.0.0
2
+
3
+ 2.0.0 has **breaking changes** in header encoding.
4
+
5
+ ### Signed Integer Encoding in Headers
6
+
7
+ Integer values in headers are now encoded as signed 64-bit
8
+ (was unsigned 32-bit previously, unintentionally).
9
+
10
+ This is a breaking change: consuming messages with integers in headers
11
+ published with older versions of this library will break!
2
12
 
3
13
  ### Signed 16 Bit Integer Decoding
4
14
 
5
15
  Signed 16 bit integers are now decoded correctly.
6
16
 
17
+ ### Signed 8 Bit Integer Decoding
18
+
19
+ Signed 8 bit integers are now decoded correctly.
20
+
7
21
  Contributed by Benjamin Conlan.
8
22
 
9
23
 
data/Gemfile CHANGED
@@ -4,12 +4,13 @@ source "https://rubygems.org"
4
4
 
5
5
  group :development do
6
6
  # excludes Windows, Rubinius and JRuby
7
- gem "ruby-prof", :platform => :mri
7
+ gem "ruby-prof", :platforms => [:mri_19, :mri_20, :mri_21]
8
8
 
9
9
  gem "rake"
10
10
  end
11
11
 
12
12
  group :test do
13
- gem "rspec", ">= 2.13.0"
13
+ gem "rspec"
14
+ gem "rspec-its"
14
15
  gem "effin_utf8"
15
16
  end
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2010 – 2011 Jakub Šťastný aka Botanicus
2
- Copyright (c) 2011 – 2012 Michael S. Klishin <michael@defprotocol.org>
2
+ Copyright (c) 2011 – 2015 Michael S. Klishin <michael@defprotocol.org>
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining
5
5
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -7,6 +7,13 @@ If you want to write your own AMQP client, this gem will handle all the serializ
7
7
  needs for you, including RabbitMQ extensions to AMQP 0.9.1.
8
8
 
9
9
 
10
+ ## Supported Ruby Versions
11
+
12
+ amq-protocol `1.9.2` was the last version to support Ruby 1.8 and 1.9.
13
+
14
+ amq-protocol `2.0.0` and later will only support Ruby 2.0+.
15
+
16
+
10
17
  ## Installation
11
18
 
12
19
  gem install amq-protocol
@@ -56,7 +63,3 @@ Any questions you may have should be sent to the [Ruby AMQP mailing list](http:/
56
63
  ## License
57
64
 
58
65
  MIT (see LICENSE in the repository root).
59
-
60
-
61
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ruby-amqp/amq-protocol/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
62
-
data/amq-protocol.gemspec CHANGED
@@ -10,14 +10,14 @@ Gem::Specification.new do |s|
10
10
  s.version = AMQ::Protocol::VERSION
11
11
  s.authors = ["Jakub Stastny", "Michael S. Klishin", "Theo Hultberg", "Mark Abramov"]
12
12
  s.homepage = "http://github.com/ruby-amqp/amq-protocol"
13
- s.summary = "AMQP 0.9.1 encoder & decoder."
13
+ s.summary = "AMQP 0.9.1 encoding & decoding library."
14
14
  s.description = <<-DESC
15
- amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It is not an
16
- AMQP client: amq-protocol only handles serialization and deserialization.
17
- If you want to write your own AMQP client, this gem can help you with that.
15
+ amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It is not a
16
+ client: the library only handles serialization and deserialization.
18
17
  DESC
19
- s.email = ["bWljaGFlbEBub3ZlbWJlcmFpbi5jb20=\n", "c3Rhc3RueUAxMDFpZGVhcy5jeg==\n"].map { |i| Base64.decode64(i) }
18
+ s.email = ["michael.s.klishin@gmail.com"]
20
19
  s.licenses = ["MIT"]
20
+ s.required_ruby_version = Gem::Requirement.new(">= 2.0")
21
21
 
22
22
  # files
23
23
  s.files = `git ls-files`.split("\n").reject { |file| file =~ /^vendor\// }
@@ -25,7 +25,5 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.extra_rdoc_files = ["README.md"] + Dir.glob("doc/*")
27
27
 
28
-
29
- # RubyForge
30
28
  s.rubyforge_project = "amq-protocol"
31
29
  end
@@ -13,6 +13,7 @@ module AMQ
13
13
  PACK_UINT32 = 'N'.freeze
14
14
  PACK_UINT32_X2 = 'N2'.freeze
15
15
  PACK_INT64 = 'q'.freeze
16
+ PACK_INT64_BE = 'q>'.freeze
16
17
  PACK_UCHAR_UINT32 = 'CN'.freeze
17
18
  PACK_CHAR_UINT16_UINT32 = 'cnN'.freeze
18
19
 
@@ -36,8 +36,8 @@ module AMQ
36
36
  accumulator << [v.bytesize].pack(PACK_UINT32)
37
37
  accumulator << v
38
38
  when Integer then
39
- accumulator << TYPE_INTEGER
40
- accumulator << [value].pack(PACK_UINT32)
39
+ accumulator << TYPE_SIGNED_64BIT
40
+ accumulator << [value].pack(PACK_INT64_BE)
41
41
  when AMQ::Protocol::Float32Bit then
42
42
  accumulator << TYPE_32BIT_FLOAT
43
43
  accumulator << [value.value].pack(PACK_32BIT_FLOAT)
@@ -49,7 +49,7 @@ module AMQ
49
49
  accumulator << (value ? BOOLEAN_TRUE : BOOLEAN_FALSE)
50
50
  when Time then
51
51
  accumulator << TYPE_TIME
52
- accumulator << [value.to_i].pack(PACK_INT64).reverse # FIXME: there has to be a more efficient way
52
+ accumulator << [value.to_i].pack(PACK_INT64_BE)
53
53
  when nil then
54
54
  accumulator << TYPE_VOID
55
55
  when Array then
@@ -91,7 +91,7 @@ module AMQ
91
91
  when String then
92
92
  acc += (value.bytesize + 4)
93
93
  when Integer then
94
- acc += 4
94
+ acc += 8
95
95
  when Float then
96
96
  acc += 8
97
97
  when Time, DateTime then
@@ -1,5 +1,5 @@
1
1
  module AMQ
2
2
  module Protocol
3
- VERSION = "1.9.2"
3
+ VERSION = "2.0.0"
4
4
  end # Protocol
5
5
  end # AMQ
data/lib/amq/uri.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "amq/settings"
4
-
5
3
  require "cgi"
6
4
  require "uri"
7
5
 
@@ -18,14 +16,14 @@ module AMQ
18
16
  opts = {}
19
17
 
20
18
  opts[:scheme] = uri.scheme
21
- opts[:user] = ::URI.unescape(uri.user) if uri.user
22
- opts[:pass] = ::URI.unescape(uri.password) if uri.password
19
+ opts[:user] = ::CGI::unescape(uri.user) if uri.user
20
+ opts[:pass] = ::CGI::unescape(uri.password) if uri.password
23
21
  opts[:host] = uri.host if uri.host
24
22
  opts[:port] = uri.port || AMQP_PORTS[uri.scheme]
25
23
  opts[:ssl] = uri.scheme.to_s.downcase =~ /amqps/i
26
24
  if uri.path =~ %r{^/(.*)}
27
25
  raise ArgumentError.new("#{uri} has multiple-segment path; please percent-encode any slashes in the vhost name (e.g. /production => %2Fproduction). Learn more at http://bit.ly/amqp-gem-and-connection-uris") if $1.index('/')
28
- opts[:vhost] = ::URI.unescape($1)
26
+ opts[:vhost] = ::CGI::unescape($1)
29
27
  end
30
28
 
31
29
  opts
@@ -23,7 +23,7 @@ describe AMQ::BitSet do
23
23
  it "has no bits set at the start" do
24
24
  bs = AMQ::BitSet.new(128)
25
25
  0.upto(127) do |i|
26
- bs[i].should == false
26
+ expect(bs[i]).to be_falsey
27
27
  end
28
28
  end # it
29
29
  end # describe
@@ -33,15 +33,15 @@ describe AMQ::BitSet do
33
33
  described_class.new(nbits)
34
34
  end
35
35
  it "returns 0 when the word is between 0 and 63" do
36
- subject.word_index(0).should == 0
37
- subject.word_index(63).should == 0
36
+ expect(subject.word_index(0)).to eq(0)
37
+ expect(subject.word_index(63)).to eq(0)
38
38
  end # it
39
39
  it "returns 1 when the word is between 64 and 127" do
40
- subject.word_index(64).should == 1
41
- subject.word_index(127).should == 1
40
+ expect(subject.word_index(64)).to be(1)
41
+ expect(subject.word_index(127)).to be(1)
42
42
  end # it
43
43
  it "returns 2 when the word is between 128 and another number" do
44
- subject.word_index(128).should == 2
44
+ expect(subject.word_index(128)).to be(2)
45
45
  end # it
46
46
  end # describe
47
47
 
@@ -54,7 +54,7 @@ describe AMQ::BitSet do
54
54
  end
55
55
 
56
56
  it "returns true" do
57
- subject.get(3).should be_true
57
+ expect(subject.get(3)).to be_truthy
58
58
  end # it
59
59
  end # describe
60
60
 
@@ -64,7 +64,7 @@ describe AMQ::BitSet do
64
64
  end
65
65
 
66
66
  it "returns false" do
67
- subject.get(5).should be_false
67
+ expect(subject.get(5)).to be_falsey
68
68
  end # it
69
69
  end # describe
70
70
 
@@ -74,10 +74,10 @@ describe AMQ::BitSet do
74
74
  end
75
75
 
76
76
  it "should raise IndexError for negative index" do
77
- lambda { subject.get(-1) }.should raise_error(IndexError)
77
+ expect { subject.get(-1) }.to raise_error(IndexError)
78
78
  end # it
79
79
  it "should raise IndexError for index >= number of bits" do
80
- lambda { subject.get(nbits) }.should raise_error(IndexError)
80
+ expect { subject.get(nbits) }.to raise_error(IndexError)
81
81
  end # it
82
82
  end # describe
83
83
  end # describe
@@ -91,9 +91,9 @@ describe AMQ::BitSet do
91
91
 
92
92
  it "has no effect" do
93
93
  subject.set(3)
94
- subject.get(3).should be_true
94
+ expect(subject.get(3)).to be_truthy
95
95
  subject.set(3)
96
- subject[3].should be_true
96
+ expect(subject[3]).to be_truthy
97
97
  end # it
98
98
  end # describe
99
99
 
@@ -104,13 +104,13 @@ describe AMQ::BitSet do
104
104
 
105
105
  it "sets that bit" do
106
106
  subject.set(3)
107
- subject.get(3).should be_true
107
+ expect(subject.get(3)).to be_truthy
108
108
 
109
109
  subject.set(33)
110
- subject.get(33).should be_true
110
+ expect(subject.get(33)).to be_truthy
111
111
 
112
112
  subject.set(3387)
113
- subject.get(3387).should be_true
113
+ expect(subject.get(3387)).to be_truthy
114
114
  end # it
115
115
  end # describe
116
116
 
@@ -120,10 +120,10 @@ describe AMQ::BitSet do
120
120
  end
121
121
 
122
122
  it "should raise IndexError for negative index" do
123
- lambda { subject.set(-1) }.should raise_error(IndexError)
123
+ expect { subject.set(-1) }.to raise_error(IndexError)
124
124
  end # it
125
125
  it "should raise IndexError for index >= number of bits" do
126
- lambda { subject.set(nbits) }.should raise_error(IndexError)
126
+ expect { subject.set(nbits) }.to raise_error(IndexError)
127
127
  end # it
128
128
  end # describe
129
129
  end # describe
@@ -137,9 +137,9 @@ describe AMQ::BitSet do
137
137
 
138
138
  it "unsets that bit" do
139
139
  subject.set(3)
140
- subject.get(3).should be_true
140
+ expect(subject.get(3)).to be_truthy
141
141
  subject.unset(3)
142
- subject.get(3).should be_false
142
+ expect(subject.get(3)).to be_falsey
143
143
  end # it
144
144
  end # describe
145
145
 
@@ -150,9 +150,9 @@ describe AMQ::BitSet do
150
150
  end
151
151
 
152
152
  it "has no effect" do
153
- subject.get(3).should be_false
153
+ expect(subject.get(3)).to be_falsey
154
154
  subject.unset(3)
155
- subject.get(3).should be_false
155
+ expect(subject.get(3)).to be_falsey
156
156
  end # it
157
157
  end # describe
158
158
 
@@ -162,10 +162,10 @@ describe AMQ::BitSet do
162
162
  end
163
163
 
164
164
  it "should raise IndexError for negative index" do
165
- lambda { subject.unset(-1) }.should raise_error(IndexError)
165
+ expect { subject.unset(-1) }.to raise_error(IndexError)
166
166
  end # it
167
167
  it "should raise IndexError for index >= number of bits" do
168
- lambda { subject.unset(nbits) }.should raise_error(IndexError)
168
+ expect { subject.unset(nbits) }.to raise_error(IndexError)
169
169
  end # it
170
170
  end # describe
171
171
  end # describe
@@ -179,25 +179,25 @@ describe AMQ::BitSet do
179
179
 
180
180
  it "clears all bits" do
181
181
  subject.set(3)
182
- subject.get(3).should be_true
182
+ expect(subject.get(3)).to be_truthy
183
183
 
184
184
  subject.set(7668)
185
- subject.get(7668).should be_true
185
+ expect(subject.get(7668)).to be_truthy
186
186
 
187
187
  subject.clear
188
188
 
189
- subject.get(3).should be_false
190
- subject.get(7668).should be_false
189
+ expect(subject.get(3)).to be_falsey
190
+ expect(subject.get(7668)).to be_falsey
191
191
  end # it
192
192
  end # describe
193
193
 
194
194
  describe "#number_of_trailing_ones" do
195
195
  it "calculates them" do
196
- described_class.number_of_trailing_ones(0).should == 0
197
- described_class.number_of_trailing_ones(1).should == 1
198
- described_class.number_of_trailing_ones(2).should == 0
199
- described_class.number_of_trailing_ones(3).should == 2
200
- described_class.number_of_trailing_ones(4).should == 0
196
+ expect(described_class.number_of_trailing_ones(0)).to eq(0)
197
+ expect(described_class.number_of_trailing_ones(1)).to eq(1)
198
+ expect(described_class.number_of_trailing_ones(2)).to eq(0)
199
+ expect(described_class.number_of_trailing_ones(3)).to eq(2)
200
+ expect(described_class.number_of_trailing_ones(4)).to eq(0)
201
201
  end # it
202
202
  end # describe
203
203
 
@@ -206,27 +206,27 @@ describe AMQ::BitSet do
206
206
  described_class.new(255)
207
207
  end
208
208
  it "returns sequential values when none have been returned" do
209
- subject.next_clear_bit.should == 0
209
+ expect(subject.next_clear_bit).to eq(0)
210
210
  subject.set(0)
211
- subject.next_clear_bit.should == 1
211
+ expect(subject.next_clear_bit).to eq(1)
212
212
  subject.set(1)
213
- subject.next_clear_bit.should == 2
213
+ expect(subject.next_clear_bit).to eq(2)
214
214
  subject.unset(1)
215
- subject.next_clear_bit.should == 1
215
+ expect(subject.next_clear_bit).to eq(1)
216
216
  end # it
217
217
 
218
218
  it "returns the same number as long as nothing is set" do
219
- subject.next_clear_bit.should == 0
220
- subject.next_clear_bit.should == 0
219
+ expect(subject.next_clear_bit).to eq(0)
220
+ expect(subject.next_clear_bit).to eq(0)
221
221
  end # it
222
222
 
223
223
  it "handles more than 128 bits" do
224
224
  0.upto(254) do |i|
225
225
  subject.set(i)
226
- subject.next_clear_bit.should == i + 1
226
+ expect(subject.next_clear_bit).to eq(i + 1)
227
227
  end
228
228
  subject.unset(254)
229
- subject.get(254).should be_false
229
+ expect(subject.get(254)).to be_falsey
230
230
  end # it
231
231
  end # describe
232
232
  end
@@ -23,20 +23,20 @@ describe AMQ::IntAllocator do
23
23
 
24
24
  describe "#number_of_bits" do
25
25
  it "returns number of bits available for allocation" do
26
- subject.number_of_bits.should == 4
26
+ expect(subject.number_of_bits).to eq(4)
27
27
  end
28
28
  end
29
29
 
30
30
 
31
31
  describe "#hi" do
32
32
  it "returns upper bound of the allocation range" do
33
- subject.hi.should == 5
33
+ expect(subject.hi).to eq(5)
34
34
  end
35
35
  end
36
36
 
37
37
  describe "#lo" do
38
38
  it "returns lower bound of the allocation range" do
39
- subject.lo.should == 1
39
+ expect(subject.lo).to eq(1)
40
40
  end
41
41
  end
42
42
 
@@ -44,12 +44,12 @@ describe AMQ::IntAllocator do
44
44
  describe "#allocate" do
45
45
  context "when integer in the range is available" do
46
46
  it "returns allocated integer" do
47
- subject.allocate.should == 1
48
- subject.allocate.should == 2
49
- subject.allocate.should == 3
50
- subject.allocate.should == 4
47
+ expect(subject.allocate).to eq(1)
48
+ expect(subject.allocate).to eq(2)
49
+ expect(subject.allocate).to eq(3)
50
+ expect(subject.allocate).to eq(4)
51
51
 
52
- subject.allocate.should == -1
52
+ expect(subject.allocate).to eq(-1)
53
53
  end
54
54
  end
55
55
 
@@ -57,10 +57,10 @@ describe AMQ::IntAllocator do
57
57
  it "returns -1" do
58
58
  4.times { subject.allocate }
59
59
 
60
- subject.allocate.should == -1
61
- subject.allocate.should == -1
62
- subject.allocate.should == -1
63
- subject.allocate.should == -1
60
+ expect(subject.allocate).to eq(-1)
61
+ expect(subject.allocate).to eq(-1)
62
+ expect(subject.allocate).to eq(-1)
63
+ expect(subject.allocate).to eq(-1)
64
64
  end
65
65
  end
66
66
  end
@@ -70,24 +70,24 @@ describe AMQ::IntAllocator do
70
70
  context "when the integer WAS allocated" do
71
71
  it "returns frees that integer" do
72
72
  4.times { subject.allocate }
73
- subject.allocate.should == -1
73
+ expect(subject.allocate).to eq(-1)
74
74
 
75
75
  subject.free(1)
76
- subject.allocate.should == 1
77
- subject.allocate.should == -1
76
+ expect(subject.allocate).to eq(1)
77
+ expect(subject.allocate).to eq(-1)
78
78
  subject.free(2)
79
- subject.allocate.should == 2
80
- subject.allocate.should == -1
79
+ expect(subject.allocate).to eq(2)
80
+ expect(subject.allocate).to eq(-1)
81
81
  subject.free(3)
82
- subject.allocate.should == 3
83
- subject.allocate.should == -1
82
+ expect(subject.allocate).to eq(3)
83
+ expect(subject.allocate).to eq(-1)
84
84
  end
85
85
  end
86
86
 
87
87
  context "when the integer WAS NOT allocated" do
88
88
  it "has no effect" do
89
89
  32.times { subject.free(1) }
90
- subject.allocate.should == 1
90
+ expect(subject.allocate).to eq(1)
91
91
  end
92
92
  end
93
93
  end
@@ -98,9 +98,9 @@ describe AMQ::IntAllocator do
98
98
  it "returns true" do
99
99
  3.times { subject.allocate }
100
100
 
101
- subject.allocated?(1).should be_true
102
- subject.allocated?(2).should be_true
103
- subject.allocated?(3).should be_true
101
+ expect(subject.allocated?(1)).to be_truthy
102
+ expect(subject.allocated?(2)).to be_truthy
103
+ expect(subject.allocated?(3)).to be_truthy
104
104
  end
105
105
  end
106
106
 
@@ -108,8 +108,8 @@ describe AMQ::IntAllocator do
108
108
  it "returns false" do
109
109
  2.times { subject.allocate }
110
110
 
111
- subject.allocated?(3).should be_false
112
- subject.allocated?(4).should be_false
111
+ expect(subject.allocated?(3)).to be_falsey
112
+ expect(subject.allocated?(4)).to be_falsey
113
113
  end
114
114
  end
115
115
  end