ruby-dbus 0.18.0.beta3 → 0.18.0.beta4

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
  SHA256:
3
- metadata.gz: aefe0e0b1ea07e4d659c568e496f0018e85ef0364d678169db736f967539175b
4
- data.tar.gz: 44c64528e74823a45d318be92b6fc8838b988429c2f1205287682ee40b9a8f38
3
+ metadata.gz: e6e093b55c88614ceebd2cfd0c09a5bba3886b8c561b8e153c034d9249ae5a08
4
+ data.tar.gz: a2b2931d1b3b9ae560cc6204e297a7daceec2ec85a065a2782cbbeed34286f5d
5
5
  SHA512:
6
- metadata.gz: e6655ff88bcbda618eafc3ec62f74f4a2051a5f6327cd130fddd8a3aaff4b8e999fa2843edde8fd6de9cdb0df95fa6dfd56bf18c1e668ac92ffd1e131f58c9f6
7
- data.tar.gz: 4c54cad54ea4833afff8290598c8717a30cb0b221b486378d06070e010b162e54a2dcaa08cb542b21f91cf7dd8ee215646c8461504b676e977b597e325a5b7ae
6
+ metadata.gz: 66e7ad826a0f1ef5bb1abba72a6f76f02fbd4c13c7e7f14caf3abd71946ba4e5a0b9cc16950d60a22eb2d994d73c78306d270296af90f2bf9aa2aaaf4f85dab3
7
+ data.tar.gz: 4641ca7b18414d7cf58d786ab05d3d3bc3a50d40311b1b5650b6f44a1bfcf0b1cca373eee4445b5cd6e0eb70a42407b244d93c09371d9ea985a66d6d4c79c0d7
data/NEWS.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## Ruby D-Bus 0.18.0.beta4 - 2022-04-21
6
+
7
+ Bug fixes:
8
+ * Service-side properties: Fix Properties.Get, Properties.GetAll for
9
+ properties that contain arrays, on other than outermost level ([#109][]).
10
+ * Sending variants: fixed make_variant to correctly guess the signature
11
+ for UInt64 and number-keyed hashes/dictionaries.
12
+
13
+ [#109]: https://github.com/mvidner/ruby-dbus/pull/109
14
+
5
15
  ## Ruby D-Bus 0.18.0.beta3 - 2022-04-10
6
16
 
7
17
  Bug fixes:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.18.0.beta3
1
+ 0.18.0.beta4
data/lib/dbus/marshall.rb CHANGED
@@ -250,6 +250,7 @@ module DBus
250
250
  when Type::VARIANT
251
251
  append_variant(val)
252
252
  when Type::ARRAY
253
+ val = val.value if val.is_a?(Data::Array)
253
254
  append_array(type.child, val)
254
255
  when Type::STRUCT, Type::DICT_ENTRY
255
256
  val = val.value if val.is_a?(Data::Struct) || val.is_a?(Data::DictEntry)
@@ -353,15 +354,23 @@ module DBus
353
354
  elsif value.is_a? Hash
354
355
  h = {}
355
356
  value.each_key { |k| h[k] = make_variant(value[k]) }
356
- ["a{sv}", h]
357
+ key_type = if value.empty?
358
+ "s"
359
+ else
360
+ t, = make_variant(value.first.first)
361
+ t
362
+ end
363
+ ["a{#{key_type}v}", h]
357
364
  elsif value.respond_to? :to_str
358
365
  ["s", value.to_str]
359
366
  elsif value.respond_to? :to_int
360
367
  i = value.to_int
361
- if (-2_147_483_648...2_147_483_648).cover?(i)
368
+ if Data::Int32.range.cover?(i)
362
369
  ["i", i]
363
- else
370
+ elsif Data::Int64.range.cover?(i)
364
371
  ["x", i]
372
+ else
373
+ ["t", i]
365
374
  end
366
375
  end
367
376
  end
@@ -1534,6 +1534,34 @@
1534
1534
  - [0xDE, 0xAD, 0xBE, 0xEF]
1535
1535
  exc: DBus::InvalidPacketException
1536
1536
  msg: ''
1537
+ - sig: a{oq}
1538
+ end: little
1539
+ buf:
1540
+ # body size
1541
+ - [0, 0, 0, 0]
1542
+ # padding
1543
+ - [0, 0, 0, 0]
1544
+ val: {}
1545
+ - sig: a{oq}
1546
+ end: little
1547
+ buf:
1548
+ # body size
1549
+ - [26, 0, 0, 0]
1550
+ # dict_entry padding
1551
+ - [0, 0, 0, 0]
1552
+ # key, padding, value
1553
+ - [2, 0, 0, 0, "/7", 0]
1554
+ - 0
1555
+ - [7, 0]
1556
+ # dict_entry padding
1557
+ - [0, 0, 0, 0, 0, 0]
1558
+ # key, padding, value
1559
+ - [2, 0, 0, 0, "/9", 0]
1560
+ - 0
1561
+ - [9, 0]
1562
+ val:
1563
+ /7: 7
1564
+ /9: 9
1537
1565
  - sig: "(qq)"
1538
1566
  end: little
1539
1567
  buf:
@@ -29,6 +29,13 @@ describe DBus::PacketMarshaller do
29
29
  subject.append(signature, t.val)
30
30
  expect(subject.packet).to eq(expected)
31
31
  end
32
+
33
+ it "writes a '#{signature}' with typed value #{t.val.inspect} (#{endianness})" do
34
+ subject = described_class.new(endianness: endianness)
35
+ typed_val = DBus::Data.make_typed(signature, t.val)
36
+ subject.append(signature, typed_val)
37
+ expect(subject.packet).to eq(expected)
38
+ end
32
39
  end
33
40
  end
34
41
  end
@@ -4,6 +4,14 @@
4
4
  require_relative "spec_helper"
5
5
  require "dbus"
6
6
 
7
+ # FIXME: factor out DBus::TestFixtures::Value in spec_helper
8
+ require "ostruct"
9
+ require "yaml"
10
+
11
+ data_dir = File.expand_path("data", __dir__)
12
+ marshall_yaml_s = File.read("#{data_dir}/marshall.yaml")
13
+ marshall_yaml = YAML.safe_load(marshall_yaml_s)
14
+
7
15
  describe "PropertyTest" do
8
16
  before(:each) do
9
17
  @session_bus = DBus::ASessionBus.new
@@ -168,8 +176,29 @@ describe "PropertyTest" do
168
176
 
169
177
  context "a variant-typed property" do
170
178
  it "gets read at all" do
171
- val = @iface["MyVariant"]
179
+ obj = @svc.object("/org/ruby/MyDerivedInstance")
180
+ iface = obj["org.ruby.SampleInterface"]
181
+ val = iface["MyVariant"]
172
182
  expect(val).to eq([42, 43])
173
183
  end
174
184
  end
185
+
186
+ context "marshall.yaml round-trip via a VARIANT property" do
187
+ marshall_yaml.each do |test|
188
+ t = OpenStruct.new(test)
189
+ next if t.val.nil?
190
+
191
+ # Round trips do not work yet because the properties
192
+ # must present a plain Ruby value so the exact D-Bus type is lost.
193
+ # Round trips will work once users can declare accepting DBus::Data
194
+ # in properties and method arguments.
195
+ it "Sets #{t.sig.inspect}:#{t.val.inspect} and Gets something back" do
196
+ before = DBus::Data.make_typed(t.sig, t.val)
197
+ expect { @iface["MyVariant"] = before }.to_not raise_error
198
+ expect { _after = @iface["MyVariant"] }.to_not raise_error
199
+ # round-trip:
200
+ # expect(after).to eq(before.value)
201
+ end
202
+ end
203
+ end
175
204
  end
@@ -107,10 +107,10 @@ class Test < DBus::Object
107
107
  end
108
108
  dbus_reader :explosive, "s"
109
109
 
110
- dbus_attr_reader :my_struct, "(sss)"
111
- dbus_attr_reader :my_array, "aq"
112
- dbus_attr_reader :my_dict, "a{sv}"
113
- dbus_attr_reader :my_variant, "v"
110
+ dbus_attr_accessor :my_struct, "(sss)"
111
+ dbus_attr_accessor :my_array, "aq"
112
+ dbus_attr_accessor :my_dict, "a{sv}"
113
+ dbus_attr_accessor :my_variant, "v"
114
114
  end
115
115
 
116
116
  # closing and reopening the same interface
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.beta3
4
+ version: 0.18.0.beta4
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-04-10 00:00:00.000000000 Z
11
+ date: 2022-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rexml