Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package rubygem-ruby-dbus for
openSUSE:Factory checked in at 2022-05-30 12:42:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-ruby-dbus (Old)
and /work/SRC/openSUSE:Factory/.rubygem-ruby-dbus.new.2254 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-ruby-dbus"
Mon May 30 12:42:02 2022 rev:29 rq:979643 version:0.18.0.beta7
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-ruby-dbus/rubygem-ruby-dbus.changes
2022-05-26 18:44:06.085180859 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-ruby-dbus.new.2254/rubygem-ruby-dbus.changes
2022-05-30 12:42:14.760254430 +0200
@@ -1,0 +2,12 @@
+Sun May 29 08:24:04 UTC 2022 - Martin Vidner <[email protected]>
+
+- 0.18.0.beta7
+ API:
+ * DBus.variant(type, value) is deprecated in favor of
+ Data::Variant.new(value, member_type:)
+
+ Bug fixes:
+ * Client-side properties: When calling Properties.Set in
+ ProxyObjectInterface#[]=, use the correct type (gh#mvidner/ruby-dbus#108).
+
+-------------------------------------------------------------------
Old:
----
ruby-dbus-0.18.0.beta6.gem
New:
----
ruby-dbus-0.18.0.beta7.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-ruby-dbus.spec ++++++
--- /var/tmp/diff_new_pack.4Au8fn/_old 2022-05-30 12:42:15.352255218 +0200
+++ /var/tmp/diff_new_pack.4Au8fn/_new 2022-05-30 12:42:15.360255228 +0200
@@ -24,7 +24,7 @@
#
Name: rubygem-ruby-dbus
-Version: 0.18.0.beta6
+Version: 0.18.0.beta7
Release: 0
%define mod_name ruby-dbus
%define mod_full_name %{mod_name}-%{version}
++++++ ruby-dbus-0.18.0.beta6.gem -> ruby-dbus-0.18.0.beta7.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/NEWS.md new/NEWS.md
--- old/NEWS.md 2022-05-25 15:29:26.000000000 +0200
+++ new/NEWS.md 2022-05-29 10:48:54.000000000 +0200
@@ -2,6 +2,18 @@
## Unreleased
+## Ruby D-Bus 0.18.0.beta7 - 2022-05-29
+
+API:
+ * DBus.variant(type, value) is deprecated in favor of
+ Data::Variant.new(value, member_type:)
+
+Bug fixes:
+ * Client-side properties: When calling Properties.Set in
+ ProxyObjectInterface#[]=, use the correct type ([#108][]).
+
+[#108]: https://github.com/mvidner/ruby-dbus/issues/108
+
## Ruby D-Bus 0.18.0.beta6 - 2022-05-25
API:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/VERSION new/VERSION
--- old/VERSION 2022-05-25 15:29:26.000000000 +0200
+++ new/VERSION 2022-05-29 10:48:54.000000000 +0200
@@ -1 +1 @@
-0.18.0.beta6
+0.18.0.beta7
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/doc/Reference.md new/doc/Reference.md
--- old/doc/Reference.md 2022-05-25 15:29:26.000000000 +0200
+++ new/doc/Reference.md 2022-05-29 10:48:54.000000000 +0200
@@ -166,12 +166,21 @@
which D-Bus type to choose. Most of the time the choice is dictated
by the D-Bus signature.
+For exact representation of D-Bus data types, use subclasses
+of {DBus::Data::Base}, such as {DBus::Data::Int16} or {DBus::Data::UInt64}.
+
##### Variants
If the signature expects a Variant
(which is the case for all Properties!) then an explicit mechanism is needed.
-1. A pair [{DBus::Type}, value] specifies to marshall *value* as
+1. Any {DBus::Data::Base}.
+
+2. A {DBus::Data::Variant} made by {DBus.variant}(signature, value).
+ (Formerly this produced the type+value pair below, now it is just an alias
+ to the Variant constructor.)
+
+3. A pair [{DBus::Type}, value] specifies to marshall *value* as
that specified type.
The pair can be produced by {DBus.variant}(signature, value) which
gives the same result as [{DBus.type}(signature), value].
@@ -181,13 +190,13 @@
`foo_i["Bar"] = DBus.variant("au", [0, 1, 1, 2, 3, 5, 8])`
-2. Other values are tried to fit one of these:
+4. Other values are tried to fit one of these:
Boolean, Double, Array of Variants, Hash of String keyed Variants,
String, Int32, Int64.
-3. **Deprecated:** A pair [String, value], where String is a valid
+5. **Deprecated:** A pair [String, value], where String is a valid
signature of a single complete type, marshalls value as that
- type. This will hit you when you rely on method (2) but happen to have
+ type. This will hit you when you rely on method (4) but happen to have
a particular string value in an array.
##### Structs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dbus/data.rb new/lib/dbus/data.rb
--- old/lib/dbus/data.rb 2022-05-25 15:29:26.000000000 +0200
+++ new/lib/dbus/data.rb 2022-05-29 10:48:54.000000000 +0200
@@ -601,8 +601,10 @@
typed_value = case value
when Data::Array
- raise ArgumentError, "Specified type is #{type} but
value type is #{value.type}" \
- unless value.type == type
+ unless value.type == type
+ raise ArgumentError,
+ "Specified type is #{type.inspect} but value
type is #{value.type.inspect}"
+ end
value.exact_value
else
@@ -651,8 +653,10 @@
typed_value = case value
when self.class
- raise ArgumentError, "Specified type is #{type} but
value type is #{value.type}" \
- unless value.type == type
+ unless value.type == type
+ raise ArgumentError,
+ "Specified type is #{type.inspect} but value
type is #{value.type.inspect}"
+ end
value.exact_value
else
@@ -751,13 +755,19 @@
# @return [Type]
attr_reader :member_type
+ # Determine the type of *value*
+ # @param value [::Object]
+ # @return [Type]
+ # @api private
+ # See also {PacketMarshaller.make_variant}
def self.guess_type(value)
sct, = PacketMarshaller.make_variant(value)
DBus.type(sct)
end
- # @param member_type [Type,nil]
+ # @param member_type [SingleCompleteType,Type,nil]
def initialize(value, member_type:)
+ member_type = Type::Factory.make_type(member_type) if member_type
# TODO: validate that the given *member_type* matches *value*
case value
when Data::Variant
@@ -775,6 +785,30 @@
end
super(value)
end
+
+ # Internal helpers to keep the {DBus.variant} method working.
+ # Formerly it returned just a pair of [DBus.type(string_type), value]
+ # so let's provide [0], [1], .first, .last
+ def [](index)
+ case index
+ when 0
+ member_type
+ when 1
+ value
+ else
+ raise ArgumentError, "DBus.variant can only be indexed with 0 or 1,
seen #{index.inspect}"
+ end
+ end
+
+ # @see #[]
+ def first
+ self[0]
+ end
+
+ # @see #[]
+ def last
+ self[1]
+ end
end
consts = constants.map { |c_sym| const_get(c_sym) }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dbus/introspect.rb new/lib/dbus/introspect.rb
--- old/lib/dbus/introspect.rb 2022-05-25 15:29:26.000000000 +0200
+++ new/lib/dbus/introspect.rb 2022-05-29 10:48:54.000000000 +0200
@@ -238,19 +238,20 @@
# An (exported) property
#
https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties
class Property
- # @return [String] The name of the property, for example FooBar.
+ # @return [Symbol] The name of the property, for example FooBar.
attr_reader :name
# @return [SingleCompleteType]
attr_reader :type
# @return [Symbol] :read :write or :readwrite
attr_reader :access
- # @return [Symbol] What to call at Ruby side.
+ # @return [Symbol,nil] What to call at Ruby side.
# (Always without the trailing `=`)
+ # It is `nil` IFF representing a client-side proxy.
attr_reader :ruby_name
def initialize(name, type, access, ruby_name:)
- @name = name
+ @name = name.to_sym
@type = type
@access = access
@ruby_name = ruby_name
@@ -270,5 +271,14 @@
def to_xml
" <property type=\"#{@type}\" name=\"#{@name}\"
access=\"#{@access}\"/>\n"
end
+
+ # @param xml_node [AbstractXML::Node]
+ # @return [Property]
+ def self.from_xml(xml_node)
+ name = xml_node["name"].to_sym
+ type = xml_node["type"]
+ access = xml_node["access"].to_sym
+ new(name, type, access, ruby_name: nil)
+ end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dbus/proxy_object_factory.rb
new/lib/dbus/proxy_object_factory.rb
--- old/lib/dbus/proxy_object_factory.rb 2022-05-25 15:29:26.000000000
+0200
+++ new/lib/dbus/proxy_object_factory.rb 2022-05-29 10:48:54.000000000
+0200
@@ -29,11 +29,13 @@
# @param pobj [ProxyObject]
# @param xml [String]
def self.introspect_into(pobj, xml)
+ # intfs [Array<Interface>], subnodes [Array<String>]
intfs, pobj.subnodes = IntrospectXMLParser.new(xml).parse
intfs.each do |i|
poi = ProxyObjectInterface.new(pobj, i.name)
i.methods.each_value { |m| poi.define(m) }
i.signals.each_value { |s| poi.define(s) }
+ i.properties.each_value { |p| poi.define(p) }
pobj[i.name] = poi
end
pobj.introspected = true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dbus/proxy_object_interface.rb
new/lib/dbus/proxy_object_interface.rb
--- old/lib/dbus/proxy_object_interface.rb 2022-05-25 15:29:26.000000000
+0200
+++ new/lib/dbus/proxy_object_interface.rb 2022-05-29 10:48:54.000000000
+0200
@@ -15,13 +15,16 @@
# A class similar to the normal Interface used as a proxy for remote
# object interfaces.
class ProxyObjectInterface
- # The proxied methods contained in the interface.
- attr_accessor :methods
- # The proxied signals contained in the interface.
- attr_accessor :signals
- # The proxy object to which this interface belongs.
+ # @return [Hash{String => DBus::Method}]
+ attr_reader :methods
+ # @return [Hash{String => Signal}]
+ attr_reader :signals
+ # @return [Hash{Symbol => Property}]
+ attr_reader :properties
+
+ # @return [ProxyObject] The proxy object to which this interface belongs.
attr_reader :object
- # The name of the interface.
+ # @return [String] The name of the interface.
attr_reader :name
# Creates a new proxy interface for the given proxy _object_
@@ -31,6 +34,7 @@
@name = name
@methods = {}
@signals = {}
+ @properties = {}
end
# Returns the string representation of the interface (the name).
@@ -81,13 +85,21 @@
@signals[sig.name] = sig
end
+ # @param prop [Property]
+ def define_property_from_descriptor(prop)
+ @properties[prop.name] = prop
+ end
+
# Defines a signal or method based on the descriptor _ifc_el_.
+ # @param ifc_el [DBus::Method,Signal,Property]
def define(ifc_el)
case ifc_el
when Method
define_method_from_descriptor(ifc_el)
when Signal
define_signal_from_descriptor(ifc_el)
+ when Property
+ define_property_from_descriptor(ifc_el)
end
end
@@ -129,10 +141,26 @@
end
# Write a property.
- # @param propname [String]
+ # @param property_name [String]
# @param value [Object]
- def []=(propname, value)
- object[PROPERTY_INTERFACE].Set(name, propname, value)
+ def []=(property_name, value)
+ property = properties[property_name.to_sym]
+ if !property
+ raise DBus.error("org.freedesktop.DBus.Error.UnknownProperty"),
+ "Property '#{name}.#{property_name}' (on object
'#{object.path}') not found"
+ end
+
+ case value
+ # accommodate former need to explicitly make a variant with the right
type
+ when Data::Variant
+ variant = value
+ else
+ type = property.type
+ typed_value = Data.make_typed(type, value)
+ variant = Data::Variant.new(typed_value, member_type: type)
+ end
+
+ object[PROPERTY_INTERFACE].Set(name, property_name, variant)
end
# Read all properties at once, as a hash.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dbus/type.rb new/lib/dbus/type.rb
--- old/lib/dbus/type.rb 2022-05-25 15:29:26.000000000 +0200
+++ new/lib/dbus/type.rb 2022-05-29 10:48:54.000000000 +0200
@@ -415,8 +415,9 @@
# @param string_type [SingleCompleteType]
# @param value [::Object]
# @return [Array(DBus::Type::Type,::Object)]
+ # @deprecated Use {Data::Variant.new} instead
def variant(string_type, value)
- [type(string_type), value]
+ Data::Variant.new(value, member_type: string_type)
end
module_function :variant
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dbus/xml.rb new/lib/dbus/xml.rb
--- old/lib/dbus/xml.rb 2022-05-25 15:29:26.000000000 +0200
+++ new/lib/dbus/xml.rb 2022-05-29 10:48:54.000000000 +0200
@@ -134,6 +134,10 @@
parse_methsig(se, s)
i << s
end
+ e.each("property") do |pe|
+ p = Property.from_xml(pe)
+ i << p
+ end
end
d = Time.now - t
if d > 2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2022-05-25 15:29:26.000000000 +0200
+++ new/metadata 2022-05-29 10:48:54.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: ruby-dbus
version: !ruby/object:Gem::Version
- version: 0.18.0.beta6
+ version: 0.18.0.beta7
platform: ruby
authors:
- Ruby DBus Team
autorequire:
bindir: bin
cert_chain: []
-date: 2022-05-25 00:00:00.000000000 Z
+date: 2022-05-29 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rexml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/data_spec.rb new/spec/data_spec.rb
--- old/spec/data_spec.rb 2022-05-25 15:29:26.000000000 +0200
+++ new/spec/data_spec.rb 2022-05-29 10:48:54.000000000 +0200
@@ -193,7 +193,7 @@
describe "#initialize" do
bad_list.each do |(value, exc_class, msg_substr)|
it "rejects #{value.inspect} with #{exc_class}: #{msg_substr}" do
- msg_re = Regexp.new(Regexp.quote(msg_substr))
+ msg_re = Regexp.try_convert(msg_substr) ||
Regexp.new(Regexp.quote(msg_substr))
expect { described_class.new(value) }.to raise_error(exc_class, msg_re)
end
end
@@ -204,7 +204,7 @@
describe "#initialize" do
bad_list.each do |(value, kwargs_hash, exc_class, msg_substr)|
it "rejects #{value.inspect}, #{kwargs_hash.inspect} with #{exc_class}:
#{msg_substr}" do
- msg_re = Regexp.new(Regexp.quote(msg_substr))
+ msg_re = Regexp.try_convert(msg_substr) ||
Regexp.new(Regexp.quote(msg_substr))
expect { described_class.new(value, **kwargs_hash) }.to
raise_error(exc_class, msg_re)
end
end
@@ -387,8 +387,9 @@
describe "containers" do
describe DBus::Data::Array do
+ aq = DBus::Data::Array.new([1, 2, 3], type: "aq")
+
good = [
- # [[1, 2, 3], type: nil],
[[1, 2, 3], { type: "aq" }],
[[1, 2, 3], { type: T::Array[T::UINT16] }],
[[1, 2, 3], { type: T::Array["q"] }],
@@ -398,9 +399,14 @@
bad = [
# undesirable type guessing
- ## [[1, 2, 3], { type: nil }, DBus::InvalidPacketException, "Unknown
type code"],
- ## [[1, 2, 3], { type: "!" }, DBus::InvalidPacketException, "Unknown
type code"]
- # TODO: others
+ [[1, 2, 3], { type: nil }, ArgumentError, /Expecting DBus::Type.*got
nil/],
+ [[1, 2, 3], { type: "!" }, DBus::Type::SignatureException, "Unknown
type code"],
+ [aq, { type: "q" }, ArgumentError, "Expecting \"a\""],
+ [aq, { type: "ao" }, ArgumentError,
+ "Specified type is ARRAY: [OBJECT_PATH] but value type is ARRAY:
[UINT16]"]
+ # TODO: how to handle these?
+ # [{1 => 2, 3 => 4}, { type: "aq" }, ArgumentError, "?"],
+ # [/i am not an array/, { type: "aq" }, ArgumentError, "?"],
]
include_examples "#== and #eql? work for container types (inequal)",
@@ -506,7 +512,7 @@
value2 = result1
type2 = "(xxx)"
expect { described_class.new(value2, type: type2) }
- .to raise_error(ArgumentError, /value type is .uuu./)
+ .to raise_error(ArgumentError, /value type is STRUCT.*UINT32/)
end
it "checks that size of type and value match" do
@@ -553,7 +559,7 @@
value2 = result1
type2 = T::Hash[T::UINT64, T::UINT64].child
expect { described_class.new(value2, type: type2) }
- .to raise_error(ArgumentError, /value type is .uu./)
+ .to raise_error(ArgumentError, /value type is DICT_ENTRY.*UINT32/)
end
it "checks that size of type and value match" do
@@ -632,6 +638,36 @@
include_examples "#== and #eql? work for container types (1 value)",
"/foo", { member_type: DBus.type(T::STRING) }
+
+ describe "DBus.variant compatibility" do
+ let(:v) { DBus.variant("o", "/foo") }
+
+ describe "#[]" do
+ it "returns the type for 0" do
+ expect(v[0]).to eq DBus.type(DBus::Type::OBJECT_PATH)
+ end
+
+ it "returns the value for 1" do
+ expect(v[1]).to eq DBus::ObjectPath.new("/foo")
+ end
+
+ it "returns an error for other indices" do
+ expect { v[2] }.to raise_error(ArgumentError, /DBus.variant can
only be indexed with 0 or 1/)
+ end
+ end
+
+ describe "#first" do
+ it "returns the type" do
+ expect(v.first).to eq DBus.type(DBus::Type::OBJECT_PATH)
+ end
+ end
+
+ describe "#last" do
+ it "returns the value" do
+ expect(v.last).to eq DBus::ObjectPath.new("/foo")
+ end
+ end
+ end
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/property_spec.rb new/spec/property_spec.rb
--- old/spec/property_spec.rb 2022-05-25 15:29:26.000000000 +0200
+++ new/spec/property_spec.rb 2022-05-29 10:48:54.000000000 +0200
@@ -60,7 +60,7 @@
it "tests get all" do
all = @iface.all_properties
- expect(all.keys.sort).to eq(["MyArray", "MyDict", "MyStruct", "MyVariant",
"ReadMe", "ReadOrWriteMe"])
+ expect(all.keys.sort).to eq(["MyArray", "MyByte", "MyDict", "MyStruct",
"MyVariant", "ReadMe", "ReadOrWriteMe"])
end
it "tests get all on a V1 object" do
@@ -68,7 +68,7 @@
iface = obj["org.ruby.SampleInterface"]
all = iface.all_properties
- expect(all.keys.sort).to eq(["MyArray", "MyDict", "MyStruct", "MyVariant",
"ReadMe", "ReadOrWriteMe"])
+ expect(all.keys.sort).to eq(["MyArray", "MyByte", "MyDict", "MyStruct",
"MyVariant", "ReadMe", "ReadOrWriteMe"])
end
it "tests unknown property reading" do
@@ -200,6 +200,36 @@
end
end
+ context "a byte-typed property" do
+ # Slightly advanced RSpec:
+ #
https://rspec.info/documentation/3.9/rspec-expectations/RSpec/Matchers.html#satisfy-instance_method
+ let(:a_byte_in_a_variant) do
+ satisfying { |x| x.is_a?(DBus::Data::Variant) && x.member_type.to_s ==
DBus::Type::BYTE }
+ # ^ This formatting keeps the matcher on a single line
+ # which enables RSpect to cite it if it fails, instead of saying "block".
+ end
+
+ let(:prop_iface) { @obj[DBus::PROPERTY_INTERFACE] }
+
+ it "gets set with a correct type (#108)" do
+ expect(prop_iface).to receive(:Set).with(
+ "org.ruby.SampleInterface",
+ "MyByte",
+ a_byte_in_a_variant
+ )
+ @iface["MyByte"] = 1
+ end
+
+ it "gets set with a correct type (#108), when using the DBus.variant
workaround" do
+ expect(prop_iface).to receive(:Set).with(
+ "org.ruby.SampleInterface",
+ "MyByte",
+ a_byte_in_a_variant
+ )
+ @iface["MyByte"] = DBus.variant("y", 1)
+ end
+ end
+
context "marshall.yaml round-trip via a VARIANT property" do
marshall_yaml.each do |test|
t = OpenStruct.new(test)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/service_newapi.rb new/spec/service_newapi.rb
--- old/spec/service_newapi.rb 2022-05-25 15:29:26.000000000 +0200
+++ new/spec/service_newapi.rb 2022-05-29 10:48:54.000000000 +0200
@@ -28,6 +28,8 @@
"three" => [3, 3, 3]
}
@my_variant = @my_array.dup
+ # 201 is a RET instruction for ZX Spectrum which has turned 40 recently
+ @my_byte = 201
@main_loop = nil
end
@@ -111,6 +113,8 @@
dbus_attr_accessor :my_array, "aq"
dbus_attr_accessor :my_dict, "a{sv}"
dbus_attr_accessor :my_variant, "v"
+
+ dbus_attr_accessor :my_byte, "y"
end
# closing and reopening the same interface