gio2 3.4.9 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gio2.gemspec +2 -1
- data/lib/gio2/input-stream.rb +1 -1
- data/lib/gio2/loader.rb +80 -10
- data/lib/gio2/output-stream.rb +32 -0
- data/lib/gio2/pollable-input-stream.rb +2 -1
- data/lib/gio2/ruby-input-stream.rb +70 -0
- data/lib/gio2/ruby-output-stream.rb +50 -0
- data/lib/gio2/ruby-seekable.rb +50 -0
- data/test/gio2-test-utils.rb +1 -0
- data/test/test-buffered-input-stream.rb +12 -4
- data/test/test-resolver.rb +38 -0
- data/test/test-ruby-input-stream.rb +74 -0
- data/test/test-ruby-output-stream.rb +70 -0
- metadata +26 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 641772657997d3ed85fa83c47ddd0ca91c5243e17c7378f250d41517545a1691
|
4
|
+
data.tar.gz: 275adb45985d155ef45b70f5855c9d073683ccbeb47f4cf23ff15ce412db7607
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdea4aa0ad4e855a9ea0b1cc4692dfaef770b2d15e9d973801675ff09355c1f32822e4de9dfe2e1f6f4574be13d52b3c2cec83710f70e795531bf1e06c0f9d2f
|
7
|
+
data.tar.gz: 139379b3bf244377b246239d8f78a8f075723b4bede4fc5c6935c767350464dab035192578a612159d40fb6ba737ff3b751cc2b340f012e2107fe8b57a2b5bad
|
data/gio2.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2018 Ruby-GNOME Project Team
|
3
|
+
# Copyright (C) 2018-2021 Ruby-GNOME Project Team
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or
|
6
6
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.files += Dir.glob("ext/#{s.name}/*.{c,h,def,rb}")
|
44
44
|
s.files += Dir.glob("test/**/*")
|
45
45
|
|
46
|
+
s.add_runtime_dependency("fiddle")
|
46
47
|
s.add_runtime_dependency("gobject-introspection", "= #{s.version}")
|
47
48
|
|
48
49
|
s.metadata["msys2_mingw_dependencies"] = "glib-networking"
|
data/lib/gio2/input-stream.rb
CHANGED
data/lib/gio2/loader.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013-
|
1
|
+
# Copyright (C) 2013-2021 Ruby-GNOME Project Team
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -39,6 +39,18 @@ module Gio
|
|
39
39
|
end
|
40
40
|
require_extension
|
41
41
|
require_libraries
|
42
|
+
|
43
|
+
if defined?(Ractor)
|
44
|
+
[
|
45
|
+
@content_type_class,
|
46
|
+
@mime_type_class,
|
47
|
+
@dbus_module,
|
48
|
+
@resources_module,
|
49
|
+
].each do |klass|
|
50
|
+
Ractor.make_shareable(klass::INVOKERS)
|
51
|
+
Ractor.make_shareable(klass.singleton_class::INVOKERS)
|
52
|
+
end
|
53
|
+
end
|
42
54
|
end
|
43
55
|
|
44
56
|
def require_extension
|
@@ -55,9 +67,12 @@ module Gio
|
|
55
67
|
require "gio2/inet-address"
|
56
68
|
require "gio2/input-stream"
|
57
69
|
require "gio2/menu-item"
|
70
|
+
require "gio2/output-stream"
|
58
71
|
require "gio2/pollable-input-stream"
|
59
72
|
require "gio2/pollable-output-stream"
|
60
73
|
require "gio2/resources"
|
74
|
+
require "gio2/ruby-input-stream"
|
75
|
+
require "gio2/ruby-output-stream"
|
61
76
|
require "gio2/settings"
|
62
77
|
require "gio2/settings-schema-source"
|
63
78
|
require "gio2/simple-action"
|
@@ -67,6 +82,9 @@ module Gio
|
|
67
82
|
|
68
83
|
def define_content_type_class
|
69
84
|
@content_type_class = Class.new do
|
85
|
+
const_set(:INVOKERS, {})
|
86
|
+
singleton_class.const_set(:INVOKERS, {})
|
87
|
+
|
70
88
|
def initialize(type)
|
71
89
|
@type = type
|
72
90
|
end
|
@@ -80,6 +98,9 @@ module Gio
|
|
80
98
|
|
81
99
|
def define_mime_type_class
|
82
100
|
@mime_type_class = Class.new do
|
101
|
+
const_set(:INVOKERS, {})
|
102
|
+
singleton_class.const_set(:INVOKERS, {})
|
103
|
+
|
83
104
|
def initialize(type)
|
84
105
|
@type = type
|
85
106
|
end
|
@@ -92,12 +113,18 @@ module Gio
|
|
92
113
|
end
|
93
114
|
|
94
115
|
def define_dbus_module
|
95
|
-
@dbus_module = Module.new
|
116
|
+
@dbus_module = Module.new do
|
117
|
+
const_set(:INVOKERS, {})
|
118
|
+
singleton_class.const_set(:INVOKERS, {})
|
119
|
+
end
|
96
120
|
@base_module.const_set("DBus", @dbus_module)
|
97
121
|
end
|
98
122
|
|
99
123
|
def define_resources_module
|
100
|
-
@resources_module = Module.new
|
124
|
+
@resources_module = Module.new do
|
125
|
+
const_set(:INVOKERS, {})
|
126
|
+
singleton_class.const_set(:INVOKERS, {})
|
127
|
+
end
|
101
128
|
@base_module.const_set("Resources", @resources_module)
|
102
129
|
end
|
103
130
|
|
@@ -196,17 +223,60 @@ module Gio
|
|
196
223
|
Error
|
197
224
|
end
|
198
225
|
|
199
|
-
def
|
226
|
+
def prepare_function_info_lock_gvl(function_info, klass)
|
227
|
+
super
|
200
228
|
case klass.name
|
229
|
+
when "Gio::Seekable"
|
230
|
+
function_info.lock_gvl_default = false
|
231
|
+
if defined?(Ractor)
|
232
|
+
predicate = Ractor.current.instance_eval do
|
233
|
+
lambda do |_, receiver|
|
234
|
+
receiver.is_a?(RubySeekable)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
Ractor.make_shareable(predicate)
|
238
|
+
else
|
239
|
+
predicate = lambda do |_, receiver|
|
240
|
+
receiver.is_a?(RubySeekable)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
function_info.add_lock_gvl_predicate(&predicate)
|
201
244
|
when "Gio::InputStream"
|
202
245
|
case function_info.name
|
203
|
-
when "read", "read_all"
|
204
|
-
|
205
|
-
|
206
|
-
|
246
|
+
when "read", "read_all", "skip", "close"
|
247
|
+
function_info.lock_gvl_default = false
|
248
|
+
if defined?(Ractor)
|
249
|
+
predicate = Ractor.current.instance_eval do
|
250
|
+
lambda do |_, receiver|
|
251
|
+
receiver.is_a?(RubyInputStream)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
Ractor.make_shareable(predicate)
|
255
|
+
else
|
256
|
+
predicate = lambda do |_, receiver|
|
257
|
+
receiver.is_a?(RubyInputStream)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
function_info.add_lock_gvl_predicate(&predicate)
|
261
|
+
end
|
262
|
+
when "Gio::OutputStream"
|
263
|
+
case function_info.name
|
264
|
+
when "write", "write_all", "flush", "close"
|
265
|
+
function_info.lock_gvl_default = false
|
266
|
+
if defined?(Ractor)
|
267
|
+
predicate = Ractor.current.instance_eval do
|
268
|
+
lambda do |_, receiver|
|
269
|
+
receiver.is_a?(RubyOutputStream)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
Ractor.make_shareable(predicate)
|
273
|
+
else
|
274
|
+
predicate = lambda do |_, receiver|
|
275
|
+
receiver.is_a?(RubyOutputStream)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
function_info.add_lock_gvl_predicate(&predicate)
|
207
279
|
end
|
208
|
-
else
|
209
|
-
false
|
210
280
|
end
|
211
281
|
end
|
212
282
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright (C) 2014-2021 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
class OutputStream
|
19
|
+
class << self
|
20
|
+
def open(*arguments)
|
21
|
+
output_stream = new(*arguments)
|
22
|
+
return output_stream unless block_given?
|
23
|
+
|
24
|
+
begin
|
25
|
+
yield(output_stream)
|
26
|
+
ensure
|
27
|
+
output_stream.close unless output_stream.closed?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -51,7 +51,8 @@ module Gio
|
|
51
51
|
private
|
52
52
|
def read_nonblocking_raw_compatible(buffer)
|
53
53
|
if (GLib::VERSION <=> [2, 42, 0]) >= 0
|
54
|
-
read_nonblocking_raw(buffer)
|
54
|
+
n_bytes, = read_nonblocking_raw(buffer)
|
55
|
+
n_bytes
|
55
56
|
else
|
56
57
|
read_nonblocking_raw(buffer, buffer.bytesize)
|
57
58
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Copyright (C) 2021 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require "fiddle"
|
18
|
+
|
19
|
+
require_relative "ruby-seekable"
|
20
|
+
|
21
|
+
module Gio
|
22
|
+
class RubyInputStream < InputStream
|
23
|
+
type_register("RubyInputStream")
|
24
|
+
|
25
|
+
include Seekable
|
26
|
+
include RubySeekable
|
27
|
+
|
28
|
+
def initialize(ruby_input)
|
29
|
+
@ruby_input = ruby_input
|
30
|
+
@buffer = ""
|
31
|
+
super()
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def ruby_io
|
36
|
+
@ruby_input
|
37
|
+
end
|
38
|
+
|
39
|
+
def virtual_do_read_fn(buffer_address, count, cancellable)
|
40
|
+
buffer = Fiddle::Pointer.new(buffer_address)
|
41
|
+
if @ruby_input.read(count, @buffer)
|
42
|
+
buffer[0, @buffer.bytesize] = @buffer
|
43
|
+
@buffer.bytesize
|
44
|
+
else
|
45
|
+
0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def virtual_do_skip(count, cancellable)
|
50
|
+
if @ruby_input.respond_to?(:seek)
|
51
|
+
if @ruby_input.seek(count, IO::SEEK_CUR).zero?
|
52
|
+
count
|
53
|
+
else
|
54
|
+
-1
|
55
|
+
end
|
56
|
+
else
|
57
|
+
if @ruby_input.read(count, @buffer)
|
58
|
+
@buffer.bytesize
|
59
|
+
else
|
60
|
+
-1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def virtual_do_close_fn(cancellable)
|
66
|
+
@ruby_input.close
|
67
|
+
true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright (C) 2021 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
require_relative "ruby-seekable"
|
18
|
+
|
19
|
+
module Gio
|
20
|
+
class RubyOutputStream < OutputStream
|
21
|
+
type_register("RubyOutputStream")
|
22
|
+
|
23
|
+
include Seekable
|
24
|
+
include RubySeekable
|
25
|
+
|
26
|
+
def initialize(ruby_output)
|
27
|
+
@ruby_output = ruby_output
|
28
|
+
super()
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def ruby_io
|
33
|
+
@ruby_output
|
34
|
+
end
|
35
|
+
|
36
|
+
def virtual_do_write_fn(buffer, cancellable)
|
37
|
+
@ruby_output.write(buffer)
|
38
|
+
end
|
39
|
+
|
40
|
+
def virtual_do_flush(cancellable)
|
41
|
+
@ruby_output.flush
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
def virtual_do_close_fn(cancellable)
|
46
|
+
@ruby_output.close
|
47
|
+
true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright (C) 2021 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gio
|
18
|
+
module RubySeekable
|
19
|
+
private
|
20
|
+
# GSeekable methods
|
21
|
+
def virtual_do_tell
|
22
|
+
ruby_io.tell
|
23
|
+
end
|
24
|
+
|
25
|
+
def virtual_do_can_seek
|
26
|
+
ruby_io.respond_to?(:seek)
|
27
|
+
end
|
28
|
+
|
29
|
+
def virtual_do_seek(offset, type, cancellable)
|
30
|
+
case type
|
31
|
+
when GLib::IOChannel::SEEK_CUR
|
32
|
+
ruby_type = IO::SEEK_CUR
|
33
|
+
when GLib::IOChannel::SEEK_SET
|
34
|
+
ruby_type = IO::SEEK_SET
|
35
|
+
when GLib::IOChannel::SEEK_END
|
36
|
+
ruby_type = IO::SEEK_END
|
37
|
+
end
|
38
|
+
ruby_io.seek(offset, ruby_type).zero?
|
39
|
+
end
|
40
|
+
|
41
|
+
def virtual_do_can_truncate
|
42
|
+
ruby_io.respond_to?(:truncate)
|
43
|
+
end
|
44
|
+
|
45
|
+
def virtual_do_truncate_fn(offset, cancellable)
|
46
|
+
ruby_io.truncate(offset)
|
47
|
+
true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/test/gio2-test-utils.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Ruby-
|
1
|
+
# Copyright (C) 2013-2022 Ruby-GNOME Project Team
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,9 +15,17 @@
|
|
15
15
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
16
|
|
17
17
|
class TestBufferedInputStream < Test::Unit::TestCase
|
18
|
-
def
|
19
|
-
|
20
|
-
Gio::BufferedInputStream.
|
18
|
+
def setup
|
19
|
+
Gio::RubyInputStream.open(StringIO.new("Hello!")) do |base_stream|
|
20
|
+
Gio::BufferedInputStream.open(base_stream) do |stream|
|
21
|
+
@stream = stream
|
22
|
+
yield
|
23
|
+
end
|
21
24
|
end
|
22
25
|
end
|
26
|
+
|
27
|
+
def test_fill
|
28
|
+
assert_equal(2, @stream.fill(2))
|
29
|
+
assert_equal("He", @stream.read(2))
|
30
|
+
end
|
23
31
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (C) 2022 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
class TestResolver < Test::Unit::TestCase
|
18
|
+
include GioTestUtils::Fixture
|
19
|
+
include GioTestUtils::Omissions
|
20
|
+
|
21
|
+
def test_lookup_records_async
|
22
|
+
loop = GLib::MainLoop.new
|
23
|
+
timeout_id = GLib::Timeout.add(5000) do
|
24
|
+
loop.quit
|
25
|
+
GLib::Source::REMOVE
|
26
|
+
end
|
27
|
+
resolver = Gio::Resolver.default
|
28
|
+
records = nil
|
29
|
+
resolver.lookup_records_async("clear-code.com", :mx) do |_, result|
|
30
|
+
records = resolver.lookup_records_finish(result)
|
31
|
+
GLib::Source.remove(timeout_id)
|
32
|
+
loop.quit
|
33
|
+
end
|
34
|
+
loop.run
|
35
|
+
assert_equal([[10, "mail.clear-code.com"]],
|
36
|
+
records)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Copyright (C) 2021 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
class TestRubyInputStream < Test::Unit::TestCase
|
18
|
+
def setup
|
19
|
+
@base_stream = StringIO.new("Hello!")
|
20
|
+
Gio::RubyInputStream.open(@base_stream) do |stream|
|
21
|
+
@stream = stream
|
22
|
+
yield
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
sub_test_case("#read") do
|
27
|
+
def test_with_size
|
28
|
+
assert_equal("H", @stream.read(1))
|
29
|
+
assert_equal("ell", @stream.read(3))
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_without_size
|
33
|
+
assert_equal("Hello!", @stream.read)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_skip
|
38
|
+
assert_equal(1, @stream.skip(1))
|
39
|
+
assert_equal("ell", @stream.read(3))
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_tell
|
43
|
+
assert_equal(0, @stream.tell)
|
44
|
+
assert_equal(1, @stream.skip(1))
|
45
|
+
assert_equal(1, @stream.tell)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_can_seek?
|
49
|
+
assert do
|
50
|
+
@stream.can_seek?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_seek
|
55
|
+
assert do
|
56
|
+
@stream.seek(-1, GLib::IOChannel::SEEK_END)
|
57
|
+
end
|
58
|
+
assert_equal(@base_stream.string.bytesize - 1,
|
59
|
+
@stream.tell)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_can_truncate?
|
63
|
+
assert do
|
64
|
+
@stream.can_truncate?
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_truncate
|
69
|
+
assert do
|
70
|
+
@stream.truncate(2)
|
71
|
+
end
|
72
|
+
assert_equal("He", @stream.read)
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Copyright (C) 2021 Ruby-GNOME Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
class TestRubyOutputStream < Test::Unit::TestCase
|
18
|
+
def setup
|
19
|
+
@base_stream = StringIO.new("Hello World")
|
20
|
+
Gio::RubyOutputStream.open(@base_stream) do |stream|
|
21
|
+
@stream = stream
|
22
|
+
yield
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_write
|
27
|
+
assert_equal(2, @stream.write("Hi"))
|
28
|
+
assert_equal("Hillo World", @base_stream.string)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_splice
|
32
|
+
Gio::RubyInputStream.open(StringIO.new("Hi")) do |input_stream|
|
33
|
+
assert_equal(2, @stream.splice(input_stream, :none))
|
34
|
+
end
|
35
|
+
assert_equal("Hillo World", @base_stream.string)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_flush
|
39
|
+
assert do
|
40
|
+
@stream.flush
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_can_seek?
|
45
|
+
assert do
|
46
|
+
@stream.can_seek?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_seek
|
51
|
+
assert do
|
52
|
+
@stream.seek(-1, GLib::IOChannel::SEEK_END)
|
53
|
+
end
|
54
|
+
assert_equal(@base_stream.string.bytesize - 1,
|
55
|
+
@stream.tell)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_can_truncate?
|
59
|
+
assert do
|
60
|
+
@stream.can_truncate?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_truncate
|
65
|
+
assert do
|
66
|
+
@stream.truncate(2)
|
67
|
+
end
|
68
|
+
assert_equal("He", @base_stream.string)
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gio2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Ruby-GNOME Project Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fiddle
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: gobject-introspection
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - '='
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
33
|
+
version: 3.5.0
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - '='
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
40
|
+
version: 3.5.0
|
27
41
|
description: Ruby/GIO2 provide Ruby binding to a VFS API and useful APIs for desktop
|
28
42
|
applications (such as networking and D-Bus support).
|
29
43
|
email: ruby-gnome2-devel-en@lists.sourceforge.net
|
@@ -55,9 +69,13 @@ files:
|
|
55
69
|
- lib/gio2/input-stream.rb
|
56
70
|
- lib/gio2/loader.rb
|
57
71
|
- lib/gio2/menu-item.rb
|
72
|
+
- lib/gio2/output-stream.rb
|
58
73
|
- lib/gio2/pollable-input-stream.rb
|
59
74
|
- lib/gio2/pollable-output-stream.rb
|
60
75
|
- lib/gio2/resources.rb
|
76
|
+
- lib/gio2/ruby-input-stream.rb
|
77
|
+
- lib/gio2/ruby-output-stream.rb
|
78
|
+
- lib/gio2/ruby-seekable.rb
|
61
79
|
- lib/gio2/settings-schema-source.rb
|
62
80
|
- lib/gio2/settings.rb
|
63
81
|
- lib/gio2/simple-action.rb
|
@@ -93,7 +111,10 @@ files:
|
|
93
111
|
- test/test-output-stream.rb
|
94
112
|
- test/test-pollable-input-stream.rb
|
95
113
|
- test/test-pollable-output-stream.rb
|
114
|
+
- test/test-resolver.rb
|
96
115
|
- test/test-resources.rb
|
116
|
+
- test/test-ruby-input-stream.rb
|
117
|
+
- test/test-ruby-output-stream.rb
|
97
118
|
- test/test-settings-schema-source.rb
|
98
119
|
- test/test-settings.rb
|
99
120
|
- test/test-simple-action.rb
|
@@ -118,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
139
|
- !ruby/object:Gem::Version
|
119
140
|
version: '0'
|
120
141
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.4.0.dev
|
122
143
|
signing_key:
|
123
144
|
specification_version: 4
|
124
145
|
summary: Ruby/GIO2 is a Ruby binding of gio-2.x.
|