io-stream 0.3.0 → 0.4.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: f6a65103b45022f50d46603a178bb87f7bf8a11ab24da10e855dd7c18233a261
4
- data.tar.gz: d0870c42173b4e87388ea1f3c56e68323c394cac7bf4ea1d90cd879d1c02b8a4
3
+ metadata.gz: f0a5f918cac3b8ad0a5f88281f74f2ba71b1f37e3b0504bab234fc7139ae22c9
4
+ data.tar.gz: ce06b6c063777952df3f6e911807e7377983e15450259d269d05d69ac8e073fa
5
5
  SHA512:
6
- metadata.gz: 97d1162cf543a3b604a1fe1873525d8c6278c1adac118fe165e0d1066a8421b06a4932e96e46276bc7abe8f618fe0bc89f45c5f13dd262d52c2e58e65cd5f878
7
- data.tar.gz: 0c7db373575894a7271133aa1f610246efad907e7e168114ba677c64fbfb7a0695fd80dd286585ebdfe5af6e88f44d1f2a2c3ecf339fda540eb8ac913a2f181a
6
+ metadata.gz: b74b95787f49071ba75c4b17ab6683b14fa24c2a83c8cc8b896cc4f23ba684ab0657b5dd0db7d6701b65e2da276619e6539a120918f079b23dbdef53b9bd6b93
7
+ data.tar.gz: d254f93d0561271c7406f2a00269e53776ef6548ea1814b169fdee5dc661bed4230eefef734ceb463a0561f255e8c9c8c0f76bd20419213ac49cc18b11ccf7e0
checksums.yaml.gz.sig CHANGED
Binary file
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require_relative 'generic'
6
+ require_relative "generic"
7
7
 
8
8
  module IO::Stream
9
9
  class Buffered < Generic
@@ -50,6 +50,10 @@ module IO::Stream
50
50
 
51
51
  attr :io
52
52
 
53
+ def to_io
54
+ @io.to_io
55
+ end
56
+
53
57
  def closed?
54
58
  @io.closed?
55
59
  end
@@ -70,8 +74,15 @@ module IO::Stream
70
74
 
71
75
  protected
72
76
 
73
- def sysclose
74
- @io.close
77
+ if RUBY_VERSION >= "3.3.0"
78
+ def sysclose
79
+ # https://bugs.ruby-lang.org/issues/20723
80
+ Thread.new{@io.close}.join
81
+ end
82
+ else
83
+ def sysclose
84
+ @io.close
85
+ end
75
86
  end
76
87
 
77
88
  def syswrite(buffer)
@@ -111,6 +122,8 @@ module IO::Stream
111
122
  return result
112
123
  end
113
124
  end
125
+ rescue Errno::EBADF
126
+ raise ::IOError, "stream closed"
114
127
  end
115
128
  end
116
129
  end
@@ -3,20 +3,20 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
- require_relative 'string_buffer'
6
+ require_relative "string_buffer"
7
7
 
8
- require_relative 'shim/buffered'
9
- require_relative 'shim/readable'
10
- require_relative 'shim/timeout'
8
+ require_relative "shim/buffered"
9
+ require_relative "shim/readable"
10
+ require_relative "shim/timeout"
11
11
 
12
- require_relative 'openssl'
12
+ require_relative "openssl"
13
13
 
14
14
  module IO::Stream
15
15
  # The default block size for IO buffers. Defaults to 64KB (typical pipe buffer size).
16
- BLOCK_SIZE = ENV.fetch('IO_STREAM_BLOCK_SIZE', 1024*64).to_i
16
+ BLOCK_SIZE = ENV.fetch("IO_STREAM_BLOCK_SIZE", 1024*64).to_i
17
17
 
18
18
  # The maximum read size when appending to IO buffers. Defaults to 8MB.
19
- MAXIMUM_READ_SIZE = ENV.fetch('IO_STREAM_MAXIMUM_READ_SIZE', BLOCK_SIZE * 128).to_i
19
+ MAXIMUM_READ_SIZE = ENV.fetch("IO_STREAM_MAXIMUM_READ_SIZE", BLOCK_SIZE * 128).to_i
20
20
 
21
21
  class Generic
22
22
  def initialize(block_size: BLOCK_SIZE, maximum_read_size: MAXIMUM_READ_SIZE)
@@ -195,7 +195,7 @@ module IO::Stream
195
195
  rescue
196
196
  # We really can't do anything here unless we want #close to raise exceptions.
197
197
  ensure
198
- sysclose
198
+ self.sysclose
199
199
  end
200
200
  end
201
201
 
@@ -3,7 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2024, by Samuel Williams.
5
5
 
6
- require 'openssl'
6
+ require "openssl"
7
7
 
8
8
  module OpenSSL
9
9
  module SSL
@@ -15,7 +15,7 @@ unless IO.method_defined?(:buffered?, false)
15
15
  end
16
16
  end
17
17
 
18
- require 'socket'
18
+ require "socket"
19
19
 
20
20
  unless BasicSocket.method_defined?(:buffered?, false)
21
21
  class BasicSocket
@@ -50,7 +50,7 @@ unless BasicSocket.method_defined?(:buffered?, false)
50
50
  end
51
51
  end
52
52
 
53
- require 'stringio'
53
+ require "stringio"
54
54
 
55
55
  unless StringIO.method_defined?(:buffered?, false)
56
56
  class StringIO
@@ -12,7 +12,7 @@ class IO
12
12
  end
13
13
  end
14
14
 
15
- require 'socket'
15
+ require "socket"
16
16
 
17
17
  class BasicSocket
18
18
  unless method_defined?(:readable?, false)
@@ -32,7 +32,7 @@ class BasicSocket
32
32
  end
33
33
  end
34
34
 
35
- require 'stringio'
35
+ require "stringio"
36
36
 
37
37
  class StringIO
38
38
  unless method_defined?(:readable?, false)
@@ -42,7 +42,7 @@ class StringIO
42
42
  end
43
43
  end
44
44
 
45
- require 'openssl'
45
+ require "openssl"
46
46
 
47
47
  class OpenSSL::SSL::SSLSocket
48
48
  unless method_defined?(:readable?, false)
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2024, by Samuel Williams.
5
+
3
6
  class IO
4
7
  unless const_defined?(:TimeoutError)
5
8
  # Compatibility shim.
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  module IO::Stream
7
- VERSION = "0.3.0"
7
+ VERSION = "0.4.1"
8
8
  end
data/lib/io/stream.rb CHANGED
@@ -3,10 +3,18 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
- require_relative 'stream/version'
7
- require_relative 'stream/buffered'
6
+ require_relative "stream/version"
7
+ require_relative "stream/buffered"
8
8
 
9
9
  class IO
10
10
  module Stream
11
11
  end
12
+
13
+ def self.Stream(io)
14
+ if io.is_a?(Stream::Buffered)
15
+ io
16
+ else
17
+ Stream::Buffered.wrap(io)
18
+ end
19
+ end
12
20
  end
data/readme.md CHANGED
@@ -20,11 +20,11 @@ We welcome contributions to this project.
20
20
 
21
21
  ### Developer Certificate of Origin
22
22
 
23
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
23
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
24
24
 
25
- ### Contributor Covenant
25
+ ### Community Guidelines
26
26
 
27
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
27
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
28
28
 
29
29
  ## See Also
30
30
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2024-04-23 00:00:00.000000000 Z
40
+ date: 2024-09-11 00:00:00.000000000 Z
41
41
  dependencies: []
42
42
  description:
43
43
  email:
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
- rubygems_version: 3.5.3
81
+ rubygems_version: 3.5.11
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Provides a generic stream wrapper for IO instances.
metadata.gz.sig CHANGED
Binary file