paquito 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/Gemfile.lock +4 -10
- data/lib/paquito/codec_factory.rb +0 -3
- data/lib/paquito/types.rb +9 -29
- data/lib/paquito/version.rb +1 -1
- data/paquito.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7827d51263d503a0798dda51d14f0233f7a310e37f247b14a5ea13454403b3a5
|
4
|
+
data.tar.gz: 63381b29bd17cbc2473036ef0f6ca8eee60f099e7d2f70202a6922ba6721313a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75dba9ef5f38a56e765736b63549168e049d695615e6bc6bc545bb05deb7104b452094556cc3899d8fa0bf677ae7deef944f92f71c816af5f390a0e03c0f111b
|
7
|
+
data.tar.gz: 56d37636f06418d32263a803b84fb1bf15cd4fe07b6b7fd7bf28252e162aabfdedc8cfb9d2ac5e2c03231cd0b4b2bb7cd3b879f43ced04b0af753923cbca5bff
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/msgpack/msgpack-ruby.git
|
3
|
-
revision: b69e6d6965ef46890885ddf73f02b820f3185d80
|
4
|
-
specs:
|
5
|
-
msgpack (1.4.5)
|
6
|
-
|
7
1
|
PATH
|
8
2
|
remote: .
|
9
3
|
specs:
|
10
|
-
paquito (0.
|
11
|
-
msgpack
|
4
|
+
paquito (0.6.0)
|
5
|
+
msgpack (>= 1.5.1)
|
12
6
|
|
13
7
|
GEM
|
14
8
|
remote: https://rubygems.org/
|
@@ -31,6 +25,7 @@ GEM
|
|
31
25
|
i18n (1.10.0)
|
32
26
|
concurrent-ruby (~> 1.0)
|
33
27
|
minitest (5.15.0)
|
28
|
+
msgpack (1.5.1)
|
34
29
|
parallel (1.21.0)
|
35
30
|
parser (3.1.1.0)
|
36
31
|
ast (~> 2.4.1)
|
@@ -70,7 +65,6 @@ DEPENDENCIES
|
|
70
65
|
benchmark-ips
|
71
66
|
byebug
|
72
67
|
minitest (~> 5.0)
|
73
|
-
msgpack!
|
74
68
|
paquito!
|
75
69
|
rake (~> 13.0)
|
76
70
|
rubocop
|
@@ -79,4 +73,4 @@ DEPENDENCIES
|
|
79
73
|
sqlite3
|
80
74
|
|
81
75
|
BUNDLED WITH
|
82
|
-
2.
|
76
|
+
2.3.11
|
@@ -16,9 +16,6 @@ module Paquito
|
|
16
16
|
Types.register_serializable_type(factory) if serializable_type
|
17
17
|
|
18
18
|
if pool && pool > 0 && factory.respond_to?(:pool)
|
19
|
-
if serializable_type || types.any? { |t| Types.recursive?(t) }
|
20
|
-
pool *= 2
|
21
|
-
end
|
22
19
|
factory = factory.freeze.pool(pool, freeze: freeze)
|
23
20
|
freeze = false
|
24
21
|
end
|
data/lib/paquito/types.rb
CHANGED
@@ -75,8 +75,8 @@ module Paquito
|
|
75
75
|
TYPES = {
|
76
76
|
"Symbol" => {
|
77
77
|
code: 0,
|
78
|
-
packer: Symbol.method_defined?(:name) ? :name : :to_s,
|
79
|
-
unpacker: :to_sym,
|
78
|
+
packer: Symbol.method_defined?(:name) ? :name.to_proc : :to_s.to_proc,
|
79
|
+
unpacker: :to_sym.to_proc,
|
80
80
|
optimized_symbols_parsing: true,
|
81
81
|
}.freeze,
|
82
82
|
"Time" => {
|
@@ -153,14 +153,15 @@ module Paquito
|
|
153
153
|
}.freeze,
|
154
154
|
"ActiveSupport::HashWithIndifferentAccess" => {
|
155
155
|
code: 7,
|
156
|
-
packer: ->(
|
156
|
+
packer: ->(value, packer) do
|
157
157
|
unless value.instance_of?(ActiveSupport::HashWithIndifferentAccess)
|
158
158
|
raise PackError.new("cannot pack HashWithIndifferentClass subclass", value)
|
159
159
|
end
|
160
160
|
|
161
|
-
|
161
|
+
packer.write(value.to_h)
|
162
162
|
end,
|
163
|
-
unpacker: ->(
|
163
|
+
unpacker: ->(unpacker) { HashWithIndifferentAccess.new(unpacker.read) },
|
164
|
+
recursive: true,
|
164
165
|
},
|
165
166
|
"ActiveSupport::TimeWithZone" => {
|
166
167
|
code: 8,
|
@@ -180,8 +181,9 @@ module Paquito
|
|
180
181
|
},
|
181
182
|
"Set" => {
|
182
183
|
code: 9,
|
183
|
-
packer: ->(
|
184
|
-
unpacker: ->(
|
184
|
+
packer: ->(value, packer) { packer.write(value.to_a) },
|
185
|
+
unpacker: ->(unpacker) { unpacker.read.to_set },
|
186
|
+
recursive: true,
|
185
187
|
},
|
186
188
|
# Integer => { code: 10 }, reserved for oversized Integer
|
187
189
|
# Object => { code: 127 }, reserved for serializable Object type
|
@@ -212,10 +214,6 @@ module Paquito
|
|
212
214
|
end
|
213
215
|
|
214
216
|
type_attributes = TYPES.fetch(name)
|
215
|
-
type_attributes = type_attributes.merge(
|
216
|
-
packer: curry_callback(type_attributes.fetch(:packer), factory),
|
217
|
-
unpacker: curry_callback(type_attributes.fetch(:unpacker), factory),
|
218
|
-
)
|
219
217
|
factory.register_type(
|
220
218
|
type_attributes.fetch(:code),
|
221
219
|
type,
|
@@ -224,11 +222,6 @@ module Paquito
|
|
224
222
|
end
|
225
223
|
end
|
226
224
|
|
227
|
-
def recursive?(type)
|
228
|
-
type_attributes = TYPES.fetch(type.name)
|
229
|
-
recursive_callback?(type_attributes[:packer]) || recursive_callback?(type_attributes[:unpacker])
|
230
|
-
end
|
231
|
-
|
232
225
|
def register_serializable_type(factory)
|
233
226
|
factory.register_type(
|
234
227
|
0x7f,
|
@@ -256,19 +249,6 @@ module Paquito
|
|
256
249
|
def define_custom_type(klass, packer: nil, unpacker:)
|
257
250
|
CustomTypesRegistry.register(klass, packer: packer, unpacker: unpacker)
|
258
251
|
end
|
259
|
-
|
260
|
-
private
|
261
|
-
|
262
|
-
def recursive_callback?(callback)
|
263
|
-
callback.respond_to?(:arity) && callback.arity != 1
|
264
|
-
end
|
265
|
-
|
266
|
-
def curry_callback(callback, factory)
|
267
|
-
return callback.to_proc if callback.is_a?(Symbol)
|
268
|
-
return callback if callback.arity == 1
|
269
|
-
|
270
|
-
callback.curry.call(factory)
|
271
|
-
end
|
272
252
|
end
|
273
253
|
end
|
274
254
|
end
|
data/lib/paquito/version.rb
CHANGED
data/paquito.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paquito
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.5.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.5.1
|
27
27
|
description: Framework for defining efficient and extendable serializers
|
28
28
|
email:
|
29
29
|
- jean.boussier@gmail.com
|