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 2023-10-04 22:30:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-ruby-dbus (Old) and /work/SRC/openSUSE:Factory/.rubygem-ruby-dbus.new.28202 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-ruby-dbus" Wed Oct 4 22:30:32 2023 rev:38 rq:1114915 version:0.23.1 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-ruby-dbus/rubygem-ruby-dbus.changes 2023-06-24 20:13:47.984093408 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-ruby-dbus.new.28202/rubygem-ruby-dbus.changes 2023-10-04 22:30:52.442388970 +0200 @@ -1,0 +2,10 @@ +Tue Oct 3 07:29:07 UTC 2023 - Martin Vidner <mvid...@suse.com> + +- 0.23.1 + API: + * Add DBus::Object.dbus_reader_attr_accessor to declare a common use case + with a single call (gh#mvidner/ruby-dbus#140). + * BusConnection#request_name defaults to the simple use case: single owner + without queuing, failing fast; documented the complex use cases. + +------------------------------------------------------------------- Old: ---- ruby-dbus-0.23.0.beta2.gem New: ---- ruby-dbus-0.23.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-ruby-dbus.spec ++++++ --- /var/tmp/diff_new_pack.mPtcDf/_old 2023-10-04 22:30:54.114449403 +0200 +++ /var/tmp/diff_new_pack.mPtcDf/_new 2023-10-04 22:30:54.118449549 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-ruby-dbus -Version: 0.23.0.beta2 +Version: 0.23.1 Release: 0 %define mod_name ruby-dbus %define mod_full_name %{mod_name}-%{version} ++++++ ruby-dbus-0.23.0.beta2.gem -> ruby-dbus-0.23.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/NEWS.md new/NEWS.md --- old/NEWS.md 2023-06-23 10:08:40.000000000 +0200 +++ new/NEWS.md 2023-10-03 09:47:08.000000000 +0200 @@ -2,6 +2,16 @@ ## Unreleased +## Ruby D-Bus 0.23.1 - 2023-10-03 + +API: + * Add DBus::Object.dbus_reader_attr_accessor to declare a common use case + with a single call ([#140][]). + * BusConnection#request_name defaults to the simple use case: single owner + without queuing, failing fast; documented the complex use cases. + +[#140]: https://github.com/mvidner/ruby-dbus/pull/140 + ## Ruby D-Bus 0.23.0.beta2 - 2023-06-23 License: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/VERSION new/VERSION --- old/VERSION 2023-06-23 10:08:40.000000000 +0200 +++ new/VERSION 2023-10-03 09:47:08.000000000 +0200 @@ -1 +1 @@ -0.23.0.beta2 +0.23.1 Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/examples/utils/listnames.rb new/examples/utils/listnames.rb --- old/examples/utils/listnames.rb 2023-06-23 10:08:40.000000000 +0200 +++ new/examples/utils/listnames.rb 2023-10-03 09:47:08.000000000 +0200 @@ -8,4 +8,12 @@ else DBus::SessionBus.instance end -d.proxy.ListNames[0].each { |n| puts "\t#{n}" } +d.proxy.ListNames[0].each do |n| + puts "\t#{n}" + qns = d.proxy.ListQueuedOwners(n)[0] + next if qns.size == 1 && qns.first == n + + qns.each do |qn| + puts "\t\t#{qn}" + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dbus/bus.rb new/lib/dbus/bus.rb --- old/lib/dbus/bus.rb 2023-06-23 10:08:40.000000000 +0200 +++ new/lib/dbus/bus.rb 2023-10-03 09:47:08.000000000 +0200 @@ -55,20 +55,107 @@ @proxy end + # Request a well-known name so that clients can find us. + # @note Parameters other than *name* are advanced, you probably don't need them. + # + # With no boolean flags, running a second instance of a program that calls `request_name` + # will result in the second one failing, which this library translates to an exception. + # If you want the second instance to take over, you need both + # `allow_replacement: true` and `replace_existing: true.` + # # @param name [BusName] the requested name - # @param flags [Integer] TODO: explain and add a better non-numeric API for this - # @raise NameRequestError if we could not get the name - # @example Usage + # @param replace_existing [Boolean] + # Replace an existing owner of the name, if that owner set *allow_replacement*. + # @param allow_replacement [Boolean] + # Other connections that specify *replace_existing* will be able to take + # the name from us. We will get {#on_name_lost NameLost}. If we specified *queue* + # we may get the name again, with {#on_name_acquired NameAcquired}. + # @param queue [Boolean] + # Affects the behavior when the bus denies the name (sooner or later). + # - If `false` (default), it is recommended to let the `NameRequestError` fall through and end your program. + # - If `true`, you should `rescue` the `NameRequestError` and set up + # {#on_name_acquired NameAcquired} and {#on_name_lost NameLost} handlers. + # Meanwhile, the bus will put us in a queue waiting for *name* (this is the "sooner" case). + # Also, if we had `allow_replacement: true`, another connection can cause us + # to lose the name. We will be moved back to the queue, waiting for when the other owners give up + # (the "later" case). + # @param flags [Integer,nil] + # If specified, overrides the boolean parameters. + # Use a bitwise sum `|` of: + # - NAME_FLAG_ALLOW_REPLACEMENT + # - NAME_FLAG_REPLACE_EXISTING + # - NAME_FLAG_DO_NOT_QUEUE + # Note that `0` implies `queue: true`. + # + # @return [REQUEST_NAME_REPLY_PRIMARY_OWNER,REQUEST_NAME_REPLY_ALREADY_OWNER] on success + # @raise [NameRequestError] with #error_code REQUEST_NAME_REPLY_EXISTS or REQUEST_NAME_REPLY_IN_QUEUE, on failure + # @raise DBus::Error another way to fail is being prohibited to own the name + # which is the default on the system bus + # + # @see https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-request-name + # + # @example Simple usage # bus = DBus.session_bus # bus.object_server.export(DBus::Object.new("/org/example/Test")) # bus.request_name("org.example.Test") - # @see https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-request-name - def request_name(name, flags: 0) + # # main loop + # + # @example Second instance taking over + # bus = DBus.session_bus + # bus.object_server.export(DBus::Object.new("/org/example/Test")) + # bus.on_name_lost { exit } + # bus.request_name("org.example.Test", allow_replacement: true, replace_existing: true) + # # main loop + # + # @example Second instance waiting for its turn + # bus = DBus.session_bus + # bus.object_server.export(DBus::Object.new("/org/example/Test")) + # bus.on_name_acquired { @owner = true } + # begin + # bus.request_name("org.example.Test", queue: true) + # rescue DBus::Connection::NameRequestError => e + # @owner = false + # end + # # main loop + def request_name(name, + allow_replacement: false, + replace_existing: false, + queue: false, + flags: nil) + if flags.nil? + flags = (allow_replacement ? NAME_FLAG_ALLOW_REPLACEMENT : 0) | + (replace_existing ? NAME_FLAG_REPLACE_EXISTING : 0) | + (queue ? 0 : NAME_FLAG_DO_NOT_QUEUE) + end name = BusName.new(name) r = proxy.RequestName(name, flags).first handle_return_of_request_name(r, name) end + # The caller has released his claim on the given name. + # Either the caller was the primary owner of the name, and the name is now unused + # or taken by somebody waiting in the queue for the name, + # or the caller was waiting in the queue for the name and has now been removed from the queue. + RELEASE_NAME_REPLY_RELEASED = 1 + # The given name does not exist on this bus. + RELEASE_NAME_REPLY_NON_EXISTENT = 2 + # The caller was not the primary owner of this name, and was also not waiting in the queue to own this name. + RELEASE_NAME_REPLY_NOT_OWNER = 3 + + # @param name [BusName] the name to release + def release_name(name) + name = BusName.new(name) + proxy.ReleaseName(name).first + end + + def on_name_acquired(&handler) + proxy.on_signal("NameAcquired", &handler) + end + + def on_name_lost(&handler) + proxy.on_signal("NameLost", &handler) + end + # Asks bus to send us messages matching mr, and execute slot when # received # @param match_rule [MatchRule,#to_s] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dbus/connection.rb new/lib/dbus/connection.rb --- old/lib/dbus/connection.rb 2023-06-23 10:08:40.000000000 +0200 +++ new/lib/dbus/connection.rb 2023-10-03 09:47:08.000000000 +0200 @@ -153,17 +153,30 @@ # Exception raised when a service name is requested that is not available. class NameRequestError < Exception + # @return [Integer] one of + # REQUEST_NAME_REPLY_IN_QUEUE + # REQUEST_NAME_REPLY_EXISTS + attr_reader :error_code + + def initialize(error_code) + @error_code = error_code + super() + end end + # In case RequestName did not succeed, raise an exception but first ask the bus who owns the name instead of us + # @param ret [Integer] what RequestName returned + # @param name Name that was requested + # @return [REQUEST_NAME_REPLY_PRIMARY_OWNER,REQUEST_NAME_REPLY_ALREADY_OWNER] on success + # @raise [NameRequestError] with #error_code REQUEST_NAME_REPLY_EXISTS or REQUEST_NAME_REPLY_IN_QUEUE, on failure + # @api private def handle_return_of_request_name(ret, name) - details = if ret == REQUEST_NAME_REPLY_IN_QUEUE - other = proxy.GetNameOwner(name).first - other_creds = proxy.GetConnectionCredentials(other).first - "already owned by #{other}, #{other_creds.inspect}" - else - "error code #{ret}" - end - raise NameRequestError, "Could not request #{name}, #{details}" unless ret == REQUEST_NAME_REPLY_PRIMARY_OWNER + if [REQUEST_NAME_REPLY_EXISTS, REQUEST_NAME_REPLY_IN_QUEUE].include?(ret) + other = proxy.GetNameOwner(name).first + other_creds = proxy.GetConnectionCredentials(other).first + message = "Could not request #{name}, already owned by #{other}, #{other_creds.inspect}" + raise NameRequestError.new(ret), message + end ret end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dbus/object.rb new/lib/dbus/object.rb --- old/lib/dbus/object.rb 2023-06-23 10:08:40.000000000 +0200 +++ new/lib/dbus/object.rb 2023-10-03 09:47:08.000000000 +0200 @@ -156,18 +156,32 @@ dbus_accessor(ruby_name, type, dbus_name: dbus_name, emits_changed_signal: emits_changed_signal) end + # A read-only property accessing a read-write instance variable. + # A combination of `attr_accessor` and {.dbus_reader}. + # + # @param (see .dbus_attr_accessor) + # @return (see .dbus_attr_accessor) + def self.dbus_reader_attr_accessor(ruby_name, type, dbus_name: nil, emits_changed_signal: nil) + attr_accessor(ruby_name) + + dbus_reader(ruby_name, type, dbus_name: dbus_name, emits_changed_signal: emits_changed_signal) + end + # A read-only property accessing an instance variable. # A combination of `attr_reader` and {.dbus_reader}. # + # You may be instead looking for a variant which is read-write from the Ruby side: + # {.dbus_reader_attr_accessor}. + # # Whenever the property value gets changed from "inside" the object, # you should emit the `PropertiesChanged` signal by calling # {#dbus_properties_changed}. # - # dbus_properties_changed(interface_name, {dbus_name.to_s => value}, []) + # dbus_properties_changed(interface_name, {dbus_name.to_s => value}, []) # # or, omitting the value in the signal, # - # dbus_properties_changed(interface_name, {}, [dbus_name.to_s]) + # dbus_properties_changed(interface_name, {}, [dbus_name.to_s]) # # @param (see .dbus_attr_accessor) # @return (see .dbus_attr_accessor) @@ -213,18 +227,22 @@ # implement it with a read-write attr_accessor. In that case this method # uses {.dbus_watcher} to set up the PropertiesChanged signal. # - # attr_accessor :foo_bar - # dbus_reader :foo_bar, "s" + # attr_accessor :foo_bar + # dbus_reader :foo_bar, "s" + # + # The above two declarations have a shorthand: + # + # dbus_reader_attr_accessor :foo_bar, "s" # # If the property value should change by other means than its attr_writer, # you should emit the `PropertiesChanged` signal by calling # {#dbus_properties_changed}. # - # dbus_properties_changed(interface_name, {dbus_name.to_s => value}, []) + # dbus_properties_changed(interface_name, {dbus_name.to_s => value}, []) # # or, omitting the value in the signal, # - # dbus_properties_changed(interface_name, {}, [dbus_name.to_s]) + # dbus_properties_changed(interface_name, {}, [dbus_name.to_s]) # # @param (see .dbus_attr_accessor) # @return (see .dbus_attr_accessor) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2023-06-23 10:08:40.000000000 +0200 +++ new/metadata 2023-10-03 09:47:08.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: ruby-dbus version: !ruby/object:Gem::Version - version: 0.23.0.beta2 + version: 0.23.1 platform: ruby authors: - Ruby DBus Team autorequire: bindir: bin cert_chain: [] -date: 2023-06-23 00:00:00.000000000 Z +date: 2023-10-03 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rexml @@ -235,9 +235,9 @@ version: 2.4.0 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - - ">" + - - ">=" - !ruby/object:Gem::Version - version: 1.3.1 + version: '0' requirements: [] rubygems_version: 3.3.26 signing_key: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/bus_connection_spec.rb new/spec/bus_connection_spec.rb --- old/spec/bus_connection_spec.rb 2023-06-23 10:08:40.000000000 +0200 +++ new/spec/bus_connection_spec.rb 2023-10-03 09:47:08.000000000 +0200 @@ -21,7 +21,6 @@ end context "when the name is taken already", tag_service: true do - # formerly it returned Service, now ObjectServer takes its role it "raises NameRequestError... too late" do name = "org.ruby.service" expect do @@ -50,21 +49,35 @@ describe "#request_name", tag_bus: true do context "when the name request succeeds" do - it "returns something which can export objects" do + it "returns a success code" do name = "org.rubygems.ruby_dbus.RequestNameTest" - expect { bus.request_name(name) }.to_not raise_error - bus.proxy.ReleaseName(name) + expect(bus.request_name(name)).to eq DBus::Connection::REQUEST_NAME_REPLY_PRIMARY_OWNER + # second time, considered also a success + expect(bus.request_name(name)).to eq DBus::Connection::REQUEST_NAME_REPLY_ALREADY_OWNER + bus.release_name(name) end end context "when the name is taken already", tag_service: true do - # formerly it returned Service, now ObjectServer takes its role it "raises NameRequestError" do name = "org.ruby.service" expect do - # flags: avoid getting the name sometime later, unexpectedly - bus.request_name(name, flags: DBus::Connection::NAME_FLAG_DO_NOT_QUEUE) + bus.request_name(name) + end.to raise_error(DBus::Connection::NameRequestError) + end + end + + context "when the name is taken already but we request queuing", tag_service: true do + it "raises NameRequestError but we are queued" do + name = "org.ruby.service" + owning = nil + # TODO: we do not expect the handlers to run + bus.on_name_acquired { owning = true } + bus.on_name_lost { owning = false } + expect do + bus.request_name(name, queue: true) end.to raise_error(DBus::Connection::NameRequestError) + expect(bus.release_name(name)).to eq DBus::BusConnection::RELEASE_NAME_REPLY_RELEASED end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spec/mock-service/spaghetti-monster.rb new/spec/mock-service/spaghetti-monster.rb --- old/spec/mock-service/spaghetti-monster.rb 2023-06-23 10:08:40.000000000 +0200 +++ new/spec/mock-service/spaghetti-monster.rb 2023-10-03 09:47:08.000000000 +0200 @@ -23,7 +23,7 @@ end dbus_interface "org.ruby.TestChild" do - dbus_attr_reader :name, "s" + dbus_reader_attr_accessor :name, "s" end end