gio2 3.3.5 → 3.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gio2/file.rb +14 -1
- data/lib/gio2/input-stream.rb +14 -1
- data/test/gio2-test-utils.rb +2 -1
- data/test/test-file.rb +42 -2
- data/test/test-input-stream.rb +40 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 852d554d3e78a6b9c79bb99431e531bbfb123bd1cb5d457b34d6511ccba2c871
|
4
|
+
data.tar.gz: f77f0d28354552d43c42445543e80c4bda4857f0a39e7b16fd46882ec94feafa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70ccbe75a0382d5d9d6d60681731c87a396fcc63cc3870a0d438031b5ecdd4a136fbc6cbb3844d169971af91d9a765155e13d25908b6c0b097895c4eae7266dc
|
7
|
+
data.tar.gz: 98f2188796590570649db9c613bbb29b6477fb87fa27324460ffe9fa007dd382d7994df659ba2bb53b20f5d1bd114433e856e49dc61c37cf089dde934f918520
|
data/lib/gio2/file.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2016-
|
1
|
+
# Copyright (C) 2016-2019 Ruby-GNOME2 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
|
@@ -30,6 +30,7 @@ module Gio
|
|
30
30
|
file = new_for_commandline_arg(arg)
|
31
31
|
end
|
32
32
|
elsif path
|
33
|
+
path = path.to_path if path.respond_to?(:to_path)
|
33
34
|
file = new_for_path(path)
|
34
35
|
elsif uri
|
35
36
|
file = new_for_uri(uri)
|
@@ -45,5 +46,17 @@ module Gio
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
49
|
+
|
50
|
+
alias_method :read_raw, :read
|
51
|
+
def read(cancellable=nil)
|
52
|
+
input_stream = read_raw(cancellable)
|
53
|
+
return input_stream unless block_given?
|
54
|
+
|
55
|
+
begin
|
56
|
+
yield(input_stream)
|
57
|
+
ensure
|
58
|
+
input_stream.close unless input_stream.closed?
|
59
|
+
end
|
60
|
+
end
|
48
61
|
end
|
49
62
|
end
|
data/lib/gio2/input-stream.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
1
|
+
# Copyright (C) 2014-2019 Ruby-GNOME2 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
|
@@ -16,6 +16,19 @@
|
|
16
16
|
|
17
17
|
module Gio
|
18
18
|
class InputStream
|
19
|
+
class << self
|
20
|
+
def open(*arguments)
|
21
|
+
input_stream = new(*arguments)
|
22
|
+
return input_stream unless block_given?
|
23
|
+
|
24
|
+
begin
|
25
|
+
yield(input_stream)
|
26
|
+
ensure
|
27
|
+
input_stream.close unless input_stream.closed?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
19
32
|
alias_method :read_raw, :read
|
20
33
|
def read(size=nil)
|
21
34
|
if size.nil?
|
data/test/gio2-test-utils.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
1
|
+
# Copyright (C) 2013-2019 Ruby-GNOME2 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
|
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
require "test-unit"
|
18
18
|
|
19
|
+
require "pathname"
|
19
20
|
require "tempfile"
|
20
21
|
|
21
22
|
require "gio2-test-utils/fixture"
|
data/test/test-file.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2019 Ruby-GNOME2 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
|
@@ -18,7 +18,33 @@ class TestFile < Test::Unit::TestCase
|
|
18
18
|
include GioTestUtils::Fixture
|
19
19
|
include GioTestUtils::Omissions
|
20
20
|
|
21
|
-
|
21
|
+
sub_test_case(".open") do
|
22
|
+
sub_test_case(":path") do
|
23
|
+
def test_string
|
24
|
+
path = __FILE__
|
25
|
+
Gio::File.open(path: path) do |file|
|
26
|
+
file.read do |input|
|
27
|
+
assert_equal(File.read(__FILE__), input.read)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_pathname
|
33
|
+
path = Pathname(__FILE__)
|
34
|
+
Gio::File.open(path: path) do |file|
|
35
|
+
file.read do |input|
|
36
|
+
assert_equal(File.read(__FILE__), input.read)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
sub_test_case("instance methods") do
|
44
|
+
def setup
|
45
|
+
@file = Gio::File.open(path: __FILE__)
|
46
|
+
end
|
47
|
+
|
22
48
|
def test_guess_content_type
|
23
49
|
omit_on_os_x
|
24
50
|
path = fixture_path("content-type", "x-content", "unix-software")
|
@@ -26,5 +52,19 @@ class TestFile < Test::Unit::TestCase
|
|
26
52
|
assert_equal(["x-content/unix-software"],
|
27
53
|
dir.guess_content_types.collect(&:to_s))
|
28
54
|
end
|
55
|
+
|
56
|
+
sub_test_case("#read") do
|
57
|
+
def test_no_block
|
58
|
+
input_stream = @file.read
|
59
|
+
assert_equal(File.read(__FILE__), input_stream.read)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_with_block
|
63
|
+
content = @file.read do |input_stream|
|
64
|
+
input_stream.read
|
65
|
+
end
|
66
|
+
assert_equal(File.read(__FILE__), content)
|
67
|
+
end
|
68
|
+
end
|
29
69
|
end
|
30
70
|
end
|
data/test/test-input-stream.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Ruby-GNOME2 Project Team
|
1
|
+
# Copyright (C) 2014-2019 Ruby-GNOME2 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
|
@@ -26,6 +26,45 @@ class TestInputStream < Test::Unit::TestCase
|
|
26
26
|
teardown_socket_client
|
27
27
|
end
|
28
28
|
|
29
|
+
sub_test_case(".open") do
|
30
|
+
def setup
|
31
|
+
super
|
32
|
+
@data = "Hello\n"
|
33
|
+
client = @server.accept
|
34
|
+
client.write(@data)
|
35
|
+
client.flush
|
36
|
+
client.close
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_no_block
|
40
|
+
input = Gio::BufferedInputStream.open(@stream)
|
41
|
+
assert_equal(@data[0, 4], input.read(4))
|
42
|
+
input.close
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_block
|
46
|
+
input = nil
|
47
|
+
read_data = Gio::BufferedInputStream.open(@stream) do |i|
|
48
|
+
input = i
|
49
|
+
input.read(4)
|
50
|
+
end
|
51
|
+
assert_equal([@data[0, 4], true],
|
52
|
+
[read_data, input.closed?])
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_block_closed
|
56
|
+
input = nil
|
57
|
+
read_data = Gio::BufferedInputStream.open(@stream) do |i|
|
58
|
+
input = i
|
59
|
+
_data = input.read(4)
|
60
|
+
input.close
|
61
|
+
_data
|
62
|
+
end
|
63
|
+
assert_equal([@data[0, 4], true],
|
64
|
+
[read_data, input.closed?])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
29
68
|
sub_test_case("#read") do
|
30
69
|
def test_with_size
|
31
70
|
data = "Hello\n"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gio2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Ruby-GNOME2 Project Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gobject-introspection
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.3.
|
19
|
+
version: 3.3.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.3.
|
26
|
+
version: 3.3.6
|
27
27
|
description: Ruby/GIO2 provide Ruby binding to a VFS API and useful APIs for desktop
|
28
28
|
applications (such as networking and D-Bus support).
|
29
29
|
email: ruby-gnome2-devel-en@lists.sourceforge.net
|