ruby-dbus-openplacos 0.7.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS CHANGED
@@ -5,6 +5,22 @@ 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.2 - 2012-04-05
9
+
10
+ A brown-paper-bag release.
11
+
12
+ Bug fixes:
13
+ * Fixed "undefined local variable or method `continue'" in
14
+ DBus::Main#run when a service becomes idle (by Ravil Bayramgalin)
15
+
16
+ == Ruby D-Bus 0.7.1 - 2012-04-04
17
+
18
+ Bug fixes:
19
+ * Fixed calling asynchronous methods on the default interface (Issue#13,
20
+ by Eugene Korbut).
21
+ * Fixed Main#quit to really quit the loop (by Josef Reidinger)
22
+ * Unbundled files from Active Support (by Bohuslav Kabrda)
23
+
8
24
  == Ruby D-Bus 0.7.0 - 2011-07-26
9
25
 
10
26
  Features:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.2
data/lib/dbus/bus.rb CHANGED
@@ -942,9 +942,11 @@ module DBus
942
942
 
943
943
  else
944
944
  @buses.each_value do |b|
945
+
945
946
  while m = b.pop_message
946
947
  b.process(m)
947
948
  end
949
+
948
950
  end
949
951
  while not @quitting and not @buses.empty?
950
952
  io_ready = false
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. Hash: String => Interface
23
- class_attribute :intfs
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
@@ -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
@@ -8,7 +8,6 @@
8
8
  # License, version 2.1 as published by the Free Software Foundation.
9
9
  # See the file "COPYING" for the exact licensing terms.
10
10
 
11
- require 'dbus/core_ext/class/attribute'
12
11
  require 'dbus/type'
13
12
  require 'dbus/introspect'
14
13
  require 'dbus/error'
@@ -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
@@ -27,6 +27,15 @@ class PropertyTest < Test::Unit::TestCase
27
27
  assert_equal "VALUE", @iface["ReadOrWriteMe"]
28
28
  end
29
29
 
30
+ # https://github.com/mvidner/ruby-dbus/pull/19
31
+ def test_service_select_timeout
32
+ @iface["ReadOrWriteMe"] = "VALUE"
33
+ assert_equal "VALUE", @iface["ReadOrWriteMe"]
34
+ # wait for the service to become idle
35
+ sleep 6
36
+ assert_equal "VALUE", @iface["ReadOrWriteMe"], "Property value changed; perhaps the service died and got restarted"
37
+ end
38
+
30
39
  def test_property_nonwriting
31
40
  e = assert_raises DBus::Error do
32
41
  @iface["ReadMe"] = "WROTE"
@@ -74,7 +74,6 @@ class Test < DBus::Object
74
74
  end
75
75
  dbus_method :Reverse, "in instr:s, out outstr:s" do |instr|
76
76
  outstr = instr.split(//).reverse.join
77
- puts "got: #{instr}, replying: #{outstr}"
78
77
  [outstr]
79
78
  end
80
79
  end
metadata CHANGED
@@ -1,34 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-dbus-openplacos
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 7
8
- - 0
9
- version: 0.7.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.2
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Openplacos Team
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-03-10 00:00:00 +01:00
18
- default_executable:
12
+ date: 2012-05-02 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description:
22
15
  email:
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
- extra_rdoc_files:
18
+ extra_rdoc_files:
28
19
  - COPYING
29
20
  - README
30
21
  - NEWS
31
- files:
22
+ files:
32
23
  - Rakefile
33
24
  - VERSION
34
25
  - doc/tutorial/index.markdown
@@ -47,9 +38,6 @@ files:
47
38
  - lib/dbus-openplacos.rb
48
39
  - lib/dbus/auth.rb
49
40
  - lib/dbus/bus.rb
50
- - lib/dbus/core_ext/class/attribute.rb
51
- - lib/dbus/core_ext/kernel/singleton_class.rb
52
- - lib/dbus/core_ext/module/remove_method.rb
53
41
  - lib/dbus/error.rb
54
42
  - lib/dbus/export.rb
55
43
  - lib/dbus/introspect.rb
@@ -58,6 +46,7 @@ files:
58
46
  - lib/dbus/message.rb
59
47
  - lib/dbus/type.rb
60
48
  - ruby-dbus-openplacos.gemspec
49
+ - test/async_test.rb
61
50
  - test/binding_test.rb
62
51
  - test/bus_driver_test.rb
63
52
  - test/bus_test.rb
@@ -81,39 +70,29 @@ files:
81
70
  - COPYING
82
71
  - README
83
72
  - NEWS
84
- has_rdoc: true
85
73
  homepage: https://github.com/flagos/ruby-dbus
86
- licenses:
74
+ licenses:
87
75
  - LGPL v2.1
88
76
  post_install_message:
89
77
  rdoc_options: []
90
-
91
- require_paths:
78
+ require_paths:
92
79
  - lib
93
- required_ruby_version: !ruby/object:Gem::Requirement
80
+ required_ruby_version: !ruby/object:Gem::Requirement
94
81
  none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- segments:
99
- - 1
100
- - 8
101
- - 7
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
102
85
  version: 1.8.7
103
- required_rubygems_version: !ruby/object:Gem::Requirement
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
87
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- segments:
109
- - 0
110
- version: "0"
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
111
92
  requirements: []
112
-
113
93
  rubyforge_project:
114
- rubygems_version: 1.3.7
94
+ rubygems_version: 1.8.23
115
95
  signing_key:
116
96
  specification_version: 3
117
97
  summary: Fork from ruby-dbus
118
98
  test_files: []
119
-
@@ -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