amq-protocol 0.7.0.alpha4 → 0.7.0.alpha5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,6 +2,6 @@ script: "bundle exec rspec spec"
2
2
  rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
- - ree
5
+ - jruby
6
6
  - rbx
7
- - jruby
7
+ - ree
@@ -26,13 +26,15 @@ module AMQ
26
26
  PACK_UCHAR_UINT32 = "CN".freeze
27
27
  PACK_CHAR_UINT16_UINT32 = "cnN".freeze
28
28
 
29
- # @version 0.0.1
29
+ PACK_32BIT_FLOAT = 'f'.freeze
30
+ PACK_64BIT_FLOAT = 'd'.freeze
31
+
32
+
30
33
  # @return [Array] Collection of subclasses of AMQ::Protocol::Class.
31
34
  def self.classes
32
35
  Protocol::Class.classes
33
36
  end
34
37
 
35
- # @version 0.0.1
36
38
  # @return [Array] Collection of subclasses of AMQ::Protocol::Method.
37
39
  def self.methods
38
40
  Protocol::Method.methods
@@ -44,17 +44,19 @@ module AMQ
44
44
  when Integer then
45
45
  buffer << TYPE_INTEGER
46
46
  buffer << [value].pack(PACK_UINT32)
47
+ when Float then
48
+ buffer << TYPE_32BIT_FLOAT
49
+ buffer << [value].pack(PACK_32BIT_FLOAT)
47
50
  when TrueClass, FalseClass then
48
51
  value = value ? 1 : 0
49
52
  buffer << TYPE_INTEGER
50
53
  buffer << [value].pack(PACK_UINT32)
51
54
  when Hash then
52
- buffer << TYPE_HASH # it will work as long as the encoding is ASCII-8BIT
55
+ buffer << TYPE_HASH # TODO: encoding support
53
56
  buffer << self.encode(value)
54
57
  when Time then
55
- # TODO: encode timezone?
56
58
  buffer << TYPE_TIME
57
- buffer << [value.to_i].pack(PACK_INT64).reverse # Don't ask. It works.
59
+ buffer << [value.to_i].pack(PACK_INT64).reverse # FIXME: there has to be a more efficient way
58
60
  else
59
61
  # We don't want to require these libraries.
60
62
  if defined?(BigDecimal) && value.is_a?(BigDecimal)
@@ -123,8 +125,12 @@ module AMQ
123
125
  when TYPE_SIGNED_8BIT then raise NotImplementedError.new
124
126
  when TYPE_SIGNED_16BIT then raise NotImplementedError.new
125
127
  when TYPE_SIGNED_64BIT then raise NotImplementedError.new
126
- when TYPE_32BIT_FLOAT then raise NotImplementedError.new
127
- when TYPE_64BIT_FLOAT then raise NotImplementedError.new
128
+ when TYPE_32BIT_FLOAT then
129
+ value = data.slice(offset, 4).unpack(PACK_32BIT_FLOAT).first
130
+ offset += 4
131
+ when TYPE_64BIT_FLOAT then
132
+ value = data.slice(offset, 8).unpack(PACK_64BIT_FLOAT).first
133
+ offset += 8
128
134
  when TYPE_VOID
129
135
  value = nil
130
136
  when TYPE_BYTE_ARRAY
@@ -1,5 +1,5 @@
1
1
  module AMQ
2
2
  module Protocol
3
- VERSION = "0.7.0.alpha4"
3
+ VERSION = "0.7.0.alpha5"
4
4
  end # Protocol
5
5
  end # AMQ
@@ -17,6 +17,7 @@ module AMQ
17
17
  {
18
18
  {} => "\000\000\000\000",
19
19
  {"test" => 1} => "\000\000\000\n\004testI\000\000\000\001",
20
+ {"float" => 1.0} => "\000\000\000\v\005floatf\000\000\200?",
20
21
  {"test" => "string"} => "\000\000\000\020\004testS\000\000\000\006string",
21
22
  {"test" => {}} => "\000\000\000\n\004testF\000\000\000\000",
22
23
  {"test" => bigdecimal_1} => "\000\000\000\v\004testD\000\000\000\000\001",
@@ -27,6 +28,7 @@ module AMQ
27
28
  {
28
29
  {} => "\x00\x00\x00\x00",
29
30
  {"test" => 1} => "\x00\x00\x00\n\x04testI\x00\x00\x00\x01",
31
+ {"float" => 1.0} => "\000\000\000\v\005floatf\000\000\200?",
30
32
  {"test" => "string"} => "\x00\x00\x00\x10\x04testS\x00\x00\x00\x06string",
31
33
  {"test" => {}} => "\x00\x00\x00\n\x04testF\x00\x00\x00\x00",
32
34
  {"test" => bigdecimal_1} => "\x00\x00\x00\v\x04testD\x00\x00\x00\x00\x01",
@@ -46,10 +48,14 @@ module AMQ
46
48
  Table.encode(nil).should eql(encoded_value)
47
49
  end
48
50
 
49
- it "should return \"\x00\x00\x00\n\x04testI\x00\x00\x00\x01\" for {test: true}" do
51
+ it "should return \"\x00\x00\x00\n\x04testI\x00\x00\x00\x01\" for { :test => true }" do
50
52
  Table.encode(:test => true).should eql("\x00\x00\x00\n\x04testI\x00\x00\x00\x01")
51
53
  end
52
54
 
55
+ it "should return \"\x00\x00\x00\n\x04testI\x00\x00\x00\x01\" for { :coordinates => { :latitude => 59.35, :longitude => 18.066667 } }" do
56
+ Table.encode(:coordinates => { :latitude => 59.35, :longitude => 18.066667 }).should eql("\x00\x00\x00.\vcoordinatesF\x00\x00\x00\x1D\blatitudefffmB\tlongitudef\x89\x88\x90A")
57
+ end
58
+
53
59
  DATA.each do |data, encoded|
54
60
  it "should return #{encoded.inspect} for #{data.inspect}" do
55
61
  Table.encode(data).should eql(encoded)
@@ -66,4 +72,4 @@ module AMQ
66
72
  end
67
73
  end
68
74
  end
69
- end
75
+ end
metadata CHANGED
@@ -1,10 +1,17 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: amq-protocol
3
- version: !ruby/object:Gem::Version
4
- version: 0.7.0.alpha4
3
+ version: !ruby/object:Gem::Version
4
+ hash: -3702664410
5
5
  prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 0
10
+ - alpha
11
+ - 5
12
+ version: 0.7.0.alpha5
6
13
  platform: ruby
7
- authors:
14
+ authors:
8
15
  - Jakub Stastny
9
16
  - Michael S. Klishin
10
17
  - Theo Hultberg
@@ -12,19 +19,21 @@ authors:
12
19
  autorequire:
13
20
  bindir: bin
14
21
  cert_chain: []
15
- date: 2011-05-24 00:00:00.000000000Z
22
+
23
+ date: 2011-05-29 00:00:00 Z
16
24
  dependencies: []
17
- description: ! " amq-protocol is an AMQP 0.9.1 serialization library for Ruby. It
18
- is not an\n AMQP client: amq-protocol only handles serialization and deserialization.\n
19
- \ If you want to write your own AMQP client, this gem can help you with that.\n"
20
- email:
25
+
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"
27
+ email:
21
28
  - michael@novemberain.com
22
29
  - stastny@101ideas.cz
23
30
  executables: []
31
+
24
32
  extensions: []
25
- extra_rdoc_files:
33
+
34
+ extra_rdoc_files:
26
35
  - README.textile
27
- files:
36
+ files:
28
37
  - .gitignore
29
38
  - .gitmodules
30
39
  - .rspec
@@ -67,26 +76,38 @@ files:
67
76
  - tasks.rb
68
77
  homepage: http://github.com/ruby-amqp/amq-protocol
69
78
  licenses: []
79
+
70
80
  post_install_message:
71
81
  rdoc_options: []
72
- require_paths:
82
+
83
+ require_paths:
73
84
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
85
+ required_ruby_version: !ruby/object:Gem::Requirement
75
86
  none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
95
  none: false
82
- requirements:
83
- - - ! '>'
84
- - !ruby/object:Gem::Version
96
+ requirements:
97
+ - - ">"
98
+ - !ruby/object:Gem::Version
99
+ hash: 25
100
+ segments:
101
+ - 1
102
+ - 3
103
+ - 1
85
104
  version: 1.3.1
86
105
  requirements: []
106
+
87
107
  rubyforge_project: amq-protocol
88
- rubygems_version: 1.8.1
108
+ rubygems_version: 1.8.4
89
109
  signing_key:
90
110
  specification_version: 3
91
111
  summary: AMQP 0.9.1 encoder & decoder.
92
112
  test_files: []
113
+