async-io 1.15.1 → 1.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/io/buffer.rb +10 -2
- data/lib/async/io/version.rb +1 -1
- data/spec/async/io/buffer_spec.rb +46 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19b35ca5f971a4794f10013637f6f01b959e137d8c08e6b6b0696af0c3bd5fbf
|
4
|
+
data.tar.gz: 8378f92aececdad71c1ea9c8abdc535a4d3ea5942478ce863df362deafde69b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ed4c07b72a50e91b1425a7150a3f9a22d88221827e5701e4561b81d1280c8896676a368ed60b04861db3a86ae1583cdb3a9998e6db0b81f3c9f1cbd332dc383
|
7
|
+
data.tar.gz: b2ffd991b0561986e6e9a3a5bf3d0970f20a90487e43f8f7827ded47713086335446c12ca9ca8c566a1e1197d28fe24b7dbad49ceaaf56ae5d97d17239080d7b
|
data/lib/async/io/buffer.rb
CHANGED
@@ -21,14 +21,22 @@
|
|
21
21
|
module Async
|
22
22
|
module IO
|
23
23
|
class Buffer < String
|
24
|
+
BINARY = Encoding::BINARY
|
25
|
+
|
24
26
|
def initialize
|
25
27
|
super
|
26
28
|
|
27
|
-
force_encoding(
|
29
|
+
force_encoding(BINARY)
|
28
30
|
end
|
29
31
|
|
30
32
|
def << string
|
31
|
-
|
33
|
+
if string.encoding == BINARY
|
34
|
+
super(string)
|
35
|
+
else
|
36
|
+
super(string.b)
|
37
|
+
end
|
38
|
+
|
39
|
+
return self
|
32
40
|
end
|
33
41
|
|
34
42
|
alias concat <<
|
data/lib/async/io/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'async/io/buffer'
|
22
|
+
|
23
|
+
RSpec.describe Async::IO::Buffer do
|
24
|
+
include_context Async::RSpec::Memory
|
25
|
+
|
26
|
+
let!(:string) {"Hello World!".b}
|
27
|
+
subject! {described_class.new}
|
28
|
+
|
29
|
+
it "should be binary encoding" do
|
30
|
+
expect(subject.encoding).to be Encoding::BINARY
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should not allocate strings when concatenating" do
|
34
|
+
expect do
|
35
|
+
subject << string
|
36
|
+
end.to limit_allocations.of(String, size: 0, count: 0)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "can append unicode strings to binary buffer" do
|
40
|
+
2.times do
|
41
|
+
subject << "Føøbar"
|
42
|
+
end
|
43
|
+
|
44
|
+
expect(subject).to eq "FøøbarFøøbar".b
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.15.
|
4
|
+
version: 1.15.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/async/io/unix_socket.rb
|
127
127
|
- lib/async/io/version.rb
|
128
128
|
- spec/addrinfo.rb
|
129
|
+
- spec/async/io/buffer_spec.rb
|
129
130
|
- spec/async/io/c10k_spec.rb
|
130
131
|
- spec/async/io/echo_spec.rb
|
131
132
|
- spec/async/io/endpoint_spec.rb
|
@@ -172,6 +173,7 @@ specification_version: 4
|
|
172
173
|
summary: Provides support for asynchonous TCP, UDP, UNIX and SSL sockets.
|
173
174
|
test_files:
|
174
175
|
- spec/addrinfo.rb
|
176
|
+
- spec/async/io/buffer_spec.rb
|
175
177
|
- spec/async/io/c10k_spec.rb
|
176
178
|
- spec/async/io/echo_spec.rb
|
177
179
|
- spec/async/io/endpoint_spec.rb
|