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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa15bffee537c8232f3e6b4a798e3c9a0097e6b05a359b7b032e86691b8341cd
4
- data.tar.gz: e63efb61474d604ada735c3c97e7424561dc6f080c72f9c0a924bc4a87292a5b
3
+ metadata.gz: 19b35ca5f971a4794f10013637f6f01b959e137d8c08e6b6b0696af0c3bd5fbf
4
+ data.tar.gz: 8378f92aececdad71c1ea9c8abdc535a4d3ea5942478ce863df362deafde69b7
5
5
  SHA512:
6
- metadata.gz: a51bdf3354ea82c7ebea969e839bcde255b762c2fe34c7f1585089231b0fe927a3a41f9df374435459573eae8dfce6f37207d2d92fe1f47132e5f20b3d65cafd
7
- data.tar.gz: 4856741590def68e7849b96202e95f5f8ecaacca42c8d08de7671b8307102ad03181ade4fa311ed49fcad3bad3fa8fe2eba45705b07ecff9986f203453587eb3
6
+ metadata.gz: 9ed4c07b72a50e91b1425a7150a3f9a22d88221827e5701e4561b81d1280c8896676a368ed60b04861db3a86ae1583cdb3a9998e6db0b81f3c9f1cbd332dc383
7
+ data.tar.gz: b2ffd991b0561986e6e9a3a5bf3d0970f20a90487e43f8f7827ded47713086335446c12ca9ca8c566a1e1197d28fe24b7dbad49ceaaf56ae5d97d17239080d7b
@@ -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(Encoding::BINARY)
29
+ force_encoding(BINARY)
28
30
  end
29
31
 
30
32
  def << string
31
- super(string.b)
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 <<
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module IO
23
- VERSION = "1.15.1"
23
+ VERSION = "1.15.2"
24
24
  end
25
25
  end
@@ -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.1
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-06 00:00:00.000000000 Z
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