ruby-dbus 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +8 -0
- data/VERSION +1 -1
- data/lib/dbus.rb +0 -1
- data/lib/dbus/bus.rb +3 -2
- data/lib/dbus/export.rb +24 -2
- data/lib/dbus/introspect.rb +2 -2
- data/test/async_test.rb +47 -0
- data/test/service_newapi.rb +0 -1
- metadata +6 -10
- data/lib/dbus/core_ext/class/attribute.rb +0 -91
- data/lib/dbus/core_ext/kernel/singleton_class.rb +0 -14
- data/lib/dbus/core_ext/module/remove_method.rb +0 -12
data/NEWS
CHANGED
@@ -5,6 +5,14 @@ Note about bug numbers:
|
|
5
5
|
Issue#1 - http://github.com/mvidner/ruby-dbus/issues#issue/1
|
6
6
|
bnc#1 - https://bugzilla.novell.com/show_bug.cgi?id=1
|
7
7
|
|
8
|
+
== Ruby D-Bus 0.7.1 - 2012-04-04
|
9
|
+
|
10
|
+
Bug fixes:
|
11
|
+
* Fixed calling asynchronous methods on the default interface (Issue#13,
|
12
|
+
by Eugene Korbut).
|
13
|
+
* Fixed Main#quit to really quit the loop (by Josef Reidinger)
|
14
|
+
* Unbundled files from Active Support (by Bohuslav Kabrda)
|
15
|
+
|
8
16
|
== Ruby D-Bus 0.7.0 - 2011-07-26
|
9
17
|
|
10
18
|
Features:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.1
|
data/lib/dbus.rb
CHANGED
data/lib/dbus/bus.rb
CHANGED
@@ -827,8 +827,9 @@ module DBus
|
|
827
827
|
end
|
828
828
|
end
|
829
829
|
while not @quitting and not @buses.empty?
|
830
|
-
ready
|
831
|
-
ready
|
830
|
+
ready = IO.select(@buses.keys,[],[],5) #timeout 5 seconds
|
831
|
+
continue unless ready #timeout exceed so continue unless quitting
|
832
|
+
ready.first.each do |socket|
|
832
833
|
b = @buses[socket]
|
833
834
|
begin
|
834
835
|
b.update_buffer
|
data/lib/dbus/export.rb
CHANGED
@@ -19,8 +19,10 @@ module DBus
|
|
19
19
|
class Object
|
20
20
|
# The path of the object.
|
21
21
|
attr_reader :path
|
22
|
-
# The interfaces that the object supports.
|
23
|
-
|
22
|
+
# The interfaces that the object supports.
|
23
|
+
# intfs: Hash: String => Interface
|
24
|
+
# @@intfs_hash simulates a class attribute by being a hash Class => intfs
|
25
|
+
@@intfs_hash = {DBus::Object => nil}
|
24
26
|
# The service that the object is exported by.
|
25
27
|
attr_writer :service
|
26
28
|
|
@@ -34,6 +36,26 @@ module DBus
|
|
34
36
|
@service = nil
|
35
37
|
end
|
36
38
|
|
39
|
+
def self.intfs
|
40
|
+
if self.equal? DBus::Object
|
41
|
+
@@intfs_hash[DBus::Object]
|
42
|
+
else
|
43
|
+
@@intfs_hash[self] || self.superclass.intfs
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.intfs= param
|
48
|
+
@@intfs_hash[self] = param
|
49
|
+
end
|
50
|
+
|
51
|
+
def intfs
|
52
|
+
self.class.intfs
|
53
|
+
end
|
54
|
+
|
55
|
+
def intfs= param
|
56
|
+
self.class.intfs = param
|
57
|
+
end
|
58
|
+
|
37
59
|
# State that the object implements the given _intf_.
|
38
60
|
def implements(intf)
|
39
61
|
# use a setter
|
data/lib/dbus/introspect.rb
CHANGED
@@ -497,10 +497,10 @@ module DBus
|
|
497
497
|
|
498
498
|
# Handles all unkown methods, mostly to route method calls to the
|
499
499
|
# default interface.
|
500
|
-
def method_missing(name, *args)
|
500
|
+
def method_missing(name, *args, &reply_handler)
|
501
501
|
if @default_iface and has_iface?(@default_iface)
|
502
502
|
begin
|
503
|
-
@interfaces[@default_iface].method(name).call(*args)
|
503
|
+
@interfaces[@default_iface].method(name).call(*args, &reply_handler)
|
504
504
|
rescue NameError => e
|
505
505
|
# interesting, foo.method("unknown")
|
506
506
|
# raises NameError, not NoMethodError
|
data/test/async_test.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Test the binding of dbus concepts to ruby concepts
|
3
|
+
require "test/unit"
|
4
|
+
require "dbus"
|
5
|
+
|
6
|
+
class AsyncTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@bus = DBus::ASessionBus.new
|
9
|
+
@svc = @bus.service("org.ruby.service")
|
10
|
+
@obj = @svc.object "/org/ruby/MyInstance"
|
11
|
+
@obj.introspect
|
12
|
+
@obj.default_iface = "org.ruby.SampleInterface"
|
13
|
+
end
|
14
|
+
|
15
|
+
# https://github.com/mvidner/ruby-dbus/issues/13
|
16
|
+
def test_async_call_to_default_interface
|
17
|
+
loop = DBus::Main.new
|
18
|
+
loop << @bus
|
19
|
+
|
20
|
+
immediate_answer = @obj.the_answer do |msg, retval|
|
21
|
+
assert_equal 42, retval
|
22
|
+
loop.quit
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_nil immediate_answer
|
26
|
+
|
27
|
+
# wait for the async reply
|
28
|
+
loop.run
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_async_call_to_explicit_interface
|
32
|
+
loop = DBus::Main.new
|
33
|
+
loop << @bus
|
34
|
+
|
35
|
+
ifc = @obj["org.ruby.AnotherInterface"]
|
36
|
+
immediate_answer = ifc.Reverse("abcd") do |msg, retval|
|
37
|
+
assert_equal "dcba", retval
|
38
|
+
loop.quit
|
39
|
+
end
|
40
|
+
|
41
|
+
assert_nil immediate_answer
|
42
|
+
|
43
|
+
# wait for the async reply
|
44
|
+
loop.run
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/test/service_newapi.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-dbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ruby DBus Team
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-04-04 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description:
|
@@ -48,9 +47,6 @@ files:
|
|
48
47
|
- lib/dbus.rb
|
49
48
|
- lib/dbus/auth.rb
|
50
49
|
- lib/dbus/bus.rb
|
51
|
-
- lib/dbus/core_ext/class/attribute.rb
|
52
|
-
- lib/dbus/core_ext/kernel/singleton_class.rb
|
53
|
-
- lib/dbus/core_ext/module/remove_method.rb
|
54
50
|
- lib/dbus/error.rb
|
55
51
|
- lib/dbus/export.rb
|
56
52
|
- lib/dbus/introspect.rb
|
@@ -59,6 +55,7 @@ files:
|
|
59
55
|
- lib/dbus/message.rb
|
60
56
|
- lib/dbus/type.rb
|
61
57
|
- ruby-dbus.gemspec
|
58
|
+
- test/async_test.rb
|
62
59
|
- test/binding_test.rb
|
63
60
|
- test/bus_driver_test.rb
|
64
61
|
- test/bus_test.rb
|
@@ -82,7 +79,6 @@ files:
|
|
82
79
|
- COPYING
|
83
80
|
- README
|
84
81
|
- NEWS
|
85
|
-
has_rdoc: true
|
86
82
|
homepage: https://trac.luon.net/ruby-dbus
|
87
83
|
licenses:
|
88
84
|
- LGPL v2.1
|
@@ -114,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
110
|
requirements: []
|
115
111
|
|
116
112
|
rubyforge_project:
|
117
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.8.15
|
118
114
|
signing_key:
|
119
115
|
specification_version: 3
|
120
116
|
summary: Ruby module for interaction with D-Bus
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# copied from activesupport/core_ext from Rails, MIT license
|
2
|
-
require 'dbus/core_ext/kernel/singleton_class'
|
3
|
-
require 'dbus/core_ext/module/remove_method'
|
4
|
-
|
5
|
-
class Class
|
6
|
-
# Declare a class-level attribute whose value is inheritable by subclasses.
|
7
|
-
# Subclasses can change their own value and it will not impact parent class.
|
8
|
-
#
|
9
|
-
# class Base
|
10
|
-
# class_attribute :setting
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# class Subclass < Base
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# Base.setting = true
|
17
|
-
# Subclass.setting # => true
|
18
|
-
# Subclass.setting = false
|
19
|
-
# Subclass.setting # => false
|
20
|
-
# Base.setting # => true
|
21
|
-
#
|
22
|
-
# In the above case as long as Subclass does not assign a value to setting
|
23
|
-
# by performing <tt>Subclass.setting = _something_ </tt>, <tt>Subclass.setting</tt>
|
24
|
-
# would read value assigned to parent class. Once Subclass assigns a value then
|
25
|
-
# the value assigned by Subclass would be returned.
|
26
|
-
#
|
27
|
-
# This matches normal Ruby method inheritance: think of writing an attribute
|
28
|
-
# on a subclass as overriding the reader method. However, you need to be aware
|
29
|
-
# when using +class_attribute+ with mutable structures as +Array+ or +Hash+.
|
30
|
-
# In such cases, you don't want to do changes in places but use setters:
|
31
|
-
#
|
32
|
-
# Base.setting = []
|
33
|
-
# Base.setting # => []
|
34
|
-
# Subclass.setting # => []
|
35
|
-
#
|
36
|
-
# # Appending in child changes both parent and child because it is the same object:
|
37
|
-
# Subclass.setting << :foo
|
38
|
-
# Base.setting # => [:foo]
|
39
|
-
# Subclass.setting # => [:foo]
|
40
|
-
#
|
41
|
-
# # Use setters to not propagate changes:
|
42
|
-
# Base.setting = []
|
43
|
-
# Subclass.setting += [:foo]
|
44
|
-
# Base.setting # => []
|
45
|
-
# Subclass.setting # => [:foo]
|
46
|
-
#
|
47
|
-
# For convenience, a query method is defined as well:
|
48
|
-
#
|
49
|
-
# Subclass.setting? # => false
|
50
|
-
#
|
51
|
-
# Instances may overwrite the class value in the same way:
|
52
|
-
#
|
53
|
-
# Base.setting = true
|
54
|
-
# object = Base.new
|
55
|
-
# object.setting # => true
|
56
|
-
# object.setting = false
|
57
|
-
# object.setting # => false
|
58
|
-
# Base.setting # => true
|
59
|
-
#
|
60
|
-
# To opt out of the instance writer method, pass :instance_writer => false.
|
61
|
-
#
|
62
|
-
# object.setting = false # => NoMethodError
|
63
|
-
def class_attribute(*attrs)
|
64
|
-
instance_writer = !attrs.last.is_a?(Hash) || attrs.pop[:instance_writer]
|
65
|
-
|
66
|
-
attrs.each do |name|
|
67
|
-
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
68
|
-
def self.#{name}() nil end
|
69
|
-
def self.#{name}?() !!#{name} end
|
70
|
-
|
71
|
-
def self.#{name}=(val)
|
72
|
-
singleton_class.class_eval do
|
73
|
-
remove_possible_method(:#{name})
|
74
|
-
define_method(:#{name}) { val }
|
75
|
-
end
|
76
|
-
val
|
77
|
-
end
|
78
|
-
|
79
|
-
def #{name}
|
80
|
-
defined?(@#{name}) ? @#{name} : singleton_class.#{name}
|
81
|
-
end
|
82
|
-
|
83
|
-
def #{name}?
|
84
|
-
!!#{name}
|
85
|
-
end
|
86
|
-
RUBY
|
87
|
-
|
88
|
-
attr_writer name if instance_writer
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# copied from activesupport/core_ext from Rails, MIT license
|
2
|
-
module Kernel
|
3
|
-
# Returns the object's singleton class.
|
4
|
-
def singleton_class
|
5
|
-
class << self
|
6
|
-
self
|
7
|
-
end
|
8
|
-
end unless respond_to?(:singleton_class) # exists in 1.9.2
|
9
|
-
|
10
|
-
# class_eval on an object acts like singleton_class.class_eval.
|
11
|
-
def class_eval(*args, &block)
|
12
|
-
singleton_class.class_eval(*args, &block)
|
13
|
-
end
|
14
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# copied from activesupport/core_ext from Rails, MIT license
|
2
|
-
class Module
|
3
|
-
def remove_possible_method(method)
|
4
|
-
remove_method(method)
|
5
|
-
rescue NameError
|
6
|
-
end
|
7
|
-
|
8
|
-
def redefine_method(method, &block)
|
9
|
-
remove_possible_method(method)
|
10
|
-
define_method(method, &block)
|
11
|
-
end
|
12
|
-
end
|