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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6fef6b415e3f3f99d82d937b412923f77675f2fd2b458c67a79b17325df5c4b
4
- data.tar.gz: a3805612f06f9a04a2c3c452f571798d086113ff601ee550623e975abd66ac15
3
+ metadata.gz: 7827d51263d503a0798dda51d14f0233f7a310e37f247b14a5ea13454403b3a5
4
+ data.tar.gz: 63381b29bd17cbc2473036ef0f6ca8eee60f099e7d2f70202a6922ba6721313a
5
5
  SHA512:
6
- metadata.gz: 76457976e3d2bbf665b38922d0e9be0d62bfa7ecb34e7a55c3931eff29260646a92e7b5f6ed04ff53a350cc035c4e794e9a079be39cb95b1f6f261211db94a2e
7
- data.tar.gz: ed1156971e6736ee6b9abab62edb2b6eabb5ad1751a3d6d2aa48b84c444b5720dc21ba713721f82c10a7f0cbf629520ef0bc1e8625702afc683494b4fd940e22
6
+ metadata.gz: 75dba9ef5f38a56e765736b63549168e049d695615e6bc6bc545bb05deb7104b452094556cc3899d8fa0bf677ae7deef944f92f71c816af5f390a0e03c0f111b
7
+ data.tar.gz: 56d37636f06418d32263a803b84fb1bf15cd4fe07b6b7fd7bf28252e162aabfdedc8cfb9d2ac5e2c03231cd0b4b2bb7cd3b879f43ced04b0af753923cbca5bff
data/Gemfile CHANGED
@@ -5,8 +5,6 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in paquito.gemspec
6
6
  gemspec
7
7
 
8
- gem "msgpack", github: "msgpack/msgpack-ruby"
9
-
10
8
  gem "rake", "~> 13.0"
11
9
  gem "activesupport"
12
10
  gem "activerecord"
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.5.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.2.33
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: ->(factory, value) do
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
- factory.dump(value.to_h)
161
+ packer.write(value.to_h)
162
162
  end,
163
- unpacker: ->(factory, value) { HashWithIndifferentAccess.new(factory.load(value)) },
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: ->(factory, value) { factory.dump(value.to_a) },
184
- unpacker: ->(factory, value) { factory.load(value).to_set },
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paquito
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
data/paquito.gemspec CHANGED
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
31
- spec.add_dependency("msgpack")
31
+ spec.add_dependency("msgpack", ">= 1.5.1")
32
32
  end
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.5.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-03-16 00:00:00.000000000 Z
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: '0'
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: '0'
26
+ version: 1.5.1
27
27
  description: Framework for defining efficient and extendable serializers
28
28
  email:
29
29
  - jean.boussier@gmail.com