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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/lightio/library/io.rb +20 -7
- data/lib/lightio/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a29e0871184591f5232583400f01adb10fb73a0fbb2d7e807f91eb39afb60a2a
|
4
|
+
data.tar.gz: b3e733b395d9132bc84f9fba9402bfe721a1219d50f310f37092a41f85760f3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d9343a5fc2cb487f281cc85c1814c396460b7b9c7611683da49d75b17189cc6f8afa6693e887513411ddbe3a5f42dcbdb5ab8c3c2c40de8e19431090abf0350
|
7
|
+
data.tar.gz: 1e6d66287d2d10ce67b70d6a0f5c59641a0c9b87059535eb420e1f72b87a43edbfc21da02278bece1ee3b2b4fb6b9dd61e040771420f745fba3ee556cbdba3f4
|
data/Gemfile.lock
CHANGED
data/lib/lightio/library/io.rb
CHANGED
@@ -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
|
data/lib/lightio/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nio4r
|