gio2 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e3bfdf472b2d76f14c87a54d389ef6d83ea2da2
4
- data.tar.gz: b1c3f4cb4dfa19f10496aafcc47624a71805fdc7
3
+ metadata.gz: 5dc578d247292033bf8e59ca7e08c62fcb287267
4
+ data.tar.gz: baf4aaa19e4a80e4a9e27d59504d802574a3a99b
5
5
  SHA512:
6
- metadata.gz: 3c84884c4a7538781d6fc959f034bce9d3ff14c8778f651bee68af5ed1b5ddbdf328c41be76a6896b9796855cd431bc861cef2702ca8178b6f7d80984c45569b
7
- data.tar.gz: 6c51885ac72c9cf1658429fef6df6b1b6d0f7e9db984ffbbe0348e047b79bcf281ad80898a4055b37e52dc5779a10833ce81d2ccd9716b77c3b051bf4d593bf8
6
+ metadata.gz: 71fb5a9297cbe5b55ef8c9c19b422b589f632467d576408f4334f5188e40312db1584d9cfa3de84ef6ead1655f14421f90e9309bc5e1c79daa376781dc198f0b
7
+ data.tar.gz: e564d110ecc693911cceeaade69cf3634775282c5920bad623a6d6325bda052aa392f66dfc50966f924f906100782a4cc88bc7803fc5446db0726aac8069310c
@@ -16,18 +16,20 @@
16
16
 
17
17
  module Gio
18
18
  class SettingsSchemaSource
19
- alias_method :list_schemas_raw, :list_schemas
20
- def list_schemas(recursive_or_options=nil)
21
- case recursive_or_options
22
- when true, false
23
- recursive = recursive_or_options
24
- else
25
- options = recursive_or_options || {}
26
- recursive = options[:recursive]
27
- recursive = true if recursive.nil?
28
- end
19
+ if method_defined?(:list_schemas)
20
+ alias_method :list_schemas_raw, :list_schemas
21
+ def list_schemas(recursive_or_options=nil)
22
+ case recursive_or_options
23
+ when true, false
24
+ recursive = recursive_or_options
25
+ else
26
+ options = recursive_or_options || {}
27
+ recursive = options[:recursive]
28
+ recursive = true if recursive.nil?
29
+ end
29
30
 
30
- list_schemas_raw(recursive)
31
+ list_schemas_raw(recursive)
32
+ end
31
33
  end
32
34
  end
33
35
  end
data/lib/gio2/settings.rb CHANGED
@@ -16,6 +16,30 @@
16
16
 
17
17
  module Gio
18
18
  class Settings
19
+ alias_method :initialize_raw, :initialize
20
+
21
+ def initialize(*args)
22
+ if args.size == 1
23
+ initialize_raw(args[0])
24
+ elsif args.size == 2
25
+ schema_id = args[0]
26
+ options = args[1]
27
+ path = options[:path] || nil
28
+ backend = options[:backend] || nil
29
+ if path && backend
30
+ initialize_new_with_backend_and_path(schema_id, backend, path)
31
+ elsif path
32
+ initialize_new_with_path(schema_id, path)
33
+ elsif backend
34
+ initialize_new_with_backend(schema_id, backend)
35
+ end
36
+ elsif args.size == 3
37
+ initialize_new_full(*args)
38
+ else
39
+ $stderr.puts "Arguments error for Gio::Settings#new"
40
+ end
41
+ end
42
+
19
43
  alias_method :set_value_raw, :set_value
20
44
  def set_value(key, value)
21
45
  schema_key = settings_schema.get_key(key)
@@ -0,0 +1,51 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2016 Ruby-GNOME2 Project Team
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ require "rake/clean"
20
+
21
+ generated_files = []
22
+
23
+ Rake::FileList["resource/**/*.gresource.xml"].each do |gresource_xml|
24
+ gresource = gresource_xml.gsub(/\.xml\z/, "")
25
+ gresource_dir = File.dirname(gresource_xml)
26
+ generated_files << gresource
27
+ CLEAN << gresource
28
+ dependencies = [gresource_xml] + Rake::FileList["#{gresource_dir}/*.png"]
29
+ file gresource => dependencies do
30
+ cd(gresource_dir) do
31
+ sh("glib-compile-resources", File.basename(gresource_xml))
32
+ end
33
+ end
34
+ end
35
+
36
+ schema_dirs = [
37
+ "schema/default",
38
+ "schema/source",
39
+ ]
40
+ schema_dirs.each do |schema_dir|
41
+ gschema_compiled = File.join(schema_dir, "gschemas.compiled")
42
+ generated_files << gschema_compiled
43
+ CLEAN << gschema_compiled
44
+ file gschema_compiled => Rake::FileList["#{schema_dir}/*.gschema.xml"] do
45
+ cd(schema_dir) do
46
+ sh("glib-compile-schemas", ".")
47
+ end
48
+ end
49
+ end
50
+
51
+ task :default => generated_files
@@ -1,6 +1,6 @@
1
1
  <schemalist>
2
- <schema id="jp.ruby-gnome2.test.value"
3
- path="/jp/ruby-gnome2/test/value/">
2
+ <schema id="jp.ruby-gnome2.test.settings"
3
+ path="/jp/ruby-gnome2/test/settings/">
4
4
  <key name="string" type="s">
5
5
  <default>"default-string"</default>
6
6
  </key>
@@ -16,6 +16,8 @@
16
16
 
17
17
  require "test-unit"
18
18
 
19
+ require "tempfile"
20
+
19
21
  require "gio2-test-utils/fixture"
20
22
  require "gio2-test-utils/omissions"
21
23
  require "gio2-test-utils/socket-client"
data/test/run-test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # Copyright (C) 2013-2015 Ruby-GNOME2 Project Team
3
+ # Copyright (C) 2013-2016 Ruby-GNOME2 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
@@ -38,20 +38,11 @@ modules.each do |target, module_name|
38
38
  $LOAD_PATH.unshift(File.join(target, "lib"))
39
39
  end
40
40
 
41
- Dir.chdir(File.join(gio2_base, "test", "fixture", "resource")) do
42
- system("rake") or exit(false)
43
- end
44
-
45
- schema_dir = File.join(gio2_base, "test", "fixture", "schema")
46
- settings_schema_dir = File.join(schema_dir, "settings")
47
- Dir.chdir(settings_schema_dir) do
48
- system("rake") or exit(false)
49
- end
50
- ENV["GSETTINGS_SCHEMA_DIR"] = settings_schema_dir
51
-
52
- Dir.chdir(File.join(schema_dir, "source")) do
41
+ fixture_dir = File.join(gio2_base, "test", "fixture")
42
+ Dir.chdir(fixture_dir) do
53
43
  system("rake") or exit(false)
54
44
  end
45
+ ENV["GSETTINGS_SCHEMA_DIR"] = File.join(fixture_dir, "schema", "default")
55
46
 
56
47
  $LOAD_PATH.unshift(File.join(glib_base, "test"))
57
48
  require "glib-test-init"
@@ -20,7 +20,7 @@ class TestSettings < Test::Unit::TestCase
20
20
 
21
21
  sub_test_case "accessor" do
22
22
  setup do
23
- @settings = Gio::Settings.new("jp.ruby-gnome2.test.value")
23
+ @settings = Gio::Settings.new("jp.ruby-gnome2.test.settings")
24
24
  end
25
25
 
26
26
  test "string" do
@@ -41,4 +41,90 @@ class TestSettings < Test::Unit::TestCase
41
41
  @settings["boolean"])
42
42
  end
43
43
  end
44
+
45
+ sub_test_case ".new" do
46
+ def need_keyfile_settings_backend
47
+ unless Gio.respond_to?(:keyfile_settings_backend_new)
48
+ omit("Need Gio.keyfile_settings_backend_new")
49
+ end
50
+ end
51
+
52
+ test "minimum" do
53
+ settings = Gio::Settings.new("jp.ruby-gnome2.test.settings")
54
+ settings.reset("string")
55
+ assert_equal("default-string", settings["string"])
56
+ end
57
+
58
+ test ":path" do
59
+ settings = Gio::Settings.new("jp.ruby-gnome2.test.settings",
60
+ :path => "/jp/ruby-gnome2/test/settings/")
61
+ settings.reset("string")
62
+ assert_equal("default-string", settings["string"])
63
+ end
64
+
65
+ test ":backend" do
66
+ need_keyfile_settings_backend
67
+ keyfile = Tempfile.new(["settings", ".ini"])
68
+ backend = Gio::keyfile_settings_backend_new(keyfile.path, "/", "keyfile_settings")
69
+ settings = Gio::Settings.new("jp.ruby-gnome2.test.settings",
70
+ :backend => backend)
71
+
72
+ settings.reset("string")
73
+ assert_equal("default-string", settings["string"])
74
+ settings["string"] = "new-string"
75
+ assert_equal("new-string", settings["string"])
76
+
77
+ keyfile_content_ref = <<-KEYFILE
78
+ [jp/ruby-gnome2/test/settings]
79
+ string='new-string'
80
+ KEYFILE
81
+ keyfile_content = File.read(keyfile.path)
82
+ assert_equal(keyfile_content_ref, keyfile_content)
83
+ FileUtils.rm_f(keyfile)
84
+ end
85
+
86
+ test ":backend and :path" do
87
+ need_keyfile_settings_backend
88
+ keyfile = Tempfile.new(["settings", ".ini"])
89
+ backend = Gio::keyfile_settings_backend_new(keyfile.path, "/", "keyfile_settings")
90
+ settings = Gio::Settings.new("jp.ruby-gnome2.test.settings",
91
+ :backend => backend,
92
+ :path => "/jp/ruby-gnome2/test/settings/")
93
+
94
+ settings.reset("string")
95
+ assert_equal("default-string", settings["string"])
96
+ settings["string"] = "new-string"
97
+ assert_equal("new-string", settings["string"])
98
+
99
+ keyfile_content_ref = <<-KEYFILE
100
+ [jp/ruby-gnome2/test/settings]
101
+ string='new-string'
102
+ KEYFILE
103
+ keyfile_content = File.read(keyfile.path)
104
+ assert_equal(keyfile_content_ref, keyfile_content)
105
+ end
106
+
107
+ test "full" do
108
+ need_keyfile_settings_backend
109
+ keyfile = Tempfile.new(["settings", ".ini"])
110
+ backend = Gio::keyfile_settings_backend_new(keyfile.path, "/", "keyfile_settings")
111
+ schema_source = Gio::SettingsSchemaSource.new(fixture_path("schema"), nil, true)
112
+ schema = schema_source.lookup("jp.ruby-gnome2.test.settings", true)
113
+ settings = Gio::Settings.new(schema,
114
+ backend,
115
+ "/jp/ruby-gnome2/test/settings/")
116
+
117
+ settings.reset("string")
118
+ assert_equal("default-string", settings["string"])
119
+ settings["string"] = "new-string"
120
+ assert_equal("new-string", settings["string"])
121
+
122
+ keyfile_content_ref = <<-KEYFILE
123
+ [jp/ruby-gnome2/test/settings]
124
+ string='new-string'
125
+ KEYFILE
126
+ keyfile_content = File.read(keyfile.path)
127
+ assert_equal(keyfile_content_ref, keyfile_content)
128
+ end
129
+ end
44
130
  end
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.1.0
4
+ version: 3.1.1
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: 2016-11-13 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glib2
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.0
19
+ version: 3.1.1
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.1.0
26
+ version: 3.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: gobject-introspection
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.1.0
33
+ version: 3.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 3.1.0
40
+ version: 3.1.1
41
41
  description: Ruby/GIO2 is a Ruby binding of gio-2.x.
42
42
  email: ruby-gnome2-devel-en@lists.sourceforge.net
43
43
  executables: []
@@ -69,13 +69,12 @@ files:
69
69
  - lib/gio2/settings-schema-source.rb
70
70
  - lib/gio2/settings.rb
71
71
  - lib/gio2/simple-action.rb
72
+ - test/fixture/Rakefile
72
73
  - test/fixture/content-type/x-content/unix-software/autorun.sh
73
74
  - test/fixture/resource/Rakefile
74
75
  - test/fixture/resource/logo.png
75
76
  - test/fixture/resource/ruby-gio2.gresource.xml
76
- - test/fixture/schema/settings/Rakefile
77
- - test/fixture/schema/settings/jp.ruby-gnome2.test.value.gschema.xml
78
- - test/fixture/schema/source/Rakefile
77
+ - test/fixture/schema/default/jp.ruby-gnome2.test.settings.gschema.xml
79
78
  - test/fixture/schema/source/jp.ruby-gnome2.test.source.gschema.xml
80
79
  - test/gio2-test-utils.rb
81
80
  - test/gio2-test-utils/fixture.rb
@@ -125,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
124
  version: '0'
126
125
  requirements: []
127
126
  rubyforge_project:
128
- rubygems_version: 2.5.1
127
+ rubygems_version: 2.5.2
129
128
  signing_key:
130
129
  specification_version: 4
131
130
  summary: Ruby/GIO2 is a Ruby binding of gio-2.x.
@@ -1,28 +0,0 @@
1
- # -*- ruby -*-
2
- #
3
- # Copyright (C) 2016 Ruby-GNOME2 Project Team
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
-
19
- require "rake/clean"
20
-
21
- gschemas_compiled = "gschemas.compiled"
22
-
23
- CLEAN << gschemas_compiled
24
- file gschemas_compiled => Rake::FileList["*.gschema.xml"] do
25
- sh("glib-compile-schemas", ".")
26
- end
27
-
28
- task :default => gschemas_compiled
@@ -1,28 +0,0 @@
1
- # -*- ruby -*-
2
- #
3
- # Copyright (C) 2016 Ruby-GNOME2 Project Team
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
-
19
- require "rake/clean"
20
-
21
- gschemas_compiled = "gschemas.compiled"
22
-
23
- CLEAN << gschemas_compiled
24
- file gschemas_compiled => Rake::FileList["*.gschema.xml"] do
25
- sh("glib-compile-schemas", ".")
26
- end
27
-
28
- task :default => gschemas_compiled