msgpack 1.6.0 → 1.7.2
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 +25 -0
- data/README.md +27 -0
- data/ext/java/org/msgpack/jruby/Buffer.java +3 -3
- data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +11 -20
- data/ext/java/org/msgpack/jruby/ExtensionValue.java +1 -1
- data/ext/java/org/msgpack/jruby/Factory.java +11 -50
- data/ext/java/org/msgpack/jruby/Packer.java +9 -24
- data/ext/java/org/msgpack/jruby/Unpacker.java +15 -32
- data/ext/msgpack/buffer.c +16 -17
- data/ext/msgpack/buffer.h +2 -8
- data/ext/msgpack/buffer_class.c +76 -5
- data/ext/msgpack/buffer_class.h +1 -0
- data/ext/msgpack/extconf.rb +18 -26
- data/ext/msgpack/factory_class.c +27 -61
- data/ext/msgpack/packer.c +13 -14
- data/ext/msgpack/packer.h +0 -4
- data/ext/msgpack/packer_class.c +19 -54
- data/ext/msgpack/packer_ext_registry.c +31 -28
- data/ext/msgpack/packer_ext_registry.h +10 -14
- data/ext/msgpack/rbinit.c +1 -1
- data/ext/msgpack/rmem.c +3 -4
- data/ext/msgpack/unpacker.c +12 -25
- data/ext/msgpack/unpacker.h +0 -4
- data/ext/msgpack/unpacker_class.c +14 -49
- data/ext/msgpack/unpacker_ext_registry.c +4 -16
- data/ext/msgpack/unpacker_ext_registry.h +3 -7
- data/lib/msgpack/buffer.rb +9 -0
- data/lib/msgpack/factory.rb +90 -63
- data/lib/msgpack/packer.rb +10 -1
- data/lib/msgpack/unpacker.rb +14 -1
- data/lib/msgpack/version.rb +1 -1
- data/lib/msgpack.rb +1 -0
- data/msgpack.gemspec +6 -3
- metadata +19 -48
- data/.github/workflows/ci.yaml +0 -57
- data/.gitignore +0 -23
- data/.rubocop.yml +0 -36
- data/Gemfile +0 -9
- data/Rakefile +0 -70
- data/appveyor.yml +0 -18
- data/bench/bench.rb +0 -78
- data/bin/console +0 -8
- data/doclib/msgpack/buffer.rb +0 -193
- data/doclib/msgpack/core_ext.rb +0 -101
- data/doclib/msgpack/error.rb +0 -19
- data/doclib/msgpack/extension_value.rb +0 -9
- data/doclib/msgpack/factory.rb +0 -145
- data/doclib/msgpack/packer.rb +0 -209
- data/doclib/msgpack/time.rb +0 -22
- data/doclib/msgpack/timestamp.rb +0 -44
- data/doclib/msgpack/unpacker.rb +0 -183
- data/doclib/msgpack.rb +0 -87
- data/msgpack.org.md +0 -46
- data/spec/bigint_spec.rb +0 -26
- data/spec/cases.json +0 -1
- data/spec/cases.msg +0 -0
- data/spec/cases_compact.msg +0 -0
- data/spec/cases_spec.rb +0 -39
- data/spec/cruby/buffer_io_spec.rb +0 -255
- data/spec/cruby/buffer_packer.rb +0 -29
- data/spec/cruby/buffer_spec.rb +0 -592
- data/spec/cruby/buffer_unpacker.rb +0 -19
- data/spec/cruby/unpacker_spec.rb +0 -70
- data/spec/ext_value_spec.rb +0 -99
- data/spec/exttypes.rb +0 -51
- data/spec/factory_spec.rb +0 -706
- data/spec/format_spec.rb +0 -301
- data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
- data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
- data/spec/jruby/unpacker_spec.rb +0 -186
- data/spec/msgpack_spec.rb +0 -214
- data/spec/pack_spec.rb +0 -61
- data/spec/packer_spec.rb +0 -575
- data/spec/random_compat.rb +0 -24
- data/spec/spec_helper.rb +0 -72
- data/spec/timestamp_spec.rb +0 -159
- data/spec/unpack_spec.rb +0 -57
- data/spec/unpacker_spec.rb +0 -869
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.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
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:
|
13
|
+
date: 2023-07-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -68,6 +68,20 @@ dependencies:
|
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '3.3'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: ruby_memcheck
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
71
85
|
- !ruby/object:Gem::Dependency
|
72
86
|
name: yard
|
73
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,27 +136,9 @@ extensions:
|
|
122
136
|
- ext/msgpack/extconf.rb
|
123
137
|
extra_rdoc_files: []
|
124
138
|
files:
|
125
|
-
- ".github/workflows/ci.yaml"
|
126
|
-
- ".gitignore"
|
127
|
-
- ".rubocop.yml"
|
128
139
|
- ChangeLog
|
129
|
-
- Gemfile
|
130
140
|
- LICENSE
|
131
141
|
- README.md
|
132
|
-
- Rakefile
|
133
|
-
- appveyor.yml
|
134
|
-
- bench/bench.rb
|
135
|
-
- bin/console
|
136
|
-
- doclib/msgpack.rb
|
137
|
-
- doclib/msgpack/buffer.rb
|
138
|
-
- doclib/msgpack/core_ext.rb
|
139
|
-
- doclib/msgpack/error.rb
|
140
|
-
- doclib/msgpack/extension_value.rb
|
141
|
-
- doclib/msgpack/factory.rb
|
142
|
-
- doclib/msgpack/packer.rb
|
143
|
-
- doclib/msgpack/time.rb
|
144
|
-
- doclib/msgpack/timestamp.rb
|
145
|
-
- doclib/msgpack/unpacker.rb
|
146
142
|
- ext/java/org/msgpack/jruby/Buffer.java
|
147
143
|
- ext/java/org/msgpack/jruby/Decoder.java
|
148
144
|
- ext/java/org/msgpack/jruby/Encoder.java
|
@@ -183,6 +179,7 @@ files:
|
|
183
179
|
- ext/msgpack/unpacker_ext_registry.h
|
184
180
|
- lib/msgpack.rb
|
185
181
|
- lib/msgpack/bigint.rb
|
182
|
+
- lib/msgpack/buffer.rb
|
186
183
|
- lib/msgpack/core_ext.rb
|
187
184
|
- lib/msgpack/factory.rb
|
188
185
|
- lib/msgpack/packer.rb
|
@@ -192,32 +189,6 @@ files:
|
|
192
189
|
- lib/msgpack/unpacker.rb
|
193
190
|
- lib/msgpack/version.rb
|
194
191
|
- msgpack.gemspec
|
195
|
-
- msgpack.org.md
|
196
|
-
- spec/bigint_spec.rb
|
197
|
-
- spec/cases.json
|
198
|
-
- spec/cases.msg
|
199
|
-
- spec/cases_compact.msg
|
200
|
-
- spec/cases_spec.rb
|
201
|
-
- spec/cruby/buffer_io_spec.rb
|
202
|
-
- spec/cruby/buffer_packer.rb
|
203
|
-
- spec/cruby/buffer_spec.rb
|
204
|
-
- spec/cruby/buffer_unpacker.rb
|
205
|
-
- spec/cruby/unpacker_spec.rb
|
206
|
-
- spec/ext_value_spec.rb
|
207
|
-
- spec/exttypes.rb
|
208
|
-
- spec/factory_spec.rb
|
209
|
-
- spec/format_spec.rb
|
210
|
-
- spec/jruby/benchmarks/shootout_bm.rb
|
211
|
-
- spec/jruby/benchmarks/symbolize_keys_bm.rb
|
212
|
-
- spec/jruby/unpacker_spec.rb
|
213
|
-
- spec/msgpack_spec.rb
|
214
|
-
- spec/pack_spec.rb
|
215
|
-
- spec/packer_spec.rb
|
216
|
-
- spec/random_compat.rb
|
217
|
-
- spec/spec_helper.rb
|
218
|
-
- spec/timestamp_spec.rb
|
219
|
-
- spec/unpack_spec.rb
|
220
|
-
- spec/unpacker_spec.rb
|
221
192
|
homepage: http://msgpack.org/
|
222
193
|
licenses:
|
223
194
|
- Apache 2.0
|
@@ -230,14 +201,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
201
|
requirements:
|
231
202
|
- - ">="
|
232
203
|
- !ruby/object:Gem::Version
|
233
|
-
version: '2.
|
204
|
+
version: '2.5'
|
234
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
206
|
requirements:
|
236
207
|
- - ">="
|
237
208
|
- !ruby/object:Gem::Version
|
238
209
|
version: '0'
|
239
210
|
requirements: []
|
240
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.3.7
|
241
212
|
signing_key:
|
242
213
|
specification_version: 4
|
243
214
|
summary: MessagePack, a binary-based efficient data interchange format.
|
data/.github/workflows/ci.yaml
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
name: ci
|
2
|
-
|
3
|
-
on:
|
4
|
-
pull_request:
|
5
|
-
branches: '*'
|
6
|
-
push:
|
7
|
-
branches:
|
8
|
-
- master
|
9
|
-
- main
|
10
|
-
- 'release-*'
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
mri:
|
14
|
-
strategy:
|
15
|
-
fail-fast: false
|
16
|
-
matrix:
|
17
|
-
os: [ubuntu, macos, windows]
|
18
|
-
ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
|
19
|
-
runs-on: ${{ matrix.os }}-latest
|
20
|
-
steps:
|
21
|
-
- uses: actions/checkout@v2
|
22
|
-
- uses: ruby/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
bundler-cache: true # 'bundle install' and cache
|
26
|
-
- run: bundle exec rake
|
27
|
-
|
28
|
-
other:
|
29
|
-
strategy:
|
30
|
-
fail-fast: false
|
31
|
-
matrix:
|
32
|
-
os: [ubuntu]
|
33
|
-
ruby: ['jruby-9.2.19.0', 'jruby-9.3.3.0', 'truffleruby']
|
34
|
-
runs-on: ${{ matrix.os }}-latest
|
35
|
-
steps:
|
36
|
-
- uses: actions/checkout@v2
|
37
|
-
- uses: ruby/setup-ruby@v1
|
38
|
-
with:
|
39
|
-
ruby-version: ${{ matrix.ruby }}
|
40
|
-
bundler-cache: true # 'bundle install' and cache
|
41
|
-
- run: bundle exec rake spec
|
42
|
-
|
43
|
-
head-versions:
|
44
|
-
continue-on-error: true
|
45
|
-
strategy:
|
46
|
-
fail-fast: false
|
47
|
-
matrix:
|
48
|
-
os: [ubuntu]
|
49
|
-
ruby: ['ruby-head', 'jruby-head']
|
50
|
-
runs-on: ${{ matrix.os }}-latest
|
51
|
-
steps:
|
52
|
-
- uses: actions/checkout@v2
|
53
|
-
- uses: ruby/setup-ruby@v1
|
54
|
-
with:
|
55
|
-
ruby-version: ${{ matrix.ruby }}
|
56
|
-
bundler-cache: true # 'bundle install' and cache
|
57
|
-
- run: bundle exec rake spec || echo "failed, but ignore it"
|
data/.gitignore
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
*.o
|
2
|
-
*.so
|
3
|
-
*.bundle
|
4
|
-
*.gem
|
5
|
-
*.class
|
6
|
-
*.jar
|
7
|
-
doc
|
8
|
-
.yardoc
|
9
|
-
.bundle
|
10
|
-
Gemfile*
|
11
|
-
pkg
|
12
|
-
test/debug.log
|
13
|
-
*~
|
14
|
-
*.swp
|
15
|
-
/rdoc
|
16
|
-
tmp
|
17
|
-
.classpath
|
18
|
-
.project
|
19
|
-
.settings
|
20
|
-
/nbproject/private/
|
21
|
-
coverage/
|
22
|
-
.idea/
|
23
|
-
.ruby-version
|
data/.rubocop.yml
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2015-03-09 17:42:55 +0100 using RuboCop version 0.29.1.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
AllCops:
|
9
|
-
TargetRubyVersion: 2.4
|
10
|
-
|
11
|
-
# Offense count: 3
|
12
|
-
Lint/AmbiguousOperator:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
# Offense count: 1
|
16
|
-
# Configuration parameters: AllowSafeAssignment.
|
17
|
-
Lint/AssignmentInCondition:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
# Offense count: 1
|
21
|
-
Security/Eval:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
# Offense count: 3
|
25
|
-
# Cop supports --auto-correct.
|
26
|
-
Lint/UnusedBlockArgument:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
# Offense count: 35
|
30
|
-
# Cop supports --auto-correct.
|
31
|
-
Lint/UnusedMethodArgument:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
# Offense count: 128
|
35
|
-
Lint/Void:
|
36
|
-
Enabled: false
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'bundler'
|
3
|
-
Bundler::GemHelper.install_tasks
|
4
|
-
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
require 'rspec/core'
|
8
|
-
require 'rspec/core/rake_task'
|
9
|
-
require 'yard'
|
10
|
-
|
11
|
-
task :spec => :compile
|
12
|
-
|
13
|
-
desc 'Run RSpec code examples and measure coverage'
|
14
|
-
task :coverage do |t|
|
15
|
-
ENV['SIMPLE_COV'] = '1'
|
16
|
-
Rake::Task["spec"].invoke
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Generate YARD document'
|
20
|
-
YARD::Rake::YardocTask.new(:doc) do |t|
|
21
|
-
t.files = ['lib/msgpack/version.rb','doclib/**/*.rb']
|
22
|
-
t.options = []
|
23
|
-
t.options << '--debug' << '--verbose' if $trace
|
24
|
-
end
|
25
|
-
|
26
|
-
spec = eval File.read("msgpack.gemspec")
|
27
|
-
|
28
|
-
if RUBY_PLATFORM =~ /java/
|
29
|
-
require 'rake/javaextensiontask'
|
30
|
-
|
31
|
-
Rake::JavaExtensionTask.new('msgpack', spec) do |ext|
|
32
|
-
ext.ext_dir = 'ext/java'
|
33
|
-
jruby_home = RbConfig::CONFIG['prefix']
|
34
|
-
jars = ["#{jruby_home}/lib/jruby.jar"]
|
35
|
-
ext.classpath = jars.map { |x| File.expand_path(x) }.join(':')
|
36
|
-
ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
|
37
|
-
ext.release = '8'
|
38
|
-
end
|
39
|
-
else
|
40
|
-
require 'rake/extensiontask'
|
41
|
-
|
42
|
-
Rake::ExtensionTask.new('msgpack', spec) do |ext|
|
43
|
-
ext.ext_dir = 'ext/msgpack'
|
44
|
-
ext.cross_compile = true
|
45
|
-
ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
|
46
|
-
# cross_platform names are of MRI's platform name
|
47
|
-
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
test_pattern = case
|
52
|
-
when RUBY_PLATFORM =~ /java/ then 'spec/{,jruby/}*_spec.rb'
|
53
|
-
when RUBY_ENGINE =~ /rbx/ then 'spec/*_spec.rb'
|
54
|
-
else 'spec/{,cruby/}*_spec.rb' # MRI
|
55
|
-
end
|
56
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
57
|
-
t.rspec_opts = ["-c", "-f progress"]
|
58
|
-
t.rspec_opts << "-Ilib"
|
59
|
-
t.pattern = test_pattern
|
60
|
-
t.verbose = true
|
61
|
-
end
|
62
|
-
|
63
|
-
namespace :build do
|
64
|
-
desc 'Build gem for JRuby after cleaning'
|
65
|
-
task :java => [:clean, :spec, :build]
|
66
|
-
end
|
67
|
-
|
68
|
-
CLEAN.include('lib/msgpack/msgpack.*')
|
69
|
-
|
70
|
-
task :default => [:spec, :build, :doc]
|
data/appveyor.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
install:
|
3
|
-
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
4
|
-
- ruby --version
|
5
|
-
- gem --version
|
6
|
-
- bundle install
|
7
|
-
build: off
|
8
|
-
test_script:
|
9
|
-
- bundle exec rake -rdevkit
|
10
|
-
|
11
|
-
environment:
|
12
|
-
matrix:
|
13
|
-
- ruby_version: "200"
|
14
|
-
- ruby_version: "200-x64"
|
15
|
-
- ruby_version: "21"
|
16
|
-
- ruby_version: "21-x64"
|
17
|
-
- ruby_version: "22"
|
18
|
-
- ruby_version: "22-x64"
|
data/bench/bench.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# % bundle install
|
2
|
-
# % bundle exec ruby bench/bench.rb
|
3
|
-
|
4
|
-
require 'msgpack'
|
5
|
-
|
6
|
-
require 'benchmark/ips'
|
7
|
-
|
8
|
-
object_plain = {
|
9
|
-
'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"'
|
10
|
-
}
|
11
|
-
|
12
|
-
data_plain = MessagePack.pack(object_plain)
|
13
|
-
|
14
|
-
object_structured = {
|
15
|
-
'remote_host' => '127.0.0.1',
|
16
|
-
'remote_user' => '-',
|
17
|
-
'date' => '10/Oct/2000:13:55:36 -0700',
|
18
|
-
'request' => 'GET /apache_pb.gif HTTP/1.0',
|
19
|
-
'method' => 'GET',
|
20
|
-
'path' => '/apache_pb.gif',
|
21
|
-
'protocol' => 'HTTP/1.0',
|
22
|
-
'status' => 200,
|
23
|
-
'bytes' => 2326,
|
24
|
-
'referer' => 'http://www.example.com/start.html',
|
25
|
-
'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
|
26
|
-
}
|
27
|
-
|
28
|
-
data_structured = MessagePack.pack(object_structured)
|
29
|
-
|
30
|
-
class Extended
|
31
|
-
def to_msgpack_ext
|
32
|
-
MessagePack.pack({})
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.from_msgpack_ext(data)
|
36
|
-
MessagePack.unpack(data)
|
37
|
-
Extended.new
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
object_extended = {
|
42
|
-
'extended' => Extended.new
|
43
|
-
}
|
44
|
-
|
45
|
-
extended_packer = MessagePack::Packer.new
|
46
|
-
extended_packer.register_type(0x00, Extended, :to_msgpack_ext)
|
47
|
-
data_extended = extended_packer.pack(object_extended).to_s
|
48
|
-
|
49
|
-
Benchmark.ips do |x|
|
50
|
-
x.report('pack-plain') do
|
51
|
-
MessagePack.pack(object_plain)
|
52
|
-
end
|
53
|
-
|
54
|
-
x.report('pack-structured') do
|
55
|
-
MessagePack.pack(object_structured)
|
56
|
-
end
|
57
|
-
|
58
|
-
x.report('pack-extended') do
|
59
|
-
packer = MessagePack::Packer.new
|
60
|
-
packer.register_type(0x00, Extended, :to_msgpack_ext)
|
61
|
-
packer.pack(object_extended).to_s
|
62
|
-
end
|
63
|
-
|
64
|
-
x.report('unpack-plain') do
|
65
|
-
MessagePack.unpack(data_plain)
|
66
|
-
end
|
67
|
-
|
68
|
-
x.report('unpack-structured') do
|
69
|
-
MessagePack.unpack(data_structured)
|
70
|
-
end
|
71
|
-
|
72
|
-
x.report('unpack-extended') do
|
73
|
-
unpacker = MessagePack::Unpacker.new
|
74
|
-
unpacker.register_type(0x00, Extended, :from_msgpack_ext)
|
75
|
-
unpacker.feed data_extended
|
76
|
-
unpacker.read
|
77
|
-
end
|
78
|
-
end
|
data/bin/console
DELETED
data/doclib/msgpack/buffer.rb
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
module MessagePack
|
2
|
-
|
3
|
-
class Buffer
|
4
|
-
#
|
5
|
-
# Creates a MessagePack::Buffer instance.
|
6
|
-
#
|
7
|
-
# @overload initialize(options={})
|
8
|
-
# @param options [Hash]
|
9
|
-
#
|
10
|
-
# @overload initialize(io, options={})
|
11
|
-
# @param io [IO]
|
12
|
-
# @param options [Hash]
|
13
|
-
# This buffer writes written data into the IO when it is filled.
|
14
|
-
# This buffer reads data from the IO when it is empty.
|
15
|
-
#
|
16
|
-
# _io_ must respond to readpartial(length, [,string]) or read(string) method and
|
17
|
-
# write(string) or append(string) method.
|
18
|
-
#
|
19
|
-
# Supported options:
|
20
|
-
#
|
21
|
-
# * *:io_buffer_size* buffer size to read data from the internal IO. (default: 32768)
|
22
|
-
# * *:read_reference_threshold* the threshold size to enable zero-copy deserialize optimization. Read strings longer than this threshold will refer the original string instead of copying it. (default: 256) (supported in MRI only)
|
23
|
-
# * *:write_reference_threshold* the threshold size to enable zero-copy serialize optimization. The buffer refers written strings longer than this threshold instead of copying it. (default: 524288) (supported in MRI only)
|
24
|
-
#
|
25
|
-
def initialize(*args)
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Makes the buffer empty
|
30
|
-
#
|
31
|
-
# @return nil
|
32
|
-
#
|
33
|
-
def clear
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# Returns byte size of the buffer.
|
38
|
-
#
|
39
|
-
# @return nil
|
40
|
-
#
|
41
|
-
def size
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# Returns _true_ if the buffer is empty.
|
46
|
-
# This method is slightly faster than _size_.
|
47
|
-
#
|
48
|
-
# @return [Boolean]
|
49
|
-
#
|
50
|
-
def empty?
|
51
|
-
end
|
52
|
-
|
53
|
-
#
|
54
|
-
# Appends the given data to the buffer.
|
55
|
-
#
|
56
|
-
# @param data [String]
|
57
|
-
# @return [Integer] byte size written
|
58
|
-
#
|
59
|
-
def write(data)
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Appends the given data to the buffer.
|
64
|
-
#
|
65
|
-
# @param data [String]
|
66
|
-
# @return [Buffer] self
|
67
|
-
#
|
68
|
-
def <<(data)
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Consumes _n_ bytes from the head of the buffer and returns consumed data.
|
73
|
-
# If the size of the buffer is less than _n_, it reads all of data in the buffer.
|
74
|
-
#
|
75
|
-
# If _n_ is 0, it does nothing and returns an empty string.
|
76
|
-
# If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
|
77
|
-
#
|
78
|
-
# @overload read
|
79
|
-
#
|
80
|
-
# @overload read(n)
|
81
|
-
# @param n [Integer] bytes to read
|
82
|
-
#
|
83
|
-
# @overload read(n, buffer)
|
84
|
-
# @param n [Integer] bytes to read
|
85
|
-
# @param buffer [String] buffer to read into
|
86
|
-
#
|
87
|
-
# @return [String]
|
88
|
-
#
|
89
|
-
def read(n)
|
90
|
-
end
|
91
|
-
|
92
|
-
#
|
93
|
-
# Consumes _n_ bytes from the head of the buffer and returns consumed data.
|
94
|
-
# If the size of the buffer is less than _n_, it does nothing and raises EOFError.
|
95
|
-
#
|
96
|
-
# If _n_ is 0, it does nothing and returns an empty string.
|
97
|
-
# If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
|
98
|
-
#
|
99
|
-
# @overload read_all
|
100
|
-
#
|
101
|
-
# @overload read_all(n)
|
102
|
-
# @param n [Integer] bytes to read
|
103
|
-
#
|
104
|
-
# @overload read_all(n, buffer)
|
105
|
-
# @param n [Integer] bytes to read
|
106
|
-
# @param buffer [String] buffer to read into
|
107
|
-
#
|
108
|
-
# @return [String]
|
109
|
-
#
|
110
|
-
def read_all(n, buffer=nil)
|
111
|
-
end
|
112
|
-
|
113
|
-
#
|
114
|
-
# Consumes _n_ bytes from the head of the buffer.
|
115
|
-
# If the size of the buffer is less than _n_, it skips all of data in the buffer and returns integer less than _n_.
|
116
|
-
#
|
117
|
-
# If _n_ is 0, it does nothing and returns _0_.
|
118
|
-
#
|
119
|
-
# @param n [Integer] byte size to skip
|
120
|
-
# @return [Integer] byte size actually skipped
|
121
|
-
#
|
122
|
-
def skip(n)
|
123
|
-
end
|
124
|
-
|
125
|
-
#
|
126
|
-
# Consumes _n_ bytes from the head of the buffer.
|
127
|
-
# If the size of the buffer is less than _n_, it does nothing and raises EOFError.
|
128
|
-
# If _n_ is 0, it does nothing.
|
129
|
-
#
|
130
|
-
# @param n [Integer] byte size to skip
|
131
|
-
# @return [Buffer] self
|
132
|
-
#
|
133
|
-
def skip_all(n)
|
134
|
-
end
|
135
|
-
|
136
|
-
#
|
137
|
-
# Returns all data in the buffer as a string.
|
138
|
-
# Destructive update to the returned string does NOT effect the buffer.
|
139
|
-
#
|
140
|
-
# @return [String]
|
141
|
-
#
|
142
|
-
def to_str
|
143
|
-
end
|
144
|
-
|
145
|
-
#
|
146
|
-
# Returns content of the buffer as an array of strings.
|
147
|
-
#
|
148
|
-
# This method is sometimes faster than to_s because the internal
|
149
|
-
# structure of the buffer is a queue of buffer chunks.
|
150
|
-
#
|
151
|
-
# @return [Array] array of strings
|
152
|
-
#
|
153
|
-
def to_a
|
154
|
-
end
|
155
|
-
|
156
|
-
#
|
157
|
-
# Internal io
|
158
|
-
#
|
159
|
-
# @return IO
|
160
|
-
#
|
161
|
-
attr_reader :io
|
162
|
-
|
163
|
-
#
|
164
|
-
# Flushes data in the internal buffer to the internal IO.
|
165
|
-
# If internal IO is not set, it does nothing.
|
166
|
-
#
|
167
|
-
# @return [Buffer] self
|
168
|
-
#
|
169
|
-
def flush
|
170
|
-
end
|
171
|
-
|
172
|
-
#
|
173
|
-
# Closes internal IO if its set.
|
174
|
-
# If internal IO is not set, it does nothing
|
175
|
-
#
|
176
|
-
# @return nil
|
177
|
-
#
|
178
|
-
def close
|
179
|
-
end
|
180
|
-
|
181
|
-
#
|
182
|
-
# Writes all of data in the internal buffer into the given IO.
|
183
|
-
# This method consumes and removes data from the internal buffer.
|
184
|
-
# _io_ must respond to write(data) method.
|
185
|
-
#
|
186
|
-
# @param io [IO]
|
187
|
-
# @return [Integer] byte size of written data
|
188
|
-
#
|
189
|
-
def write_to(io)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|