ruby-dbus 0.18.0.beta5 → 0.18.0.beta8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +43 -0
- data/VERSION +1 -1
- data/doc/Reference.md +13 -4
- data/lib/dbus/bus.rb +3 -7
- data/lib/dbus/data.rb +165 -68
- data/lib/dbus/emits_changed_signal.rb +83 -0
- data/lib/dbus/introspect.rb +44 -4
- data/lib/dbus/marshall.rb +6 -3
- data/lib/dbus/object.rb +84 -22
- data/lib/dbus/proxy_object_factory.rb +2 -0
- data/lib/dbus/proxy_object_interface.rb +37 -9
- data/lib/dbus/type.rb +26 -2
- data/lib/dbus/xml.rb +4 -0
- data/lib/dbus.rb +1 -0
- data/spec/data_spec.rb +342 -14
- data/spec/emits_changed_signal_spec.rb +58 -0
- data/spec/object_spec.rb +138 -0
- data/spec/packet_unmarshaller_spec.rb +2 -16
- data/spec/property_spec.rb +35 -2
- data/spec/service_newapi.rb +13 -0
- data/spec/type_spec.rb +40 -0
- metadata +5 -2
@@ -48,14 +48,7 @@ RSpec.shared_examples "parses good data" do |cases|
|
|
48
48
|
result = results.first
|
49
49
|
|
50
50
|
expect(result).to be_a(DBus::Data::Base)
|
51
|
-
|
52
|
-
expect(result.value.size).to eq(expected.size)
|
53
|
-
result.value.each_key do |result_key|
|
54
|
-
expect(result.value[result_key]).to eq(expected[result_key.value])
|
55
|
-
end
|
56
|
-
else
|
57
|
-
expect(result.value).to eq(expected)
|
58
|
-
end
|
51
|
+
expect(result.value).to eq(expected)
|
59
52
|
|
60
53
|
expect(remaining_buffer(subject)).to be_empty
|
61
54
|
end
|
@@ -106,14 +99,7 @@ describe DBus::PacketUnmarshaller do
|
|
106
99
|
result = results.first
|
107
100
|
|
108
101
|
expect(result).to be_a(DBus::Data::Base)
|
109
|
-
|
110
|
-
expect(result.value.size).to eq(expected.size)
|
111
|
-
result.value.each_key do |result_key|
|
112
|
-
expect(result.value[result_key]).to eq(expected[result_key.value])
|
113
|
-
end
|
114
|
-
else
|
115
|
-
expect(result.value).to eq(expected)
|
116
|
-
end
|
102
|
+
expect(result.value).to eq(expected)
|
117
103
|
|
118
104
|
expect(remaining_buffer(subject)).to be_empty
|
119
105
|
end
|
data/spec/property_spec.rb
CHANGED
@@ -60,7 +60,7 @@ describe "PropertyTest" do
|
|
60
60
|
|
61
61
|
it "tests get all" do
|
62
62
|
all = @iface.all_properties
|
63
|
-
expect(all.keys.sort).to eq(["MyArray", "MyDict", "MyStruct", "MyVariant", "ReadMe", "ReadOrWriteMe"])
|
63
|
+
expect(all.keys.sort).to eq(["MyArray", "MyByte", "MyDict", "MyStruct", "MyVariant", "ReadMe", "ReadOrWriteMe"])
|
64
64
|
end
|
65
65
|
|
66
66
|
it "tests get all on a V1 object" do
|
@@ -68,7 +68,7 @@ describe "PropertyTest" do
|
|
68
68
|
iface = obj["org.ruby.SampleInterface"]
|
69
69
|
|
70
70
|
all = iface.all_properties
|
71
|
-
expect(all.keys.sort).to eq(["MyArray", "MyDict", "MyStruct", "MyVariant", "ReadMe", "ReadOrWriteMe"])
|
71
|
+
expect(all.keys.sort).to eq(["MyArray", "MyByte", "MyDict", "MyStruct", "MyVariant", "ReadMe", "ReadOrWriteMe"])
|
72
72
|
end
|
73
73
|
|
74
74
|
it "tests unknown property reading" do
|
@@ -110,6 +110,7 @@ describe "PropertyTest" do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
@iface["ReadOrWriteMe"] = "VALUE"
|
113
|
+
@iface.SetTwoProperties("REAMDE", 255)
|
113
114
|
|
114
115
|
# loop to process the signal. complicated :-( see signal_spec.rb
|
115
116
|
loop = DBus::Main.new
|
@@ -123,6 +124,8 @@ describe "PropertyTest" do
|
|
123
124
|
quitter.join
|
124
125
|
|
125
126
|
expect(received["ReadOrWriteMe"]).to eq("VALUE")
|
127
|
+
expect(received["ReadMe"]).to eq("REAMDE")
|
128
|
+
expect(received["MyByte"]).to eq(255)
|
126
129
|
end
|
127
130
|
|
128
131
|
context "a struct-typed property" do
|
@@ -200,6 +203,36 @@ describe "PropertyTest" do
|
|
200
203
|
end
|
201
204
|
end
|
202
205
|
|
206
|
+
context "a byte-typed property" do
|
207
|
+
# Slightly advanced RSpec:
|
208
|
+
# https://rspec.info/documentation/3.9/rspec-expectations/RSpec/Matchers.html#satisfy-instance_method
|
209
|
+
let(:a_byte_in_a_variant) do
|
210
|
+
satisfying { |x| x.is_a?(DBus::Data::Variant) && x.member_type.to_s == DBus::Type::BYTE }
|
211
|
+
# ^ This formatting keeps the matcher on a single line
|
212
|
+
# which enables RSpec to cite it if it fails, instead of saying "block".
|
213
|
+
end
|
214
|
+
|
215
|
+
let(:prop_iface) { @obj[DBus::PROPERTY_INTERFACE] }
|
216
|
+
|
217
|
+
it "gets set with a correct type (#108)" do
|
218
|
+
expect(prop_iface).to receive(:Set).with(
|
219
|
+
"org.ruby.SampleInterface",
|
220
|
+
"MyByte",
|
221
|
+
a_byte_in_a_variant
|
222
|
+
)
|
223
|
+
@iface["MyByte"] = 1
|
224
|
+
end
|
225
|
+
|
226
|
+
it "gets set with a correct type (#108), when using the DBus.variant workaround" do
|
227
|
+
expect(prop_iface).to receive(:Set).with(
|
228
|
+
"org.ruby.SampleInterface",
|
229
|
+
"MyByte",
|
230
|
+
a_byte_in_a_variant
|
231
|
+
)
|
232
|
+
@iface["MyByte"] = DBus.variant("y", 1)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
203
236
|
context "marshall.yaml round-trip via a VARIANT property" do
|
204
237
|
marshall_yaml.each do |test|
|
205
238
|
t = OpenStruct.new(test)
|
data/spec/service_newapi.rb
CHANGED
@@ -28,6 +28,8 @@ class Test < DBus::Object
|
|
28
28
|
"three" => [3, 3, 3]
|
29
29
|
}
|
30
30
|
@my_variant = @my_array.dup
|
31
|
+
# 201 is a RET instruction for ZX Spectrum which has turned 40 recently
|
32
|
+
@my_byte = 201
|
31
33
|
@main_loop = nil
|
32
34
|
end
|
33
35
|
|
@@ -111,6 +113,17 @@ class Test < DBus::Object
|
|
111
113
|
dbus_attr_accessor :my_array, "aq"
|
112
114
|
dbus_attr_accessor :my_dict, "a{sv}"
|
113
115
|
dbus_attr_accessor :my_variant, "v"
|
116
|
+
|
117
|
+
dbus_attr_accessor :my_byte, "y"
|
118
|
+
|
119
|
+
# to test dbus_properties_changed
|
120
|
+
dbus_method :SetTwoProperties, "in read_me:s, in byte:y" do |read_me, byte|
|
121
|
+
@read_me = read_me
|
122
|
+
@my_byte = byte
|
123
|
+
dbus_properties_changed(INTERFACE,
|
124
|
+
{ "ReadMe" => read_me, "MyByte" => byte },
|
125
|
+
[])
|
126
|
+
end
|
114
127
|
end
|
115
128
|
|
116
129
|
# closing and reopening the same interface
|
data/spec/type_spec.rb
CHANGED
@@ -82,6 +82,46 @@ describe DBus do
|
|
82
82
|
end
|
83
83
|
|
84
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
|
+
|
85
125
|
describe "#<<" do
|
86
126
|
it "raises if the argument is not a Type" do
|
87
127
|
t = DBus::Type.new(DBus::Type::ARRAY)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-dbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.0.
|
4
|
+
version: 0.18.0.beta8
|
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: 2022-
|
11
|
+
date: 2022-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rexml
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/dbus/core_ext/class/attribute.rb
|
147
147
|
- lib/dbus/core_ext/module/redefine_method.rb
|
148
148
|
- lib/dbus/data.rb
|
149
|
+
- lib/dbus/emits_changed_signal.rb
|
149
150
|
- lib/dbus/error.rb
|
150
151
|
- lib/dbus/introspect.rb
|
151
152
|
- lib/dbus/logger.rb
|
@@ -172,12 +173,14 @@ files:
|
|
172
173
|
- spec/client_robustness_spec.rb
|
173
174
|
- spec/data/marshall.yaml
|
174
175
|
- spec/data_spec.rb
|
176
|
+
- spec/emits_changed_signal_spec.rb
|
175
177
|
- spec/err_msg_spec.rb
|
176
178
|
- spec/introspect_xml_parser_spec.rb
|
177
179
|
- spec/introspection_spec.rb
|
178
180
|
- spec/main_loop_spec.rb
|
179
181
|
- spec/node_spec.rb
|
180
182
|
- spec/object_path_spec.rb
|
183
|
+
- spec/object_spec.rb
|
181
184
|
- spec/packet_marshaller_spec.rb
|
182
185
|
- spec/packet_unmarshaller_spec.rb
|
183
186
|
- spec/property_spec.rb
|