ffi-msgpack 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 0.1.3 / 2010-07-03
2
+
3
+ * Added specs for {FFI::MsgPack::Packable}.
4
+ * {FFI::MsgPack.pack} now accepts multiple arguments.
5
+ * Fixed a typo in {FFI::MsgPack::Packable#to_msgpack} (thanks bb).
6
+ * Fixed the packing of {Hash} objects.
7
+ * Fixed the struct layout of {FFI::MsgPack::MsgKeyValue}.
8
+
9
+ ### 0.1.2 / 2010-05-24
10
+
11
+ * Require libmsgpack >= 0.5.0, due to changes in the
12
+ `msgpack_object_type` enum.
13
+
1
14
  ### 0.1.1 / 2010-05-21
2
15
 
3
16
  * Fixed {FFI::MsgPack::MsgObject#initialize} on JRuby.
data/Gemfile CHANGED
@@ -1,16 +1,16 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
- group :runtime do
3
+ group(:runtime) do
4
4
  gem 'ffi', '~> 0.6.0'
5
5
  end
6
6
 
7
- group :development do
7
+ group(:development) do
8
8
  gem 'bundler', '~> 0.9.25'
9
9
  gem 'rake', '~> 0.8.7'
10
10
  gem 'jeweler', '~> 1.4.0', :git => 'git://github.com/technicalpickles/jeweler.git'
11
11
  end
12
12
 
13
- group :doc do
13
+ group(:doc) do
14
14
  case RUBY_PLATFORM
15
15
  when 'java'
16
16
  gem 'maruku', '~> 0.6.0'
@@ -18,7 +18,7 @@ group :doc do
18
18
  gem 'rdiscount', '~> 1.6.3'
19
19
  end
20
20
 
21
- gem 'yard', '~> 0.5.3'
21
+ gem 'yard', '~> 0.5.3'
22
22
  end
23
23
 
24
24
  gem 'rspec', '~> 1.3.0', :group => [:development, :test]
data/Rakefile CHANGED
@@ -10,16 +10,15 @@ rescue Bundler::BundlerError => e
10
10
  end
11
11
 
12
12
  require 'rake'
13
- require 'rake/clean'
14
13
  require 'jeweler'
15
14
 
16
15
  Jeweler::Tasks.new do |gem|
17
16
  gem.name = 'ffi-msgpack'
18
17
  gem.licenses = ['MIT']
19
18
  gem.summary = %Q{FFI bindings for msgpack}
19
+ gem.description = %Q{Ruby FFI bindings for the msgpack library.}
20
20
  gem.email = 'postmodern.mod3@gmail.com'
21
21
  gem.homepage = %Q{http://github.com/postmodern/ffi-msgpack}
22
- gem.description = %Q{Ruby FFI bindings for the msgpack library.}
23
22
  gem.authors = ['Postmodern']
24
23
  gem.requirements = ['libmsgpack, 0.5.0 or greater']
25
24
  gem.has_rdoc = 'yard'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/ffi-msgpack.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ffi-msgpack}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Postmodern"]
12
- s.date = %q{2010-05-24}
12
+ s.date = %q{2010-07-03}
13
13
  s.description = %q{Ruby FFI bindings for the msgpack library.}
14
14
  s.email = %q{postmodern.mod3@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -54,6 +54,14 @@ Gem::Specification.new do |s|
54
54
  "lib/ffi/msgpack/zone_chunk_list.rb",
55
55
  "lib/ffi/msgpack/zone_finalizer.rb",
56
56
  "lib/ffi/msgpack/zone_finalizer_array.rb",
57
+ "spec/extensions/array_spec.rb",
58
+ "spec/extensions/false_class_spec.rb",
59
+ "spec/extensions/float_spec.rb",
60
+ "spec/extensions/hash_spec.rb",
61
+ "spec/extensions/integer_spec.rb",
62
+ "spec/extensions/nil_class_spec.rb",
63
+ "spec/extensions/string_spec.rb",
64
+ "spec/extensions/true_class_spec.rb",
57
65
  "spec/msg_object_spec.rb",
58
66
  "spec/packer_spec.rb",
59
67
  "spec/spec_helper.rb",
@@ -67,6 +75,14 @@ Gem::Specification.new do |s|
67
75
  s.rubygems_version = %q{1.3.7}
68
76
  s.summary = %q{FFI bindings for msgpack}
69
77
  s.test_files = [
78
+ "spec/extensions/array_spec.rb",
79
+ "spec/extensions/false_class_spec.rb",
80
+ "spec/extensions/float_spec.rb",
81
+ "spec/extensions/hash_spec.rb",
82
+ "spec/extensions/integer_spec.rb",
83
+ "spec/extensions/nil_class_spec.rb",
84
+ "spec/extensions/string_spec.rb",
85
+ "spec/extensions/true_class_spec.rb",
70
86
  "spec/msg_object_spec.rb",
71
87
  "spec/packer_spec.rb",
72
88
  "spec/spec_helper.rb",
data/lib/ffi/msgpack.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'ffi/msgpack/msgpack'
2
2
  require 'ffi/msgpack/packer'
3
3
  require 'ffi/msgpack/unpacker'
4
+ require 'ffi/msgpack/extensions'
@@ -5,8 +5,8 @@ module FFI
5
5
  module MsgPack
6
6
  class MsgKeyValue < FFI::Struct
7
7
 
8
- layout :key, :pointer,
9
- :value, :pointer
8
+ layout :key, MsgObject,
9
+ :value, MsgObject
10
10
 
11
11
  #
12
12
  # The key.
@@ -15,7 +15,7 @@ module FFI
15
15
  # The key Msg Object.
16
16
  #
17
17
  def key
18
- MsgObject.new(self[:key])
18
+ self[:key]
19
19
  end
20
20
 
21
21
  #
@@ -25,7 +25,7 @@ module FFI
25
25
  # The value Msg Object.
26
26
  #
27
27
  def value
28
- MsgObject.new(self[:value])
28
+ self[:value]
29
29
  end
30
30
 
31
31
  end
@@ -1,8 +1,9 @@
1
1
  require 'ffi/msgpack/types'
2
- require 'ffi/msgpack/msg_key_value'
3
2
 
4
3
  module FFI
5
4
  module MsgPack
5
+ autoload :MsgKeyValue, 'ffi/msgpack/msg_key_value'
6
+
6
7
  class MsgMap < FFI::Struct
7
8
 
8
9
  layout :size, :uint32,
@@ -184,8 +184,8 @@ module FFI
184
184
  values.each_with_index do |(key,value),index|
185
185
  pair = MsgKeyValue.new(entries[index])
186
186
 
187
- pair[:key] = MsgObject.new_object(key)
188
- pair[:value] = MsgObject.new_object(value)
187
+ MsgObject.new_object(key,pair[:key].to_ptr)
188
+ MsgObject.new_object(value,pair[:value].to_ptr)
189
189
  end
190
190
 
191
191
  obj = MsgObject.new
@@ -94,15 +94,16 @@ module FFI
94
94
  #
95
95
  # Packs a Ruby object.
96
96
  #
97
- # @param [Hash, Array, String, Symbol, Integer, Float, true, false, nil] obj
98
- # The Ruby object to pack.
97
+ # @param [Array[Hash, Array, String, Symbol, Integer, Float, true, false, nil]] objs
98
+ # The Ruby object(s) to pack.
99
99
  #
100
100
  # @return [String]
101
101
  # The packed Ruby object.
102
102
  #
103
- def MsgPack.pack(obj)
103
+ def MsgPack.pack(*objs)
104
104
  packer = Packer.create
105
- packer << obj
105
+
106
+ objs.each { |obj| packer << obj }
106
107
 
107
108
  return packer.to_s
108
109
  end
@@ -11,7 +11,7 @@ module FFI
11
11
  #
12
12
  def to_msgpack
13
13
  packer = Packer.create
14
- packer << obj
14
+ packer << self
15
15
 
16
16
  return packer.to_s
17
17
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/array'
3
+
4
+ describe Array do
5
+ subject { [1, 2] }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\x92\x01\x02"
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/false_class'
3
+
4
+ describe FalseClass do
5
+ subject { false }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\xC2"
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/float'
3
+
4
+ describe Float do
5
+ subject { 0.2 }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\xCB?\xC9\x99\x99\x99\x99\x99\x9A"
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/hash'
3
+
4
+ describe Hash do
5
+ subject { {1 => 'a', 2 => 'b'} }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\x82\x01\xA1a\x02\xA1b"
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/integer'
3
+
4
+ describe Integer do
5
+ subject { 0x02 }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\x02"
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/nil_class'
3
+
4
+ describe NilClass do
5
+ subject { nil }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\xC0"
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/string'
3
+
4
+ describe String do
5
+ subject { "hello" }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\xA5hello"
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require 'ffi/msgpack/extensions/true_class'
3
+
4
+ describe TrueClass do
5
+ subject { true }
6
+
7
+ it "should be packable" do
8
+ should be_kind_of(FFI::MsgPack::Packable)
9
+ end
10
+
11
+ it "should pack to a msg" do
12
+ subject.to_msgpack.should == "\xC3"
13
+ end
14
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-msgpack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 2
10
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - Postmodern
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-05-24 00:00:00 -07:00
17
+ date: 2010-07-03 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -25,7 +24,6 @@ dependencies:
25
24
  requirements:
26
25
  - - ~>
27
26
  - !ruby/object:Gem::Version
28
- hash: 7
29
27
  segments:
30
28
  - 0
31
29
  - 6
@@ -41,7 +39,6 @@ dependencies:
41
39
  requirements:
42
40
  - - ~>
43
41
  - !ruby/object:Gem::Version
44
- hash: 9
45
42
  segments:
46
43
  - 0
47
44
  - 9
@@ -57,7 +54,6 @@ dependencies:
57
54
  requirements:
58
55
  - - ~>
59
56
  - !ruby/object:Gem::Version
60
- hash: 49
61
57
  segments:
62
58
  - 0
63
59
  - 8
@@ -73,7 +69,6 @@ dependencies:
73
69
  requirements:
74
70
  - - ~>
75
71
  - !ruby/object:Gem::Version
76
- hash: 7
77
72
  segments:
78
73
  - 1
79
74
  - 4
@@ -89,7 +84,6 @@ dependencies:
89
84
  requirements:
90
85
  - - ~>
91
86
  - !ruby/object:Gem::Version
92
- hash: 27
93
87
  segments:
94
88
  - 1
95
89
  - 3
@@ -145,6 +139,14 @@ files:
145
139
  - lib/ffi/msgpack/zone_chunk_list.rb
146
140
  - lib/ffi/msgpack/zone_finalizer.rb
147
141
  - lib/ffi/msgpack/zone_finalizer_array.rb
142
+ - spec/extensions/array_spec.rb
143
+ - spec/extensions/false_class_spec.rb
144
+ - spec/extensions/float_spec.rb
145
+ - spec/extensions/hash_spec.rb
146
+ - spec/extensions/integer_spec.rb
147
+ - spec/extensions/nil_class_spec.rb
148
+ - spec/extensions/string_spec.rb
149
+ - spec/extensions/true_class_spec.rb
148
150
  - spec/msg_object_spec.rb
149
151
  - spec/packer_spec.rb
150
152
  - spec/spec_helper.rb
@@ -163,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
165
  requirements:
164
166
  - - ">="
165
167
  - !ruby/object:Gem::Version
166
- hash: 3
168
+ hash: -828906031
167
169
  segments:
168
170
  - 0
169
171
  version: "0"
@@ -172,7 +174,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
174
  requirements:
173
175
  - - ">="
174
176
  - !ruby/object:Gem::Version
175
- hash: 3
176
177
  segments:
177
178
  - 0
178
179
  version: "0"
@@ -184,6 +185,14 @@ signing_key:
184
185
  specification_version: 3
185
186
  summary: FFI bindings for msgpack
186
187
  test_files:
188
+ - spec/extensions/array_spec.rb
189
+ - spec/extensions/false_class_spec.rb
190
+ - spec/extensions/float_spec.rb
191
+ - spec/extensions/hash_spec.rb
192
+ - spec/extensions/integer_spec.rb
193
+ - spec/extensions/nil_class_spec.rb
194
+ - spec/extensions/string_spec.rb
195
+ - spec/extensions/true_class_spec.rb
187
196
  - spec/msg_object_spec.rb
188
197
  - spec/packer_spec.rb
189
198
  - spec/spec_helper.rb