ffi-msgpack 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.gitignore +4 -2
- data/ChangeLog.md +8 -2
- data/Gemfile +11 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -5
- data/Rakefile +6 -30
- data/ffi-msgpack.gemspec +38 -105
- data/gemspec.yml +2 -4
- data/lib/ffi/msgpack/msg_object.rb +3 -3
- data/lib/ffi/msgpack/msg_raw.rb +1 -1
- data/lib/ffi/msgpack/msgpack.rb +1 -1
- data/lib/ffi/msgpack/packer.rb +1 -1
- data/spec/extensions/array_spec.rb +4 -2
- data/spec/extensions/false_class_spec.rb +4 -2
- data/spec/extensions/float_spec.rb +4 -2
- data/spec/extensions/hash_spec.rb +4 -2
- data/spec/extensions/integer_spec.rb +1 -1
- data/spec/extensions/nil_class_spec.rb +4 -2
- data/spec/extensions/string_spec.rb +4 -2
- data/spec/extensions/symbol_spec.rb +4 -2
- data/spec/extensions/true_class_spec.rb +4 -2
- data/spec/msg_object_spec.rb +46 -46
- data/spec/packer_spec.rb +7 -7
- data/spec/spec_helper.rb +0 -1
- data/spec/unpacker_spec.rb +5 -5
- metadata +25 -74
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3a260107c1e0dcaa23053676b0f50e717f4fd76fac6a02ca6590ab793036dd23
|
4
|
+
data.tar.gz: e5d5dd73f89aab88b608a59318add3d8ae0253623719b487225a2e8424d43344
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9e38b21d7ff3672a9a2d527b31b1652861a0c3976cd1cfc8dceb0ec1953e4af7f108fa0793f0e43d672a3b6dc1195288807676a65bd1501255162785d95f9817
|
7
|
+
data.tar.gz: ecdc03adbf7e1b384ef1088ac693e002e0c5276109b7c1a3c602b4166a2690a1a6c62b9d028333ea6010d3b4ddff71fd2c093ec72cc3f768e669369519356ff7
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: ['**']
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby:
|
16
|
+
- 2.4
|
17
|
+
- 2.5
|
18
|
+
- 2.6
|
19
|
+
- 2.7
|
20
|
+
- jruby
|
21
|
+
name: Ruby ${{ matrix.ruby }}
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
- name: Install libmsgpack
|
29
|
+
run: |
|
30
|
+
sudo apt update -y && \
|
31
|
+
sudo apt install -y --no-install-recommends --no-install-suggests libmsgpack-dev
|
32
|
+
- name: Install dependencies
|
33
|
+
run: bundle install --jobs 4 --retry 3
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
+
### 0.2.2 / 2020-11-28
|
2
|
+
|
3
|
+
* Support loading `libmsgpackc` as well as `libmsgpackc.so.2`, if
|
4
|
+
`libmsgpack` cannot be found.
|
5
|
+
|
1
6
|
### 0.2.1 / 2012-05-11
|
2
7
|
|
3
|
-
*
|
4
|
-
FFI::Union](https://github.com/rubinius/rubinius/issues/1717).
|
8
|
+
* Require ffi ~> 1.0.
|
5
9
|
* Load `libmsgpack.so.3` if `libmsgpack.so` does not exist.
|
6
10
|
* Use `:string`, `:buffer_out`, `:buffer_in` FFI types.
|
7
11
|
* {FFI::MsgPack::MsgObject#set!} now raises a TypeError when given
|
8
12
|
ambigious values.
|
13
|
+
* Temporarily drop support for [Rubinius](http://rubini.us/) due to [missing
|
14
|
+
FFI::Union](https://github.com/rubinius/rubinius/issues/1717).
|
9
15
|
|
10
16
|
### 0.2.0 / 2011-02-18
|
11
17
|
|
data/Gemfile
ADDED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -80,10 +80,6 @@ Enumerates over each unpacked Object from a stream:
|
|
80
80
|
|
81
81
|
## Requirements
|
82
82
|
|
83
|
-
* [Ruby](http://ruby-lang.org/) >= 1.8.7 or
|
84
|
-
[JRruby](http://jruby.org) >= 1.6
|
85
|
-
* [Rubinius](http://rubini.us/) is not currently supported due to
|
86
|
-
[Issue 1717](https://github.com/rubinius/rubinius/issues/1717)
|
87
83
|
* [libmsgpack](http://msgpack.sourceforge.net/) >= 0.5.0
|
88
84
|
* [ffi](http://github.com/ffi/ffi) ~> 1.0
|
89
85
|
|
@@ -93,6 +89,6 @@ Enumerates over each unpacked Object from a stream:
|
|
93
89
|
|
94
90
|
## License
|
95
91
|
|
96
|
-
Copyright (c) 2010-
|
92
|
+
Copyright (c) 2010-2020 Hal Brodigan
|
97
93
|
|
98
94
|
See {file:LICENSE.txt} for license information.
|
data/Rakefile
CHANGED
@@ -1,36 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'rake'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
require 'rubygems/tasks'
|
3
|
+
require 'rubygems/tasks'
|
4
|
+
Gem::Tasks.new
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
warn e.message
|
11
|
-
warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
|
12
|
-
end
|
13
|
-
|
14
|
-
begin
|
15
|
-
gem 'rspec', '~> 2.4'
|
16
|
-
require 'rspec/core/rake_task'
|
17
|
-
|
18
|
-
RSpec::Core::RakeTask.new
|
19
|
-
rescue LoadError => e
|
20
|
-
task :spec do
|
21
|
-
abort "Please run `gem install rspec` to install RSpec."
|
22
|
-
end
|
23
|
-
end
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new
|
24
8
|
task :test => :spec
|
25
9
|
task :default => :spec
|
26
10
|
|
27
|
-
|
28
|
-
|
29
|
-
require 'yard'
|
30
|
-
|
31
|
-
YARD::Rake::YardocTask.new
|
32
|
-
rescue LoadError => e
|
33
|
-
task :yard do
|
34
|
-
abort "Please run `gem install yard` to install YARD."
|
35
|
-
end
|
36
|
-
end
|
11
|
+
require 'yard'
|
12
|
+
YARD::Rake::YardocTask.new
|
data/ffi-msgpack.gemspec
CHANGED
@@ -2,126 +2,59 @@
|
|
2
2
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
`git ls-files`.split($/)
|
8
|
-
elsif File.directory?('.hg')
|
9
|
-
`hg manifest`.split($/)
|
10
|
-
elsif File.directory?('.svn')
|
11
|
-
`svn ls -R`.split($/).select { |path| File.file?(path) }
|
12
|
-
else
|
13
|
-
Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
|
14
|
-
end
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gemspec = YAML.load_file('gemspec.yml')
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
when String
|
21
|
-
(files & Dir[paths])
|
22
|
-
end
|
23
|
-
}
|
24
|
-
|
25
|
-
version = {
|
26
|
-
:file => 'lib/ffi/msgpack/version.rb',
|
27
|
-
:constant => 'FFI::MsgPack::VERSION'
|
28
|
-
}
|
29
|
-
|
30
|
-
defaults = {
|
31
|
-
'name' => File.basename(File.dirname(__FILE__)),
|
32
|
-
'files' => files,
|
33
|
-
'executables' => filter_files['bin/*'].map { |path| File.basename(path) },
|
34
|
-
'test_files' => filter_files['{test/{**/}*_test.rb,spec/{**/}*_spec.rb}'],
|
35
|
-
'extra_doc_files' => filter_files['*.{txt,rdoc,md,markdown,tt,textile}'],
|
36
|
-
}
|
37
|
-
|
38
|
-
metadata = defaults.merge(YAML.load_file('gemspec.yml'))
|
39
|
-
|
40
|
-
gemspec.name = metadata.fetch('name',defaults[:name])
|
41
|
-
gemspec.version = if metadata['version']
|
42
|
-
metadata['version']
|
43
|
-
elsif File.file?(version[:file])
|
44
|
-
require File.join('.',version[:file])
|
45
|
-
eval(version[:constant])
|
46
|
-
end
|
47
|
-
|
48
|
-
gemspec.summary = metadata.fetch('summary',metadata['description'])
|
49
|
-
gemspec.description = metadata.fetch('description',metadata['summary'])
|
50
|
-
|
51
|
-
case metadata['license']
|
52
|
-
when Array
|
53
|
-
gemspec.licenses = metadata['license']
|
54
|
-
when String
|
55
|
-
gemspec.license = metadata['license']
|
56
|
-
end
|
57
|
-
|
58
|
-
case metadata['authors']
|
59
|
-
when Array
|
60
|
-
gemspec.authors = metadata['authors']
|
61
|
-
when String
|
62
|
-
gemspec.author = metadata['authors']
|
63
|
-
end
|
8
|
+
gem.name = gemspec.fetch('name')
|
9
|
+
gem.version = gemspec.fetch('version') do
|
10
|
+
lib_dir = File.join(File.dirname(__FILE__),'lib')
|
11
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
64
12
|
|
65
|
-
|
66
|
-
|
13
|
+
require 'ffi/msgpack/version'
|
14
|
+
FFI::MsgPack::VERSION
|
15
|
+
end
|
67
16
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
17
|
+
gem.summary = gemspec['summary']
|
18
|
+
gem.description = gemspec['description']
|
19
|
+
gem.licenses = Array(gemspec['license'])
|
20
|
+
gem.authors = Array(gemspec['authors'])
|
21
|
+
gem.email = gemspec['email']
|
22
|
+
gem.homepage = gemspec['homepage']
|
74
23
|
|
75
|
-
|
24
|
+
glob = lambda { |patterns| gem.files & Dir[*patterns] }
|
76
25
|
|
77
|
-
|
78
|
-
|
26
|
+
gem.files = `git ls-files`.split($/)
|
27
|
+
gem.files = glob[gemspec['files']] if gemspec['files']
|
79
28
|
|
80
|
-
|
81
|
-
|
29
|
+
gem.executables = gemspec.fetch('executables') do
|
30
|
+
glob['bin/*'].map { |path| File.basename(path) }
|
82
31
|
end
|
32
|
+
gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
|
83
33
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
gemspec.extra_rdoc_files = metadata['extra_doc_files']
|
88
|
-
end
|
89
|
-
|
90
|
-
gemspec.post_install_message = metadata['post_install_message']
|
91
|
-
gemspec.requirements = metadata['requirements']
|
92
|
-
|
93
|
-
if gemspec.respond_to?(:required_ruby_version=)
|
94
|
-
gemspec.required_ruby_version = metadata['required_ruby_version']
|
95
|
-
end
|
34
|
+
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
35
|
+
gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
|
36
|
+
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
96
37
|
|
97
|
-
|
98
|
-
|
99
|
-
|
38
|
+
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
39
|
+
%w[ext lib].select { |dir| File.directory?(dir) }
|
40
|
+
})
|
100
41
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
when String
|
106
|
-
versions.split(/,\s*/)
|
107
|
-
end
|
108
|
-
}
|
42
|
+
gem.requirements = gemspec['requirements']
|
43
|
+
gem.required_ruby_version = gemspec['required_ruby_version']
|
44
|
+
gem.required_rubygems_version = gemspec['required_rubygems_version']
|
45
|
+
gem.post_install_message = gemspec['post_install_message']
|
109
46
|
|
110
|
-
|
111
|
-
metadata['dependencies'].each do |name,versions|
|
112
|
-
gemspec.add_dependency(name,parse_versions[versions])
|
113
|
-
end
|
114
|
-
end
|
47
|
+
split = lambda { |string| string.split(/,\s*/) }
|
115
48
|
|
116
|
-
if
|
117
|
-
|
118
|
-
|
49
|
+
if gemspec['dependencies']
|
50
|
+
gemspec['dependencies'].each do |name,versions|
|
51
|
+
gem.add_dependency(name,split[versions])
|
119
52
|
end
|
120
53
|
end
|
121
54
|
|
122
|
-
if
|
123
|
-
|
124
|
-
|
55
|
+
if gemspec['development_dependencies']
|
56
|
+
gemspec['development_dependencies'].each do |name,versions|
|
57
|
+
gem.add_development_dependency(name,split[versions])
|
125
58
|
end
|
126
59
|
end
|
127
60
|
end
|
data/gemspec.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
name: ffi-msgpack
|
2
|
-
version: 0.2.
|
2
|
+
version: 0.2.2
|
3
3
|
summary: FFI bindings for msgpack
|
4
4
|
description: Ruby FFI bindings for the msgpack library.
|
5
5
|
license: MIT
|
@@ -14,6 +14,4 @@ dependencies:
|
|
14
14
|
ffi: ~> 1.0
|
15
15
|
|
16
16
|
development_dependencies:
|
17
|
-
|
18
|
-
rspec: ~> 2.4
|
19
|
-
yard: ~> 0.7
|
17
|
+
bundler: ~> 2.0
|
@@ -259,7 +259,7 @@ module FFI
|
|
259
259
|
|
260
260
|
@objects = nil
|
261
261
|
@memory = FFI::MemoryPointer.new(:uchar, value.length)
|
262
|
-
@memory.
|
262
|
+
@memory.write_bytes(value)
|
263
263
|
|
264
264
|
self[:type] = :raw
|
265
265
|
|
@@ -271,7 +271,7 @@ module FFI
|
|
271
271
|
#
|
272
272
|
# Sets the Msg Objects value to an Array value.
|
273
273
|
#
|
274
|
-
# @param [Array]
|
274
|
+
# @param [Array] values
|
275
275
|
# The Array value.
|
276
276
|
#
|
277
277
|
# @since 0.2.0
|
@@ -294,7 +294,7 @@ module FFI
|
|
294
294
|
#
|
295
295
|
# Sets the Msg Objects value to a Map value.
|
296
296
|
#
|
297
|
-
# @param [Hash]
|
297
|
+
# @param [Hash] values
|
298
298
|
# The Map value.
|
299
299
|
#
|
300
300
|
# @since 0.2.0
|
data/lib/ffi/msgpack/msg_raw.rb
CHANGED
data/lib/ffi/msgpack/msgpack.rb
CHANGED
data/lib/ffi/msgpack/packer.rb
CHANGED
@@ -100,7 +100,7 @@ module FFI
|
|
100
100
|
self[:callback] = Proc.new do |data_ptr,packed_buffer,length|
|
101
101
|
@total += length
|
102
102
|
|
103
|
-
packed = packed_buffer.
|
103
|
+
packed = packed_buffer.read_bytes(length)
|
104
104
|
|
105
105
|
if block.arity == 2
|
106
106
|
block.call(packed,length)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/array'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe Array do
|
|
5
7
|
subject { [1, 2] }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\x92\x01\x02"
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/false_class'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe FalseClass do
|
|
5
7
|
subject { false }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\xC2"
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/float'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe Float do
|
|
5
7
|
subject { 0.2 }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\xCB?\xC9\x99\x99\x99\x99\x99\x9A"
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/hash'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe Hash do
|
|
5
7
|
subject { {1 => 'a', 2 => 'b'} }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\x82\x01\xA1a\x02\xA1b"
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/nil_class'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe NilClass do
|
|
5
7
|
subject { nil }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\xC0"
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/string'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe String do
|
|
5
7
|
subject { "hello" }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\xA5hello"
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/symbol'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe Symbol do
|
|
5
7
|
subject { :hello }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\xA5hello"
|
13
15
|
end
|
14
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ffi/msgpack/extensions/true_class'
|
3
5
|
|
@@ -5,10 +7,10 @@ describe TrueClass do
|
|
5
7
|
subject { true }
|
6
8
|
|
7
9
|
it "should be packable" do
|
8
|
-
|
10
|
+
expect(subject).to be_kind_of(FFI::MsgPack::Packable)
|
9
11
|
end
|
10
12
|
|
11
13
|
it "should pack to a msg" do
|
12
|
-
subject.to_msgpack.
|
14
|
+
expect(subject.to_msgpack).to be == "\xC3"
|
13
15
|
end
|
14
16
|
end
|
data/spec/msg_object_spec.rb
CHANGED
@@ -10,15 +10,15 @@ describe MsgPack::MsgObject do
|
|
10
10
|
it "should create nil Msg Objects from NilClasses" do
|
11
11
|
obj = MsgPack::MsgObject.new_object(nil)
|
12
12
|
|
13
|
-
obj.type.
|
13
|
+
expect(obj.type).to eq(:nil)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should create new nil Msg Objects" do
|
17
|
-
@obj.type.
|
17
|
+
expect(@obj.type).to eq(:nil)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return a Ruby nil value" do
|
21
|
-
@obj.to_ruby.
|
21
|
+
expect(@obj.to_ruby).to eq(nil)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -28,21 +28,21 @@ describe MsgPack::MsgObject do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should create new boolean Msg Objects" do
|
31
|
-
@obj.type.
|
31
|
+
expect(@obj.type).to eq(:boolean)
|
32
32
|
|
33
|
-
@obj[:values][:boolean].
|
33
|
+
expect(@obj[:values][:boolean]).to eq(1)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should create boolean Msg Objects from TrueClass/FalseClass" do
|
37
37
|
obj1 = MsgPack::MsgObject.new_object(true)
|
38
|
-
obj1.type.
|
38
|
+
expect(obj1.type).to eq(:boolean)
|
39
39
|
|
40
40
|
obj2 = MsgPack::MsgObject.new_object(false)
|
41
|
-
obj2.type.
|
41
|
+
expect(obj2.type).to eq(:boolean)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should return a Ruby true/false value" do
|
45
|
-
@obj.to_ruby.
|
45
|
+
expect(@obj.to_ruby).to eq(true)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -52,18 +52,18 @@ describe MsgPack::MsgObject do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should create new positive integer Msg Objects" do
|
55
|
-
@obj.type.
|
56
|
-
@obj[:values][:u64].
|
55
|
+
expect(@obj.type).to eq(:positive_integer)
|
56
|
+
expect(@obj[:values][:u64]).to eq(10)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should create positive integer Msg Objects from Integers" do
|
60
60
|
obj1 = MsgPack::MsgObject.new_object(10)
|
61
61
|
|
62
|
-
obj1.type.
|
62
|
+
expect(obj1.type).to eq(:positive_integer)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should return a Ruby Integer" do
|
66
|
-
@obj.to_ruby.
|
66
|
+
expect(@obj.to_ruby).to eq(10)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -73,18 +73,18 @@ describe MsgPack::MsgObject do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should create new negative integer Msg Objects" do
|
76
|
-
@obj.type.
|
77
|
-
@obj[:values][:i64].
|
76
|
+
expect(@obj.type).to eq(:negative_integer)
|
77
|
+
expect(@obj[:values][:i64]).to eq(-1)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should create negative integer Msg Objects from Integers" do
|
81
81
|
obj1 = MsgPack::MsgObject.new_object(-1)
|
82
82
|
|
83
|
-
obj1.type.
|
83
|
+
expect(obj1.type).to eq(:negative_integer)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should return a Ruby Integer" do
|
87
|
-
@obj.to_ruby.
|
87
|
+
expect(@obj.to_ruby).to eq(-1)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -94,18 +94,18 @@ describe MsgPack::MsgObject do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should create new floating-point Msg Objects" do
|
97
|
-
@obj.type.
|
98
|
-
@obj[:values][:dec].
|
97
|
+
expect(@obj.type).to eq(:double)
|
98
|
+
expect(@obj[:values][:dec]).to eq(0.002)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should create floating-point Msg Objects from Floats" do
|
102
102
|
obj1 = MsgPack::MsgObject.new_object(0.002)
|
103
103
|
|
104
|
-
obj1.type.
|
104
|
+
expect(obj1.type).to eq(:double)
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should return a Ruby Float" do
|
108
|
-
@obj.to_ruby.
|
108
|
+
expect(@obj.to_ruby).to eq(0.002)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -116,26 +116,26 @@ describe MsgPack::MsgObject do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
it "should create new raw Msg Objects" do
|
119
|
-
@obj.type.
|
119
|
+
expect(@obj.type).to eq(:raw)
|
120
120
|
|
121
|
-
@obj[:values][:raw].length.
|
122
|
-
@obj[:values][:raw].to_s.
|
121
|
+
expect(@obj[:values][:raw].length).to eq(@binary.length)
|
122
|
+
expect(@obj[:values][:raw].to_s).to eq(@binary)
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should create raw Msg Objects from Strings" do
|
126
126
|
obj = MsgPack::MsgObject.new_object(@binary)
|
127
127
|
|
128
|
-
obj.type.
|
128
|
+
expect(obj.type).to eq(:raw)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should create raw Msg Objects from Symbols" do
|
132
132
|
obj = MsgPack::MsgObject.new_object(:example)
|
133
133
|
|
134
|
-
obj.type.
|
134
|
+
expect(obj.type).to eq(:raw)
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should return a String" do
|
138
|
-
@obj.to_ruby.
|
138
|
+
expect(@obj.to_ruby).to eq(@binary)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -146,19 +146,19 @@ describe MsgPack::MsgObject do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should create new array Msg Objects" do
|
149
|
-
@obj.type.
|
149
|
+
expect(@obj.type).to eq(:array)
|
150
150
|
|
151
|
-
@obj[:values][:array].length.
|
151
|
+
expect(@obj[:values][:array].length).to eq(@array.length)
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should create array Msg Objects from Arrays" do
|
155
155
|
obj = MsgPack::MsgObject.new_object(@array)
|
156
156
|
|
157
|
-
obj.type.
|
157
|
+
expect(obj.type).to eq(:array)
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should return a Ruby Array" do
|
161
|
-
@obj.to_ruby.
|
161
|
+
expect(@obj.to_ruby).to eq(@array)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -175,56 +175,56 @@ describe MsgPack::MsgObject do
|
|
175
175
|
end
|
176
176
|
|
177
177
|
it "should create new map Msg Objects" do
|
178
|
-
@obj.type.
|
178
|
+
expect(@obj.type).to eq(:map)
|
179
179
|
|
180
|
-
@obj[:values][:map].length.
|
180
|
+
expect(@obj[:values][:map].length).to eq(@hash.length)
|
181
181
|
end
|
182
182
|
|
183
183
|
it "should create map Msg Objects from Hashes" do
|
184
184
|
obj = MsgPack::MsgObject.new_object(@hash)
|
185
185
|
|
186
|
-
obj.type.
|
186
|
+
expect(obj.type).to eq(:map)
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should return a Ruby Hash" do
|
190
|
-
@obj.to_ruby.
|
190
|
+
expect(@obj.to_ruby).to eq(@hash)
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should create highly nested Msg Objects" do
|
195
195
|
obj = MsgPack::MsgObject.new_object({'one' => {2 => [3.0]}})
|
196
196
|
|
197
|
-
obj[:type].
|
197
|
+
expect(obj[:type]).to eq(:map)
|
198
198
|
map = obj[:values][:map]
|
199
|
-
map[:size].
|
199
|
+
expect(map[:size]).to eq(1)
|
200
200
|
|
201
201
|
pair = MsgPack::MsgKeyValue.new(map[:ptr])
|
202
202
|
|
203
203
|
key = pair[:key]
|
204
|
-
key[:type].
|
204
|
+
expect(key[:type]).to eq(:raw)
|
205
205
|
|
206
206
|
raw = key[:values][:raw]
|
207
|
-
raw[:ptr].
|
207
|
+
expect(raw[:ptr].read_bytes(raw[:size])).to eq('one')
|
208
208
|
|
209
209
|
value = pair[:value]
|
210
|
-
value[:type].
|
210
|
+
expect(value[:type]).to eq(:map)
|
211
211
|
|
212
212
|
map = value[:values][:map]
|
213
|
-
map[:size].
|
213
|
+
expect(map[:size]).to eq(1)
|
214
214
|
|
215
215
|
pair = MsgPack::MsgKeyValue.new(map[:ptr])
|
216
216
|
key = pair[:key]
|
217
|
-
key[:type].
|
218
|
-
key[:values][:i64].
|
217
|
+
expect(key[:type]).to eq(:positive_integer)
|
218
|
+
expect(key[:values][:i64]).to eq(2)
|
219
219
|
|
220
220
|
value = pair[:value]
|
221
|
-
value[:type].
|
221
|
+
expect(value[:type]).to eq(:array)
|
222
222
|
|
223
223
|
array = value[:values][:array]
|
224
|
-
array[:size].
|
224
|
+
expect(array[:size]).to eq(1)
|
225
225
|
|
226
226
|
value = MsgPack::MsgObject.new(array[:ptr])
|
227
|
-
value[:type].
|
228
|
-
value[:values][:dec].
|
227
|
+
expect(value[:type]).to eq(:double)
|
228
|
+
expect(value[:values][:dec]).to eq(3.0)
|
229
229
|
end
|
230
230
|
end
|
data/spec/packer_spec.rb
CHANGED
@@ -9,15 +9,15 @@ describe MsgPack::Packer do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should write packed messages to a buffer" do
|
12
|
-
@packer.buffer.
|
12
|
+
expect(@packer.buffer).to eq("\x01")
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should track the number of bytes written" do
|
16
|
-
@packer.total.
|
16
|
+
expect(@packer.total).to eq(1)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should be convertable to a String" do
|
20
|
-
@packer.to_s.
|
20
|
+
expect(@packer.to_s).to eq("\x01")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -32,7 +32,7 @@ describe MsgPack::Packer do
|
|
32
32
|
end
|
33
33
|
packer << 1
|
34
34
|
|
35
|
-
@buffer.
|
35
|
+
expect(@buffer).to eq(["\x01"])
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should track the number of bytes written" do
|
@@ -41,7 +41,7 @@ describe MsgPack::Packer do
|
|
41
41
|
end
|
42
42
|
packer << 1
|
43
43
|
|
44
|
-
packer.total.
|
44
|
+
expect(packer.total).to eq(1)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should accept a secondary length argument" do
|
@@ -50,13 +50,13 @@ describe MsgPack::Packer do
|
|
50
50
|
end
|
51
51
|
packer << 1
|
52
52
|
|
53
|
-
@buffer.
|
53
|
+
expect(@buffer).to eq([["\x01", 1]])
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should not be convertable to a String" do
|
57
57
|
packer = MsgPack::Packer.create { |packed| }
|
58
58
|
|
59
|
-
packer.to_s.
|
59
|
+
expect(packer.to_s).to eq(nil)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/unpacker_spec.rb
CHANGED
@@ -18,17 +18,17 @@ describe MsgPack::Unpacker do
|
|
18
18
|
@unpacker << @packed
|
19
19
|
size2 = @unpacker[:used]
|
20
20
|
|
21
|
-
(size2 - size1).
|
21
|
+
expect(size2 - size1).to eq(@packed.length)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should enqueue data from IO objects into the buffer" do
|
25
25
|
io = StringIO.new(@packed)
|
26
26
|
|
27
27
|
size1 = @unpacker[:used]
|
28
|
-
@unpacker.read(io).
|
28
|
+
expect(@unpacker.read(io)).to eq(true)
|
29
29
|
size2 = @unpacker[:used]
|
30
30
|
|
31
|
-
(size2 - size1).
|
31
|
+
expect(size2 - size1).to eq(@packed.length)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -46,7 +46,7 @@ describe MsgPack::Unpacker do
|
|
46
46
|
objs << [obj.type, obj.values[:u64]]
|
47
47
|
end
|
48
48
|
|
49
|
-
objs.
|
49
|
+
expect(objs).to eq(expected)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should unpack each Msg Object from a stream" do
|
@@ -63,7 +63,7 @@ describe MsgPack::Unpacker do
|
|
63
63
|
objs << [obj.type, obj.values[:u64]]
|
64
64
|
end
|
65
65
|
|
66
|
-
objs.
|
66
|
+
expect(objs).to eq(expected)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
metadata
CHANGED
@@ -1,80 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Postmodern
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-11-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: ffi
|
16
14
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
15
|
requirements:
|
19
|
-
- - ~>
|
16
|
+
- - "~>"
|
20
17
|
- !ruby/object:Gem::Version
|
21
18
|
version: '1.0'
|
19
|
+
name: ffi
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: rubygems-tasks
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0.1'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0.1'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2.4'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.4'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: yard
|
64
28
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
29
|
requirements:
|
67
|
-
- - ~>
|
30
|
+
- - "~>"
|
68
31
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0
|
32
|
+
version: '2.0'
|
33
|
+
name: bundler
|
70
34
|
type: :development
|
71
35
|
prerelease: false
|
72
36
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
37
|
requirements:
|
75
|
-
- - ~>
|
38
|
+
- - "~>"
|
76
39
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0
|
40
|
+
version: '2.0'
|
78
41
|
description: Ruby FFI bindings for the msgpack library.
|
79
42
|
email: postmodern.mod3@gmail.com
|
80
43
|
executables: []
|
@@ -84,11 +47,13 @@ extra_rdoc_files:
|
|
84
47
|
- LICENSE.txt
|
85
48
|
- README.md
|
86
49
|
files:
|
87
|
-
- .gemtest
|
88
|
-
- .
|
89
|
-
- .
|
90
|
-
- .
|
50
|
+
- ".gemtest"
|
51
|
+
- ".github/workflows/ruby.yml"
|
52
|
+
- ".gitignore"
|
53
|
+
- ".rspec"
|
54
|
+
- ".yardopts"
|
91
55
|
- ChangeLog.md
|
56
|
+
- Gemfile
|
92
57
|
- LICENSE.txt
|
93
58
|
- README.md
|
94
59
|
- Rakefile
|
@@ -137,39 +102,25 @@ files:
|
|
137
102
|
homepage: https://github.com/postmodern/ffi-msgpack
|
138
103
|
licenses:
|
139
104
|
- MIT
|
140
|
-
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
141
107
|
rdoc_options: []
|
142
108
|
require_paths:
|
143
109
|
- lib
|
144
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
111
|
requirements:
|
147
|
-
- -
|
112
|
+
- - ">="
|
148
113
|
- !ruby/object:Gem::Version
|
149
114
|
version: '0'
|
150
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
-
none: false
|
152
116
|
requirements:
|
153
|
-
- -
|
117
|
+
- - ">="
|
154
118
|
- !ruby/object:Gem::Version
|
155
119
|
version: '0'
|
156
120
|
requirements:
|
157
121
|
- libmsgpack >= 0.5.0
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
specification_version: 3
|
122
|
+
rubygems_version: 3.0.6
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
162
125
|
summary: FFI bindings for msgpack
|
163
|
-
test_files:
|
164
|
-
- spec/extensions/array_spec.rb
|
165
|
-
- spec/extensions/false_class_spec.rb
|
166
|
-
- spec/extensions/float_spec.rb
|
167
|
-
- spec/extensions/hash_spec.rb
|
168
|
-
- spec/extensions/integer_spec.rb
|
169
|
-
- spec/extensions/nil_class_spec.rb
|
170
|
-
- spec/extensions/string_spec.rb
|
171
|
-
- spec/extensions/symbol_spec.rb
|
172
|
-
- spec/extensions/true_class_spec.rb
|
173
|
-
- spec/msg_object_spec.rb
|
174
|
-
- spec/packer_spec.rb
|
175
|
-
- spec/unpacker_spec.rb
|
126
|
+
test_files: []
|