msgpack 1.7.0-java → 1.7.2-java
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 +4 -4
- data/lib/msgpack/factory.rb +49 -10
- data/lib/msgpack/msgpack.jar +0 -0
- data/lib/msgpack/packer.rb +6 -1
- data/lib/msgpack/unpacker.rb +10 -1
- data/lib/msgpack/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2b1bd1178825a102da3acb1f77600cf9ea08e49fac9464ed6e60857ac3d4676
|
4
|
+
data.tar.gz: 9a64ae03c155e4a5149dc53134a660041dca33dc845f05226164a5034c212370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2bd2d41830cbd6a3d98871cf8e91a27291cc52ba6418e5a40ede28a94f935e9e7b2fd0ebf10724fb032f2c57f29db70094fb33a616161be9a8a32d54c2a68d
|
7
|
+
data.tar.gz: 7624f2dfd66975bbda4aad5b8ad4a393a5f7f3699a7ed5776f51d31bc56a8d82f7ab8e8bffd7dccbb37a980cd77d1c18aeb0cc017c60d5be3763b66d53ec00ea
|
data/lib/msgpack/factory.rb
CHANGED
@@ -2,11 +2,46 @@ module MessagePack
|
|
2
2
|
class Factory
|
3
3
|
# see ext for other methods
|
4
4
|
|
5
|
+
def register_type(type, klass, options = { packer: :to_msgpack_ext, unpacker: :from_msgpack_ext })
|
6
|
+
raise FrozenError, "can't modify frozen MessagePack::Factory" if frozen?
|
7
|
+
|
8
|
+
if options
|
9
|
+
options = options.dup
|
10
|
+
case packer = options[:packer]
|
11
|
+
when nil, Proc
|
12
|
+
# all good
|
13
|
+
when String, Symbol
|
14
|
+
options[:packer] = packer.to_sym.to_proc
|
15
|
+
when Method
|
16
|
+
options[:packer] = packer.to_proc
|
17
|
+
when packer.respond_to?(:call)
|
18
|
+
options[:packer] = packer.method(:call).to_proc
|
19
|
+
else
|
20
|
+
raise ::TypeError, "expected :packer argument to be a callable object, got: #{packer.inspect}"
|
21
|
+
end
|
22
|
+
|
23
|
+
case unpacker = options[:unpacker]
|
24
|
+
when nil, Proc
|
25
|
+
# all good
|
26
|
+
when String, Symbol
|
27
|
+
options[:unpacker] = klass.method(unpacker).to_proc
|
28
|
+
when Method
|
29
|
+
options[:unpacker] = unpacker.to_proc
|
30
|
+
when packer.respond_to?(:call)
|
31
|
+
options[:unpacker] = unpacker.method(:call).to_proc
|
32
|
+
else
|
33
|
+
raise ::TypeError, "expected :unpacker argument to be a callable object, got: #{unpacker.inspect}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
register_type_internal(type, klass, options)
|
38
|
+
end
|
39
|
+
|
5
40
|
# [ {type: id, class: Class(or nil), packer: arg, unpacker: arg}, ... ]
|
6
41
|
def registered_types(selector=:both)
|
7
42
|
packer, unpacker = registered_types_internal
|
8
|
-
# packer: Class -> [tid, proc,
|
9
|
-
# unpacker: tid -> [klass, proc,
|
43
|
+
# packer: Class -> [tid, proc, _flags]
|
44
|
+
# unpacker: tid -> [klass, proc, _flags]
|
10
45
|
|
11
46
|
list = []
|
12
47
|
|
@@ -14,27 +49,31 @@ module MessagePack
|
|
14
49
|
when :both
|
15
50
|
packer.each_pair do |klass, ary|
|
16
51
|
type = ary[0]
|
17
|
-
|
18
|
-
|
19
|
-
if unpacker.has_key?(type)
|
20
|
-
|
52
|
+
packer_proc = ary[1]
|
53
|
+
unpacker_proc = nil
|
54
|
+
if unpacker.has_key?(type)
|
55
|
+
unpacker_proc = unpacker.delete(type)[1]
|
21
56
|
end
|
22
|
-
list << {type: type, class: klass, packer:
|
57
|
+
list << {type: type, class: klass, packer: packer_proc, unpacker: unpacker_proc}
|
23
58
|
end
|
24
59
|
|
25
60
|
# unpacker definition only
|
26
61
|
unpacker.each_pair do |type, ary|
|
27
|
-
list << {type: type, class: ary[0], packer: nil, unpacker: ary[
|
62
|
+
list << {type: type, class: ary[0], packer: nil, unpacker: ary[1]}
|
28
63
|
end
|
29
64
|
|
30
65
|
when :packer
|
31
66
|
packer.each_pair do |klass, ary|
|
32
|
-
|
67
|
+
if ary[1]
|
68
|
+
list << {type: ary[0], class: klass, packer: ary[1]}
|
69
|
+
end
|
33
70
|
end
|
34
71
|
|
35
72
|
when :unpacker
|
36
73
|
unpacker.each_pair do |type, ary|
|
37
|
-
|
74
|
+
if ary[1]
|
75
|
+
list << {type: type, class: ary[0], unpacker: ary[1]}
|
76
|
+
end
|
38
77
|
end
|
39
78
|
|
40
79
|
else
|
data/lib/msgpack/msgpack.jar
CHANGED
Binary file
|
data/lib/msgpack/packer.rb
CHANGED
@@ -6,11 +6,16 @@ module MessagePack
|
|
6
6
|
undef_method :dup
|
7
7
|
undef_method :clone
|
8
8
|
|
9
|
+
def register_type(type, klass, method_name = nil, &block)
|
10
|
+
raise ArgumentError, "expected Module/Class got: #{klass.inspect}" unless klass.is_a?(Module)
|
11
|
+
register_type_internal(type, klass, block || method_name.to_proc)
|
12
|
+
end
|
13
|
+
|
9
14
|
def registered_types
|
10
15
|
list = []
|
11
16
|
|
12
17
|
registered_types_internal.each_pair do |klass, ary|
|
13
|
-
list << {type: ary[0], class: klass, packer: ary[
|
18
|
+
list << {type: ary[0], class: klass, packer: ary[1]}
|
14
19
|
end
|
15
20
|
|
16
21
|
list.sort{|a, b| a[:type] <=> b[:type] }
|
data/lib/msgpack/unpacker.rb
CHANGED
@@ -6,11 +6,20 @@ module MessagePack
|
|
6
6
|
undef_method :dup
|
7
7
|
undef_method :clone
|
8
8
|
|
9
|
+
def register_type(type, klass = nil, method_name = nil, &block)
|
10
|
+
if klass && method_name
|
11
|
+
block = klass.method(method_name).to_proc
|
12
|
+
elsif !block_given?
|
13
|
+
raise ArgumentError, "register_type takes either 3 arguments or a block"
|
14
|
+
end
|
15
|
+
register_type_internal(type, klass, block)
|
16
|
+
end
|
17
|
+
|
9
18
|
def registered_types
|
10
19
|
list = []
|
11
20
|
|
12
21
|
registered_types_internal.each_pair do |type, ary|
|
13
|
-
list << {type: type, class: ary[0], unpacker: ary[
|
22
|
+
list << {type: type, class: ary[0], unpacker: ary[1]}
|
14
23
|
end
|
15
24
|
|
16
25
|
list.sort{|a, b| a[:type] <=> b[:type] }
|
data/lib/msgpack/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.3.25
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: MessagePack, a binary-based efficient data interchange format.
|