lightio 0.4.3 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0461dd68b60dfa05c34fabdcd916ef074de8e634634174fc5253dbc5083d221a
4
- data.tar.gz: 0715bf64fe6b6150d629136b621eec9d6a79c72dc7110e19082dd4e59b14a0a9
3
+ metadata.gz: a29e0871184591f5232583400f01adb10fb73a0fbb2d7e807f91eb39afb60a2a
4
+ data.tar.gz: b3e733b395d9132bc84f9fba9402bfe721a1219d50f310f37092a41f85760f3e
5
5
  SHA512:
6
- metadata.gz: 8c7796bdbcb7cc253979813fe394fe65dec6eab3ee53384042a267fa5cf2fef316a946b732e0adc42f1c343c53c4602f7149617d7626066984156ea8fc581d0b
7
- data.tar.gz: 71e6b9f3b63d6e236ea6fb5b0629f6634fe9d60d459d63f78fd5b7406027ca5858add3e0f0d502278938db0d6e2b4d8e930171850a9fa7305b695b6fc5de3ce5
6
+ metadata.gz: 7d9343a5fc2cb487f281cc85c1814c396460b7b9c7611683da49d75b17189cc6f8afa6693e887513411ddbe3a5f42dcbdb5ab8c3c2c40de8e19431090abf0350
7
+ data.tar.gz: 1e6d66287d2d10ce67b70d6a0f5c59641a0c9b87059535eb420e1f72b87a43edbfc21da02278bece1ee3b2b4fb6b9dd61e040771420f745fba3ee556cbdba3f4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lightio (0.4.3)
4
+ lightio (0.4.4)
5
5
  nio4r (~> 2.2)
6
6
 
7
7
  GEM
@@ -14,13 +14,6 @@ module LightIO::Library
14
14
 
15
15
  # abstract for io-like operations
16
16
  module IOMethods
17
- class << self
18
- def included(base)
19
- base.send(:wrap_blocking_methods, :read, :write)
20
- base.send(:alias_method, :<<, :write)
21
- end
22
- end
23
-
24
17
  def lightio_initialize
25
18
  @readbuf = StringIO.new
26
19
  @readbuf.set_encoding(@obj.external_encoding) if @obj.respond_to?(:external_encoding)
@@ -50,6 +43,26 @@ module LightIO::Library
50
43
  wait(timeout, :write) && self
51
44
  end
52
45
 
46
+ def write(string)
47
+ s = StringIO.new(string.to_s)
48
+ remain_size = s.size
49
+ loop do
50
+ result = write_nonblock(s.read, exception: false)
51
+ case result
52
+ when :wait_writable
53
+ io_watcher.wait_writable
54
+ else
55
+ remain_size -= result
56
+ unless remain_size.zero?
57
+ s.seek(result)
58
+ end
59
+ return result
60
+ end
61
+ end
62
+ end
63
+
64
+ alias << write
65
+
53
66
  def read(length = nil, outbuf = nil)
54
67
  while !fill_read_buf && (length.nil? || length > @readbuf.length - @readbuf.pos)
55
68
  wait_readable
@@ -1,3 +1,3 @@
1
1
  module LightIO
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiang Jinyang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r