paquito 0.9.0 → 0.9.1
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/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/lib/paquito/single_byte_prefix_version_with_string_bypass.rb +14 -6
- data/lib/paquito/version.rb +1 -1
- data/lib/paquito.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0339ed04d21077425e5dd4b2e814a63ec524ca4806bc3af33b82fc162b61205
|
4
|
+
data.tar.gz: 55b5ff0b7b2c325622307b6d6a25a978067ec69762993fc6d7f5f732fcc11301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 264f88b37a150446c8e3d021887321fe1f47138894ac36a06e57105107f0f47add8ad82bd5e95078a50387ae4daad95154ebc5e1ce2bfde1b758a74e4559087c
|
7
|
+
data.tar.gz: 3775371cc85bd799bdb9580f878e3c5a33c1a10020e9349afe5eecfcac7d65552a96e76eb72b387bc72dbce375a9f03f85151bdcdf27de8ceb8d23a73560b792
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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}"
|
data/lib/paquito/version.rb
CHANGED
data/lib/paquito.rb
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.9.
|
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-
|
11
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|