paquito 0.9.0 → 0.9.1

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: 2882e208a7d6cc2c9b98f748578ea1c8e91133a5ecc71fdc4e41861bb7788f7e
4
- data.tar.gz: 8376bc939c974028dd6957e1d98467594c33807cdf13fc0470b216aa2476f9ce
3
+ metadata.gz: e0339ed04d21077425e5dd4b2e814a63ec524ca4806bc3af33b82fc162b61205
4
+ data.tar.gz: 55b5ff0b7b2c325622307b6d6a25a978067ec69762993fc6d7f5f732fcc11301
5
5
  SHA512:
6
- metadata.gz: 7bb6ab11609d478cae8993c65fb12db8ea22363064401c718f6e6915ccdd75ad9ddd5c3f7a5a88a8c0562e943c2fda44c4dab101a3db4266f26134ae2ac0e26f
7
- data.tar.gz: 268549cd0b872b554397b7d685e0ba9f8db9572690091ebaa4936e7a488a26569e9691ad0bfdf2447d1521a36aa5c26b8a7acf96a04271d449c0a6036de7d777
6
+ metadata.gz: 264f88b37a150446c8e3d021887321fe1f47138894ac36a06e57105107f0f47add8ad82bd5e95078a50387ae4daad95154ebc5e1ce2bfde1b758a74e4559087c
7
+ data.tar.gz: 3775371cc85bd799bdb9580f878e3c5a33c1a10020e9349afe5eecfcac7d65552a96e76eb72b387bc72dbce375a9f03f85151bdcdf27de8ceb8d23a73560b792
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Unreleased
2
2
 
3
+ # 0.9.1
4
+
5
+ * Fix a bug when handle `compress / decompress` coders. (#23)
6
+ * `SingleBytePrefixVersionWithStringBypass` accepts another coder for strings.
7
+
3
8
  # 0.9.0
4
9
 
5
10
  * Handle `compress / decompress` coders (#22)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paquito (0.9.0)
4
+ paquito (0.9.1)
5
5
  msgpack (>= 1.5.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -70,6 +70,18 @@ in an optimized way.
70
70
  When the object to serialize is an `UTF-8`, `ASCII` or `BINARY` string, rather than invoking the underlying serializer, it simply
71
71
  prepends a single byte to the string which indicates the encoding.
72
72
 
73
+ Additionally, you can pass a distinct serializer for strings only:
74
+
75
+ Example:
76
+
77
+ ```ruby
78
+ coder = Paquito::SingleBytePrefixVersion.new(
79
+ 1,
80
+ { 0 => YAML, 1 => JSON },
81
+ Paquito::ConditionalCompressor.new(Zlib, 1024), # Large strings will be compressed but not serialized in JSON.
82
+ )
83
+ ```
84
+
73
85
  The larger the string the larger the speed gain is, e.g. for a 1MB string, it's over 500x faster than going through `MessagePack` or `Marshal`.
74
86
 
75
87
  ### `CommentPrefixVersion`
@@ -6,15 +6,20 @@ module Paquito
6
6
  BINARY_VERSION = 254
7
7
  ASCII_VERSION = 253
8
8
 
9
+ def initialize(current_version, coders, string_coder = nil)
10
+ super(current_version, coders)
11
+ @string_coder = string_coder
12
+ end
13
+
9
14
  def dump(object)
10
15
  if object.class == String # We don't want to match subclasses
11
16
  case object.encoding
12
17
  when Encoding::UTF_8
13
- UTF8_VERSION.chr(Encoding::BINARY) << object
18
+ UTF8_VERSION.chr(Encoding::BINARY) << (@string_coder ? @string_coder.dump(object) : object)
14
19
  when Encoding::BINARY
15
- BINARY_VERSION.chr(Encoding::BINARY) << object
20
+ BINARY_VERSION.chr(Encoding::BINARY) << (@string_coder ? @string_coder.dump(object) : object)
16
21
  when Encoding::US_ASCII
17
- ASCII_VERSION.chr(Encoding::BINARY) << object
22
+ ASCII_VERSION.chr(Encoding::BINARY) << (@string_coder ? @string_coder.dump(object) : object)
18
23
  else
19
24
  super
20
25
  end
@@ -31,11 +36,14 @@ module Paquito
31
36
 
32
37
  case payload_version
33
38
  when UTF8_VERSION
34
- payload.byteslice(1..-1).force_encoding(Encoding::UTF_8)
39
+ string = payload.byteslice(1..-1).force_encoding(Encoding::UTF_8)
40
+ @string_coder ? @string_coder.load(string) : string
35
41
  when BINARY_VERSION
36
- payload.byteslice(1..-1).force_encoding(Encoding::BINARY)
42
+ string = payload.byteslice(1..-1).force_encoding(Encoding::BINARY)
43
+ @string_coder ? @string_coder.load(string) : string
37
44
  when ASCII_VERSION
38
- payload.byteslice(1..-1).force_encoding(Encoding::US_ASCII)
45
+ string = payload.byteslice(1..-1).force_encoding(Encoding::US_ASCII)
46
+ @string_coder ? @string_coder.load(string) : string
39
47
  else
40
48
  coder = @coders.fetch(payload_version) do
41
49
  raise UnsupportedCodec, "Unsupported packer version #{payload_version}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paquito
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  end
data/lib/paquito.rb CHANGED
@@ -10,6 +10,7 @@ require "msgpack"
10
10
 
11
11
  require "paquito/version"
12
12
  require "paquito/deflater"
13
+ require "paquito/compressor"
13
14
  require "paquito/allow_nil"
14
15
  require "paquito/translate_errors"
15
16
  require "paquito/safe_yaml"
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.9.0
4
+ version: 0.9.1
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-12-08 00:00:00.000000000 Z
11
+ date: 2022-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack