gio2 3.3.5 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gio2/extconf.rb +3 -3
- data/gio2.gemspec +2 -2
- data/lib/gio2/file.rb +14 -1
- data/lib/gio2/icon.rb +24 -0
- data/lib/gio2/input-stream.rb +29 -8
- data/lib/gio2/loader.rb +14 -2
- data/test/gio2-test-utils.rb +2 -1
- data/test/test-file.rb +42 -2
- data/test/test-icon.rb +49 -0
- data/test/test-input-stream.rb +40 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c876c844dbc227000b93fe74bc2acf0353d0e0530c6dae898e4c1dc39a4dd35
|
4
|
+
data.tar.gz: 4693dec79412fb456b8dd0bece005b6616969bae75fa42f4f9025d51a6daef3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 499406198636de28647319fc878d4a656bc2a13885f968e625d96990ea9e76996f73100406d75a5f76eecf08788a31009eaa68826b08dd8533d1057f9522771f
|
7
|
+
data.tar.gz: d567e56d33cbe164d95a85840fa76b4e6c6729805db906056b4a2d650b6b9ecff3d3e57ffe248f99462d18d33ee2b86ce3b263dc7a51ca7427b626fb81d1584c
|
data/ext/gio2/extconf.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014 Ruby-
|
3
|
+
# Copyright (C) 2014-2019 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
|
@@ -36,7 +36,7 @@ $LOAD_PATH.unshift(mkmf_gnome2_dir.to_s)
|
|
36
36
|
module_name = "gio2"
|
37
37
|
package_id = "gio-2.0"
|
38
38
|
|
39
|
-
require "mkmf-
|
39
|
+
require "mkmf-gnome"
|
40
40
|
|
41
41
|
["glib2", "gobject-introspection"].each do |package|
|
42
42
|
directory = "#{package}#{version_suffix}"
|
@@ -52,7 +52,7 @@ end
|
|
52
52
|
unless required_pkg_config_package(package_id,
|
53
53
|
:alt_linux => "libgio-devel",
|
54
54
|
:debian => "libglib2.0-dev",
|
55
|
-
:redhat => "
|
55
|
+
:redhat => "pkgconfig(#{package_id})",
|
56
56
|
:arch_linux => "glib2",
|
57
57
|
:homebrew => "glib",
|
58
58
|
:macports => "glib2")
|
data/gio2.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2018 Ruby-
|
3
|
+
# Copyright (C) 2018 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
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.description =
|
25
25
|
"Ruby/GIO2 provide Ruby binding to a VFS API and useful APIs " +
|
26
26
|
"for desktop applications (such as networking and D-Bus support)."
|
27
|
-
s.author = "The Ruby-
|
27
|
+
s.author = "The Ruby-GNOME Project Team"
|
28
28
|
s.email = "ruby-gnome2-devel-en@lists.sourceforge.net"
|
29
29
|
s.homepage = "https://ruby-gnome2.osdn.jp/"
|
30
30
|
s.licenses = ["LGPL-2.1+"]
|
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/icon.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright (C) 2019 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 Icon
|
19
|
+
def eql?(other)
|
20
|
+
other.is_a?(self.class) and
|
21
|
+
hash == other.hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/gio2/input-stream.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Ruby-
|
1
|
+
# Copyright (C) 2014-2019 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
|
@@ -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?
|
@@ -23,7 +36,7 @@ module Gio
|
|
23
36
|
buffer_size = 8192
|
24
37
|
buffer = " ".force_encoding("ASCII-8BIT") * buffer_size
|
25
38
|
loop do
|
26
|
-
|
39
|
+
read_bytes = read_all_raw_compatible(buffer)
|
27
40
|
all << buffer.byteslice(0, read_bytes)
|
28
41
|
break if read_bytes != buffer_size
|
29
42
|
end
|
@@ -39,25 +52,33 @@ module Gio
|
|
39
52
|
alias_method :read_all_raw, :read_all
|
40
53
|
def read_all(size)
|
41
54
|
buffer = " " * size
|
42
|
-
|
55
|
+
read_bytes = read_all_raw_compatible(buffer)
|
43
56
|
buffer.replace(buffer.byteslice(0, read_bytes))
|
44
57
|
buffer
|
45
58
|
end
|
46
59
|
|
47
60
|
private
|
48
61
|
def read_raw_compatible(buffer)
|
49
|
-
if (GLib::VERSION <=> [2,
|
62
|
+
if (GLib::VERSION <=> [2, 62, 0]) >= 0
|
63
|
+
read_bytes, _buffer = read_raw(buffer)
|
64
|
+
read_bytes
|
65
|
+
elsif (GLib::VERSION <=> [2, 36, 0]) >= 0
|
50
66
|
read_raw(buffer)
|
51
67
|
else
|
52
|
-
read_raw(buffer, buffer.bytesize)
|
68
|
+
read_bytes = read_raw(buffer, buffer.bytesize)
|
53
69
|
end
|
54
70
|
end
|
55
71
|
|
56
72
|
def read_all_raw_compatible(buffer)
|
57
|
-
if (GLib::VERSION <=> [2,
|
58
|
-
read_all_raw(buffer)
|
73
|
+
if (GLib::VERSION <=> [2, 62, 0]) >= 0
|
74
|
+
_success, _buffer, read_bytes = read_all_raw(buffer)
|
75
|
+
read_bytes
|
76
|
+
elsif (GLib::VERSION <=> [2, 36, 0]) >= 0
|
77
|
+
_success, read_bytes = read_all_raw(buffer)
|
78
|
+
read_bytes
|
59
79
|
else
|
60
|
-
read_all_raw(buffer, buffer.bytesize)
|
80
|
+
_success, read_bytes = read_all_raw(buffer, buffer.bytesize)
|
81
|
+
read_bytes
|
61
82
|
end
|
62
83
|
end
|
63
84
|
end
|
data/lib/gio2/loader.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013-
|
1
|
+
# Copyright (C) 2013-2019 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
|
@@ -51,6 +51,7 @@ module Gio
|
|
51
51
|
require "gio2/application-command-line"
|
52
52
|
require "gio2/content-type"
|
53
53
|
require "gio2/file"
|
54
|
+
require "gio2/icon"
|
54
55
|
require "gio2/inet-address"
|
55
56
|
require "gio2/input-stream"
|
56
57
|
require "gio2/menu-item"
|
@@ -113,7 +114,7 @@ module Gio
|
|
113
114
|
when /\Adbus_/
|
114
115
|
name = rubyish_method_name(info, :prefix => "dbus_")
|
115
116
|
define_singleton_method(@dbus_module, name, info)
|
116
|
-
when /\
|
117
|
+
when /\A{file,icon}_/
|
117
118
|
# Ignore because they are defined by load_interface_info
|
118
119
|
else
|
119
120
|
super
|
@@ -171,6 +172,17 @@ module Gio
|
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
175
|
+
def load_function_info_singleton_method(info, klass, method_name)
|
176
|
+
case "#{klass.name}##{method_name}"
|
177
|
+
when "Gio::Icon#hash"
|
178
|
+
define_method(info, klass, method_name)
|
179
|
+
when "Gio::Icon#new_for_string"
|
180
|
+
super(info, klass, "find")
|
181
|
+
else
|
182
|
+
super
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
174
186
|
def rubyish_class_name(info)
|
175
187
|
case info.name
|
176
188
|
when /Enum\z/
|
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-icon.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (C) 2019 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 TestIcon < Test::Unit::TestCase
|
18
|
+
include GioTestUtils::Fixture
|
19
|
+
include GioTestUtils::Omissions
|
20
|
+
|
21
|
+
sub_test_case(".find") do
|
22
|
+
def test_found
|
23
|
+
assert_equal(Gio::ThemedIcon.new("open"),
|
24
|
+
Gio::Icon.find("open"))
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_not_found
|
28
|
+
Gio::Icon.find("nonexistent")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
sub_test_case(".hash") do
|
33
|
+
def test_use_as_key
|
34
|
+
hash = {Gio::Icon => true}
|
35
|
+
assert do
|
36
|
+
hash[Gio::Icon]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
sub_test_case("#hash") do
|
42
|
+
def test_use_as_key
|
43
|
+
hash = {Gio::Icon.find("open") => true}
|
44
|
+
assert do
|
45
|
+
hash[Gio::Icon.find("open")]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/test/test-input-stream.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Ruby-
|
1
|
+
# Copyright (C) 2014-2019 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
|
@@ -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.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- The Ruby-
|
7
|
+
- The Ruby-GNOME Project Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-10 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.
|
19
|
+
version: 3.4.0
|
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.
|
26
|
+
version: 3.4.0
|
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
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/gio2/content-type.rb
|
51
51
|
- lib/gio2/deprecated.rb
|
52
52
|
- lib/gio2/file.rb
|
53
|
+
- lib/gio2/icon.rb
|
53
54
|
- lib/gio2/inet-address.rb
|
54
55
|
- lib/gio2/input-stream.rb
|
55
56
|
- lib/gio2/loader.rb
|
@@ -82,6 +83,7 @@ files:
|
|
82
83
|
- test/test-file-enumerator.rb
|
83
84
|
- test/test-file-monitor.rb
|
84
85
|
- test/test-file.rb
|
86
|
+
- test/test-icon.rb
|
85
87
|
- test/test-inet-address.rb
|
86
88
|
- test/test-input-stream.rb
|
87
89
|
- test/test-memory-input-stream.rb
|