ruby-dbus 0.16.0 → 0.18.1
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/NEWS.md +160 -0
- data/README.md +3 -5
- data/Rakefile +18 -8
- data/VERSION +1 -1
- data/doc/Reference.md +106 -7
- data/examples/doc/_extract_examples +7 -0
- data/examples/gdbus/gdbus +31 -24
- data/examples/no-introspect/nm-test.rb +2 -0
- data/examples/no-introspect/tracker-test.rb +3 -1
- data/examples/rhythmbox/playpause.rb +2 -1
- data/examples/service/call_service.rb +2 -1
- data/examples/service/complex-property.rb +21 -0
- data/examples/service/service_newapi.rb +1 -1
- data/examples/simple/call_introspect.rb +1 -0
- data/examples/simple/get_id.rb +2 -1
- data/examples/simple/properties.rb +2 -0
- data/examples/utils/listnames.rb +1 -0
- data/examples/utils/notify.rb +1 -0
- data/lib/dbus/api_options.rb +9 -0
- data/lib/dbus/auth.rb +20 -15
- data/lib/dbus/bus.rb +123 -75
- data/lib/dbus/bus_name.rb +12 -8
- data/lib/dbus/core_ext/class/attribute.rb +1 -1
- data/lib/dbus/data.rb +821 -0
- data/lib/dbus/emits_changed_signal.rb +83 -0
- data/lib/dbus/error.rb +4 -2
- data/lib/dbus/introspect.rb +132 -31
- data/lib/dbus/logger.rb +3 -1
- data/lib/dbus/marshall.rb +247 -296
- data/lib/dbus/matchrule.rb +16 -16
- data/lib/dbus/message.rb +44 -37
- data/lib/dbus/message_queue.rb +16 -10
- data/lib/dbus/object.rb +358 -24
- data/lib/dbus/object_path.rb +11 -6
- data/lib/dbus/proxy_object.rb +22 -1
- data/lib/dbus/proxy_object_factory.rb +13 -7
- data/lib/dbus/proxy_object_interface.rb +63 -30
- data/lib/dbus/raw_message.rb +91 -0
- data/lib/dbus/type.rb +318 -86
- data/lib/dbus/xml.rb +32 -17
- data/lib/dbus.rb +14 -7
- data/ruby-dbus.gemspec +7 -3
- data/spec/async_spec.rb +2 -0
- data/spec/binding_spec.rb +2 -0
- data/spec/bus_and_xml_backend_spec.rb +2 -0
- data/spec/bus_driver_spec.rb +2 -0
- data/spec/bus_name_spec.rb +3 -1
- data/spec/bus_spec.rb +2 -0
- data/spec/byte_array_spec.rb +2 -0
- data/spec/client_robustness_spec.rb +4 -2
- data/spec/data/marshall.yaml +1667 -0
- data/spec/data_spec.rb +673 -0
- data/spec/emits_changed_signal_spec.rb +58 -0
- data/spec/err_msg_spec.rb +2 -0
- data/spec/introspect_xml_parser_spec.rb +2 -0
- data/spec/introspection_spec.rb +2 -0
- data/spec/main_loop_spec.rb +3 -1
- data/spec/node_spec.rb +23 -0
- data/spec/object_path_spec.rb +3 -0
- data/spec/object_spec.rb +138 -0
- data/spec/packet_marshaller_spec.rb +41 -0
- data/spec/packet_unmarshaller_spec.rb +248 -0
- data/spec/property_spec.rb +192 -5
- data/spec/proxy_object_spec.rb +2 -0
- data/spec/server_robustness_spec.rb +2 -0
- data/spec/server_spec.rb +2 -0
- data/spec/service_newapi.rb +70 -70
- data/spec/session_bus_spec.rb +3 -1
- data/spec/session_bus_spec_manual.rb +2 -0
- data/spec/signal_spec.rb +5 -3
- data/spec/spec_helper.rb +37 -9
- data/spec/thread_safety_spec.rb +2 -0
- data/spec/tools/dbus-limited-session.conf +4 -0
- data/spec/type_spec.rb +214 -6
- data/spec/value_spec.rb +16 -1
- data/spec/variant_spec.rb +4 -2
- data/spec/zzz_quit_spec.rb +16 -0
- metadata +34 -8
data/spec/type_spec.rb
CHANGED
@@ -1,18 +1,226 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
require_relative "spec_helper"
|
3
5
|
require "dbus"
|
4
6
|
|
5
7
|
describe DBus do
|
6
8
|
describe ".type" do
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
good = [
|
10
|
+
"i",
|
11
|
+
"ai",
|
12
|
+
"a(ii)",
|
13
|
+
"aai"
|
14
|
+
]
|
15
|
+
|
16
|
+
context "valid single types" do
|
17
|
+
good.each do |s|
|
18
|
+
it "#{s.inspect} is parsed" do
|
19
|
+
expect(DBus.type(s).to_s).to eq(s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
bad = [
|
25
|
+
["\x00", "Unknown type code"],
|
26
|
+
["!", "Unknown type code"],
|
27
|
+
|
28
|
+
# ARRAY related
|
29
|
+
["a", "Empty ARRAY"],
|
30
|
+
["aa", "Empty ARRAY"],
|
31
|
+
|
32
|
+
# STRUCT related
|
33
|
+
["r", "Abstract STRUCT"],
|
34
|
+
["()", "Empty STRUCT"],
|
35
|
+
["(ii", "STRUCT not closed"],
|
36
|
+
["a{i)", "STRUCT unexpectedly closed"],
|
37
|
+
|
38
|
+
# TODO: deep nesting arrays, structs, combined
|
39
|
+
|
40
|
+
# DICT_ENTRY related
|
41
|
+
["e", "Abstract DICT_ENTRY"],
|
42
|
+
["a{}", "DICT_ENTRY must have 2 subtypes, found 0"],
|
43
|
+
["a{s}", "DICT_ENTRY must have 2 subtypes, found 1"],
|
44
|
+
["a{sss}", "DICT_ENTRY must have 2 subtypes, found 3"],
|
45
|
+
["a{vs}", "DICT_ENTRY key must be basic (non-container)"],
|
46
|
+
["{sv}", "DICT_ENTRY not an immediate child of an ARRAY"],
|
47
|
+
["a({sv})", "DICT_ENTRY not an immediate child of an ARRAY"],
|
48
|
+
["a{s", "DICT_ENTRY not closed"],
|
49
|
+
["a{sv", "DICT_ENTRY not closed"],
|
50
|
+
["}", "DICT_ENTRY unexpectedly closed"],
|
51
|
+
|
52
|
+
# Too long
|
53
|
+
["(#{"y" * 254})", "longer than 255"],
|
54
|
+
|
55
|
+
# not Single Complete Types
|
56
|
+
["", "expecting a Single Complete Type"],
|
57
|
+
["ii", "more than a Single Complete Type"]
|
58
|
+
]
|
59
|
+
context "invalid single types" do
|
60
|
+
bad.each.each do |s, msg|
|
61
|
+
it "#{s.inspect} raises an exception mentioning: #{msg}" do
|
62
|
+
rx = Regexp.new(Regexp.quote(msg))
|
63
|
+
expect { DBus.type(s) }.to raise_error(DBus::Type::SignatureException, rx)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe ".types" do
|
70
|
+
good = [
|
71
|
+
"",
|
72
|
+
"ii"
|
73
|
+
]
|
74
|
+
|
75
|
+
context "valid signatures" do
|
76
|
+
good.each do |s|
|
77
|
+
it "#{s.inspect} is parsed" do
|
78
|
+
expect(DBus.types(s).map(&:to_s).join).to eq(s)
|
79
|
+
end
|
10
80
|
end
|
11
81
|
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe DBus::Type do
|
85
|
+
let(:as1) { DBus.type("as") }
|
86
|
+
let(:as2) { DBus.type("as") }
|
87
|
+
let(:aas) { DBus.type("aas") }
|
88
|
+
|
89
|
+
describe "#==" do
|
90
|
+
it "is true for same types" do
|
91
|
+
expect(as1).to eq(as2)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "is true for a type and its string representation" do
|
95
|
+
expect(as1).to eq("as")
|
96
|
+
end
|
97
|
+
|
98
|
+
it "is false for different types" do
|
99
|
+
expect(as1).to_not eq(aas)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "is false for a type and a different string" do
|
103
|
+
expect(as1).to_not eq("aas")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#eql?" do
|
108
|
+
it "is true for same types" do
|
109
|
+
expect(as1).to eql(as2)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "is false for a type and its string representation" do
|
113
|
+
expect(as1).to_not eql("as")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "is false for different types" do
|
117
|
+
expect(as1).to_not eql(aas)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "is false for a type and a different string" do
|
121
|
+
expect(as1).to_not eql("aas")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#<<" do
|
126
|
+
it "raises if the argument is not a Type" do
|
127
|
+
t = DBus::Type.new(DBus::Type::ARRAY)
|
128
|
+
expect { t << "s" }.to raise_error(ArgumentError)
|
129
|
+
end
|
130
|
+
|
131
|
+
# TODO: the following raise checks do not occur in practice, as there are
|
132
|
+
# parallel checks in the parses. The code could be simplified?
|
133
|
+
it "raises if adding too much to an array" do
|
134
|
+
t = DBus::Type.new(DBus::Type::ARRAY)
|
135
|
+
b = DBus::Type.new(DBus::Type::BOOLEAN)
|
136
|
+
t << b
|
137
|
+
expect { t << b }.to raise_error(DBus::Type::SignatureException)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "raises if adding too much to a dict_entry" do
|
141
|
+
t = DBus::Type.new(DBus::Type::DICT_ENTRY, abstract: true)
|
142
|
+
b = DBus::Type.new(DBus::Type::BOOLEAN)
|
143
|
+
t << b
|
144
|
+
t << b
|
145
|
+
expect { t << b }.to raise_error(DBus::Type::SignatureException)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "raises if adding to a non-container" do
|
149
|
+
t = DBus::Type.new(DBus::Type::STRING)
|
150
|
+
b = DBus::Type.new(DBus::Type::BOOLEAN)
|
151
|
+
expect { t << b }.to raise_error(DBus::Type::SignatureException)
|
152
|
+
|
153
|
+
t = DBus::Type.new(DBus::Type::VARIANT)
|
154
|
+
expect { t << b }.to raise_error(DBus::Type::SignatureException)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe DBus::Type::Array do
|
159
|
+
describe ".[]" do
|
160
|
+
it "takes Type argument" do
|
161
|
+
t = DBus::Type::Array[DBus::Type.new("s")]
|
162
|
+
expect(t.to_s).to eq "as"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "takes 's':String argument" do
|
166
|
+
t = DBus::Type::Array["s"]
|
167
|
+
expect(t.to_s).to eq "as"
|
168
|
+
end
|
169
|
+
|
170
|
+
it "takes String:Class argument" do
|
171
|
+
t = DBus::Type::Array[String]
|
172
|
+
expect(t.to_s).to eq "as"
|
173
|
+
end
|
174
|
+
|
175
|
+
it "rejects Integer:Class argument" do
|
176
|
+
expect { DBus::Type::Array[Integer] }.to raise_error(ArgumentError)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "rejects /./:Regexp argument" do
|
180
|
+
expect { DBus::Type::Array[/./] }.to raise_error(ArgumentError)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe DBus::Type::Hash do
|
186
|
+
describe ".[]" do
|
187
|
+
it "takes Type arguments" do
|
188
|
+
t = DBus::Type::Hash[DBus::Type.new("s"), DBus::Type.new("v")]
|
189
|
+
expect(t.to_s).to eq "a{sv}"
|
190
|
+
end
|
191
|
+
|
192
|
+
it "takes 's':String arguments" do
|
193
|
+
t = DBus::Type::Hash["s", "v"]
|
194
|
+
expect(t.to_s).to eq "a{sv}"
|
195
|
+
end
|
196
|
+
|
197
|
+
it "takes String:Class argument" do
|
198
|
+
t = DBus::Type::Hash[String, DBus::Type::VARIANT]
|
199
|
+
expect(t.to_s).to eq "a{sv}"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe DBus::Type::Struct do
|
205
|
+
describe ".[]" do
|
206
|
+
it "takes Type arguments" do
|
207
|
+
t = DBus::Type::Struct[DBus::Type.new("s"), DBus::Type.new("v")]
|
208
|
+
expect(t.to_s).to eq "(sv)"
|
209
|
+
end
|
210
|
+
|
211
|
+
it "takes 's':String arguments" do
|
212
|
+
t = DBus::Type::Struct["s", "v"]
|
213
|
+
expect(t.to_s).to eq "(sv)"
|
214
|
+
end
|
215
|
+
|
216
|
+
it "takes String:Class argument" do
|
217
|
+
t = DBus::Type::Struct[String, DBus::Type::VARIANT]
|
218
|
+
expect(t.to_s).to eq "(sv)"
|
219
|
+
end
|
12
220
|
|
13
|
-
|
14
|
-
|
15
|
-
|
221
|
+
it "raises on no arguments" do
|
222
|
+
expect { DBus::Type::Struct[] }.to raise_error(ArgumentError)
|
223
|
+
end
|
16
224
|
end
|
17
225
|
end
|
18
226
|
end
|
data/spec/value_spec.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
3
4
|
require_relative "spec_helper"
|
4
5
|
require "dbus"
|
5
6
|
|
@@ -91,4 +92,18 @@ describe "ValueTest" do
|
|
91
92
|
it "aligns short integers correctly" do
|
92
93
|
expect(@obj.i16_plus(10, -30)[0]).to eq(-20)
|
93
94
|
end
|
95
|
+
|
96
|
+
context "structs" do
|
97
|
+
it "they are returned as FROZEN arrays" do
|
98
|
+
struct = @obj.Coordinates[0]
|
99
|
+
expect(struct).to be_an(Array)
|
100
|
+
expect(struct).to be_frozen
|
101
|
+
end
|
102
|
+
|
103
|
+
it "they are returned also from structs" do
|
104
|
+
struct = @obj.Coordinates2[0]
|
105
|
+
expect(struct).to be_an(Array)
|
106
|
+
expect(struct).to be_frozen
|
107
|
+
end
|
108
|
+
end
|
94
109
|
end
|
data/spec/variant_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
# Test marshalling variants according to ruby types
|
3
5
|
require_relative "spec_helper"
|
4
6
|
require "dbus"
|
@@ -9,8 +11,8 @@ describe "VariantTest" do
|
|
9
11
|
@svc = @bus.service("org.ruby.service")
|
10
12
|
end
|
11
13
|
|
12
|
-
def make_variant(
|
13
|
-
DBus::PacketMarshaller.make_variant(
|
14
|
+
def make_variant(val)
|
15
|
+
DBus::PacketMarshaller.make_variant(val)
|
14
16
|
end
|
15
17
|
|
16
18
|
it "tests make variant scalar" do
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "spec_helper"
|
5
|
+
require "dbus"
|
6
|
+
|
7
|
+
describe "Quit the service" do
|
8
|
+
it "Tells the service to quit and waits, to collate coverage data" do
|
9
|
+
session_bus = DBus::ASessionBus.new
|
10
|
+
@svc = session_bus.service("org.ruby.service")
|
11
|
+
@obj = @svc.object("/org/ruby/MyInstance")
|
12
|
+
@obj.default_iface = "org.ruby.SampleInterface"
|
13
|
+
@obj.quit
|
14
|
+
sleep 3
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-dbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruby DBus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rexml
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov-lcov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Pure Ruby module for interaction with D-Bus IPC system
|
98
112
|
email: martin.github@vidner.net
|
99
113
|
executables: []
|
@@ -117,6 +131,7 @@ files:
|
|
117
131
|
- examples/no-introspect/tracker-test.rb
|
118
132
|
- examples/rhythmbox/playpause.rb
|
119
133
|
- examples/service/call_service.rb
|
134
|
+
- examples/service/complex-property.rb
|
120
135
|
- examples/service/service_newapi.rb
|
121
136
|
- examples/simple/call_introspect.rb
|
122
137
|
- examples/simple/get_id.rb
|
@@ -130,6 +145,8 @@ files:
|
|
130
145
|
- lib/dbus/bus_name.rb
|
131
146
|
- lib/dbus/core_ext/class/attribute.rb
|
132
147
|
- lib/dbus/core_ext/module/redefine_method.rb
|
148
|
+
- lib/dbus/data.rb
|
149
|
+
- lib/dbus/emits_changed_signal.rb
|
133
150
|
- lib/dbus/error.rb
|
134
151
|
- lib/dbus/introspect.rb
|
135
152
|
- lib/dbus/logger.rb
|
@@ -142,6 +159,7 @@ files:
|
|
142
159
|
- lib/dbus/proxy_object.rb
|
143
160
|
- lib/dbus/proxy_object_factory.rb
|
144
161
|
- lib/dbus/proxy_object_interface.rb
|
162
|
+
- lib/dbus/raw_message.rb
|
145
163
|
- lib/dbus/type.rb
|
146
164
|
- lib/dbus/xml.rb
|
147
165
|
- ruby-dbus.gemspec
|
@@ -153,11 +171,18 @@ files:
|
|
153
171
|
- spec/bus_spec.rb
|
154
172
|
- spec/byte_array_spec.rb
|
155
173
|
- spec/client_robustness_spec.rb
|
174
|
+
- spec/data/marshall.yaml
|
175
|
+
- spec/data_spec.rb
|
176
|
+
- spec/emits_changed_signal_spec.rb
|
156
177
|
- spec/err_msg_spec.rb
|
157
178
|
- spec/introspect_xml_parser_spec.rb
|
158
179
|
- spec/introspection_spec.rb
|
159
180
|
- spec/main_loop_spec.rb
|
181
|
+
- spec/node_spec.rb
|
160
182
|
- spec/object_path_spec.rb
|
183
|
+
- spec/object_spec.rb
|
184
|
+
- spec/packet_marshaller_spec.rb
|
185
|
+
- spec/packet_unmarshaller_spec.rb
|
161
186
|
- spec/property_spec.rb
|
162
187
|
- spec/proxy_object_spec.rb
|
163
188
|
- spec/server_robustness_spec.rb
|
@@ -175,6 +200,7 @@ files:
|
|
175
200
|
- spec/type_spec.rb
|
176
201
|
- spec/value_spec.rb
|
177
202
|
- spec/variant_spec.rb
|
203
|
+
- spec/zzz_quit_spec.rb
|
178
204
|
homepage: https://github.com/mvidner/ruby-dbus
|
179
205
|
licenses:
|
180
206
|
- LGPL-2.1
|
@@ -187,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
213
|
requirements:
|
188
214
|
- - ">="
|
189
215
|
- !ruby/object:Gem::Version
|
190
|
-
version: 2.
|
216
|
+
version: 2.4.0
|
191
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
218
|
requirements:
|
193
219
|
- - ">="
|
@@ -195,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
221
|
version: '0'
|
196
222
|
requirements: []
|
197
223
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.7.6
|
224
|
+
rubygems_version: 2.7.6.3
|
199
225
|
signing_key:
|
200
226
|
specification_version: 4
|
201
227
|
summary: Ruby module for interaction with D-Bus
|