ruby-dbus 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -122,7 +122,7 @@ module DBus
122
122
  end
123
123
  d = Time.now - t
124
124
  if d > 2
125
- puts "Some XML took more that two secs to parse. Optimize me!" if $DEBUG
125
+ DBus.logger.debug "Some XML took more that two secs to parse. Optimize me!"
126
126
  end
127
127
  [interfaces, subnodes]
128
128
  end
@@ -138,10 +138,12 @@ module DBus
138
138
  dir = ae["direction"]
139
139
  sig = ae["type"]
140
140
  if m.is_a?(DBus::Signal)
141
+ # Direction can only be "out", ignore it
141
142
  m.add_fparam(name, sig)
142
143
  elsif m.is_a?(DBus::Method)
143
144
  case dir
144
- when "in"
145
+ # This is a method, so dir defaults to "in"
146
+ when "in", nil
145
147
  m.add_fparam(name, sig)
146
148
  when "out"
147
149
  m.add_return(name, sig)
@@ -6,15 +6,15 @@ GEMSPEC = Gem::Specification.new do |s|
6
6
  s.name = "ruby-dbus"
7
7
  # s.rubyforge_project = nil
8
8
  s.summary = "Ruby module for interaction with D-Bus"
9
- # s.description = FIXME
9
+ s.description = "Pure Ruby module for interaction with D-Bus IPC system"
10
10
  s.version = File.read("VERSION").strip
11
11
  s.license = "LGPL v2.1"
12
12
  s.author = "Ruby DBus Team"
13
13
  s.email = "ruby-dbus-devel@lists.luon.net"
14
14
  s.homepage = "https://trac.luon.net/ruby-dbus"
15
- s.files = FileList["{doc/tutorial,examples,lib,test}/**/*", "Rakefile", "ruby-dbus.gemspec", "VERSION"].to_a.sort
15
+ s.files = FileList["{doc,examples,lib,test}/**/*", "Rakefile", "ruby-dbus.gemspec", "VERSION"].to_a.sort
16
16
  s.require_path = "lib"
17
17
  s.has_rdoc = true
18
- s.extra_rdoc_files = ["COPYING", "README", "NEWS"]
18
+ s.extra_rdoc_files = ["COPYING", "README.md", "NEWS"]
19
19
  s.required_ruby_version = ">= 1.8.7"
20
20
  end
@@ -3,10 +3,6 @@
3
3
  require "test/unit"
4
4
  require "dbus"
5
5
 
6
- def d(msg)
7
- puts msg if $DEBUG
8
- end
9
-
10
6
  class BusDriverTest < Test::Unit::TestCase
11
7
  def setup
12
8
  @bus = DBus::ASessionBus.new
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require "test/unit"
3
+ require "dbus"
4
+
5
+ class IntrospectionTest < Test::Unit::TestCase
6
+ def setup
7
+ session_bus = DBus::ASessionBus.new
8
+ svc = session_bus.service("org.ruby.service")
9
+ @obj = svc.object("/org/ruby/MyInstance")
10
+ @obj.introspect
11
+ @obj.default_iface = "org.ruby.SampleInterface"
12
+ end
13
+
14
+ def test_wrong_number_of_arguments
15
+ assert_raise(ArgumentError) { @obj.test_variant "too","many","args" }
16
+ assert_raise(ArgumentError) { @obj.test_variant } # not enough
17
+ end
18
+
19
+ def test_shortcut_methods
20
+ @obj.default_iface = nil
21
+ assert_equal(["varargs"], @obj.bounce_variant("varargs"))
22
+ # test for a duplicated method name
23
+ assert_raise(NoMethodError) { @obj.the_answer }
24
+ # ensure istance methods of ProxyObject aren't overwritten by remote
25
+ # methods
26
+ assert_nothing_raised { @obj.interfaces }
27
+
28
+ @obj.default_iface = "org.ruby.SampleInterface"
29
+ assert_equal [42], @obj.the_answer
30
+ end
31
+ end
@@ -6,10 +6,6 @@ $:.unshift File.expand_path("../../lib", __FILE__)
6
6
 
7
7
  require 'dbus'
8
8
 
9
- def d(msg)
10
- puts "#{$$} #{msg}" if $DEBUG
11
- end
12
-
13
9
  PROPERTY_INTERFACE = "org.freedesktop.DBus.Properties"
14
10
 
15
11
  class Test < DBus::Object
@@ -84,21 +80,32 @@ class Test < DBus::Object
84
80
  end
85
81
  end
86
82
 
83
+ dbus_interface "org.ruby.Duplicates" do
84
+ dbus_method :the_answer, "out answer:i" do
85
+ [0]
86
+ end
87
+ dbus_method :interfaces, "out answer:i" do
88
+ raise "This DBus method is currently shadowed by ProxyObject#interfaces"
89
+ end
90
+ end
91
+
87
92
  dbus_interface "org.ruby.Loop" do
88
93
  # starts doing something long, but returns immediately
89
94
  # and sends a signal when done
90
95
  dbus_method :LongTaskBegin, 'in delay:i' do |delay|
91
96
  # FIXME did not complain about mismatch between signature and block args
92
- d "Long task began"
97
+ self.LongTaskStart
98
+ DBus.logger.debug "Long task began"
93
99
  task = Thread.new do
94
- d "Long task thread started (#{delay}s)"
100
+ DBus.logger.debug "Long task thread started (#{delay}s)"
95
101
  sleep delay
96
- d "Long task will signal end"
102
+ DBus.logger.debug "Long task will signal end"
97
103
  self.LongTaskEnd
98
104
  end
99
105
  task.abort_on_exception = true # protect from test case bugs
100
106
  end
101
107
 
108
+ dbus_signal :LongTaskStart
102
109
  dbus_signal :LongTaskEnd
103
110
  end
104
111
 
@@ -176,7 +183,7 @@ service.export(myobj)
176
183
  derived = Derived.new "/org/ruby/MyDerivedInstance"
177
184
  service.export derived
178
185
  test2 = Test2.new "/org/ruby/MyInstance2"
179
- service.export test2
186
+ service.export test2
180
187
 
181
188
  # introspect every other connection, Ticket #34
182
189
  # (except the one that activates us - it has already emitted
@@ -186,7 +193,7 @@ mr = DBus::MatchRule.new.from_s "type='signal',interface='org.freedesktop.DBus',
186
193
  bus.add_match(mr) do |msg|
187
194
  new_unique_name = msg.params[2]
188
195
  unless new_unique_name.empty?
189
- d "RRRING #{new_unique_name}"
196
+ DBus.logger.debug "RRRING #{new_unique_name}"
190
197
  bus.introspect_data(new_unique_name, "/") do
191
198
  # ignore the result
192
199
  end
@@ -2,10 +2,6 @@
2
2
  require "test/unit"
3
3
  require "dbus"
4
4
 
5
- def d(msg)
6
- puts msg if $DEBUG
7
- end
8
-
9
5
  class SessionBusAddressTest < Test::Unit::TestCase
10
6
  def setup
11
7
  # test getting the session bus address even if unset in ENV (Issue#4)
@@ -3,10 +3,6 @@
3
3
  require "test/unit"
4
4
  require "dbus"
5
5
 
6
- def d(msg)
7
- puts "#{$$} #{msg}" if $DEBUG
8
- end
9
-
10
6
  class SignalHandlerTest < Test::Unit::TestCase
11
7
  def setup
12
8
  @session_bus = DBus::ASessionBus.new
@@ -14,6 +10,7 @@ class SignalHandlerTest < Test::Unit::TestCase
14
10
  @obj = svc.object("/org/ruby/MyInstance")
15
11
  @obj.introspect # necessary
16
12
  @obj.default_iface = "org.ruby.Loop"
13
+ @intf = @obj["org.ruby.Loop"]
17
14
 
18
15
  @loop = DBus::Main.new
19
16
  @loop << @session_bus
@@ -21,34 +18,62 @@ class SignalHandlerTest < Test::Unit::TestCase
21
18
 
22
19
  # testing for commit 017c83 (kkaempf)
23
20
  def test_overriding_a_handler
21
+ DBus.logger.debug "Inside test_overriding_a_handler"
24
22
  counter = 0
25
23
 
26
24
  @obj.on_signal "LongTaskEnd" do
27
- d "+10"
25
+ DBus.logger.debug "+10"
28
26
  counter += 10
29
27
  end
30
28
  @obj.on_signal "LongTaskEnd" do
31
- d "+1"
29
+ DBus.logger.debug "+1"
32
30
  counter += 1
33
31
  end
34
32
 
35
- d "will begin"
33
+ DBus.logger.debug "will begin"
36
34
  @obj.LongTaskBegin 3
37
35
 
38
36
  quitter = Thread.new do
39
- d "sleep before quit"
37
+ DBus.logger.debug "sleep before quit"
40
38
  # FIXME if we sleep for too long
41
39
  # the socket will be drained and we deadlock in a select.
42
40
  # It could be worked around by sending ourselves a Unix signal
43
41
  # (with a dummy handler) to interrupt the select
44
42
  sleep 1
45
- d "will quit"
43
+ DBus.logger.debug "will quit"
44
+ @loop.quit
45
+ end
46
+ @loop.run
47
+ quitter.join
48
+
49
+ assert_equal 1, counter
50
+ end
51
+
52
+ def test_on_signal_overload
53
+ DBus.logger.debug "Inside test_on_signal_overload"
54
+ counter = 0
55
+ started = false
56
+ @intf.on_signal "LongTaskStart" do
57
+ started = true
58
+ end
59
+ # Same as intf.on_signal("LongTaskEnd"), just the old way
60
+ @intf.on_signal @obj.bus, "LongTaskEnd" do
61
+ counter += 1
62
+ end
63
+ @obj.LongTaskBegin 3
64
+ quitter = Thread.new do
65
+ DBus.logger.debug "sleep before quit"
66
+ sleep 1
67
+ DBus.logger.debug "will quit"
46
68
  @loop.quit
47
69
  end
48
70
  @loop.run
49
71
  quitter.join
50
72
 
73
+ assert_equal true, started
51
74
  assert_equal 1, counter
75
+ assert_raise(ArgumentError) {@intf.on_signal } # not enough
76
+ assert_raise(ArgumentError) {@intf.on_signal 'to', 'many', 'yarrrrr!'}
52
77
  end
53
78
 
54
79
  def test_too_many_rules
@@ -3,10 +3,6 @@
3
3
  require "test/unit"
4
4
  require "dbus"
5
5
 
6
- def d(msg)
7
- puts "#{$$} #{msg}" if $DEBUG
8
- end
9
-
10
6
  class MainLoopTest < Test::Unit::TestCase
11
7
  def setup
12
8
  @session_bus = DBus::ASessionBus.new
@@ -26,7 +22,7 @@ class MainLoopTest < Test::Unit::TestCase
26
22
  class << @session_bus
27
23
  alias :wait_for_message_orig :wait_for_message
28
24
  def wait_for_message_lazy
29
- d "I am so lazy"
25
+ DBus.logger.debug "I am so lazy"
30
26
  sleep 1 # Give the server+bus a chance to join the messages
31
27
  wait_for_message_orig
32
28
  end
@@ -45,7 +41,7 @@ class MainLoopTest < Test::Unit::TestCase
45
41
 
46
42
  def test_loop_quit(delay = 1)
47
43
  @obj.on_signal "LongTaskEnd" do
48
- d "Telling loop to quit"
44
+ DBus.logger.debug "Telling loop to quit"
49
45
  @loop.quit
50
46
  end
51
47
 
@@ -57,9 +53,9 @@ class MainLoopTest < Test::Unit::TestCase
57
53
 
58
54
  # this thread will make the test fail if @loop.run does not return
59
55
  dynamite = Thread.new do
60
- d "Dynamite burning"
56
+ DBus.logger.debug "Dynamite burning"
61
57
  sleep 2
62
- d "Dynamite explodes"
58
+ DBus.logger.debug "Dynamite explodes"
63
59
  # We need to raise in the main thread.
64
60
  # Simply raising here means the exception is ignored
65
61
  # (until dynamite.join which we don't call) or
@@ -68,7 +64,7 @@ class MainLoopTest < Test::Unit::TestCase
68
64
  end
69
65
 
70
66
  @loop.run
71
- d "Defusing dynamite"
67
+ DBus.logger.debug "Defusing dynamite"
72
68
  # if we get here, defuse the bomb
73
69
  dynamite.exit
74
70
  # remove signal handler
@@ -3,10 +3,6 @@
3
3
  require "test/unit"
4
4
  require "dbus"
5
5
 
6
- def d(msg)
7
- puts "#{$$} #{msg}" if $DEBUG
8
- end
9
-
10
6
  class ThreadSafetyTest < Test::Unit::TestCase
11
7
  def test_thread_competition
12
8
  print "Thread competition: "
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ # Test the type class
3
+ require "test/unit"
4
+ require "dbus"
5
+
6
+ class TypeTest < Test::Unit::TestCase
7
+ def test_costants_are_defined
8
+ assert_equal DBus::Type::BYTE, ?y
9
+ assert_equal DBus::Type::BOOLEAN, ?b
10
+ #etc..
11
+ end
12
+
13
+ def test_parsing
14
+ %w{i ai a(ii) aai}.each do |s|
15
+ assert_equal s, DBus::type(s).to_s
16
+ end
17
+
18
+ %w{aa (ii ii) hrmp}.each do |s|
19
+ assert_raise(DBus::Type::SignatureException) { DBus::type(s) }
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,37 +1,37 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-dbus
3
- version: !ruby/object:Gem::Version
4
- hash: 63
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 0
10
- version: 0.8.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Ruby DBus Team
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-09-20 00:00:00 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
- description:
14
+ description: Pure Ruby module for interaction with D-Bus IPC system
22
15
  email: ruby-dbus-devel@lists.luon.net
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
- extra_rdoc_files:
18
+ extra_rdoc_files:
28
19
  - COPYING
29
- - README
20
+ - README.md
30
21
  - NEWS
31
- files:
22
+ files:
32
23
  - Rakefile
33
24
  - VERSION
34
- - doc/tutorial/index.markdown
25
+ - doc/Reference.md
26
+ - doc/Tutorial.md
27
+ - doc/ex-calling-methods.body.rb
28
+ - doc/ex-calling-methods.rb
29
+ - doc/ex-properties.body.rb
30
+ - doc/ex-properties.rb
31
+ - doc/ex-setup.rb
32
+ - doc/ex-signal.body.rb
33
+ - doc/ex-signal.rb
34
+ - doc/example-helper.rb
35
35
  - examples/gdbus/gdbus
36
36
  - examples/gdbus/gdbus.glade
37
37
  - examples/gdbus/launch.sh
@@ -50,6 +50,7 @@ files:
50
50
  - lib/dbus/error.rb
51
51
  - lib/dbus/export.rb
52
52
  - lib/dbus/introspect.rb
53
+ - lib/dbus/logger.rb
53
54
  - lib/dbus/marshall.rb
54
55
  - lib/dbus/matchrule.rb
55
56
  - lib/dbus/message.rb
@@ -63,6 +64,7 @@ files:
63
64
  - test/bus_test.rb
64
65
  - test/dbus-launch-simple
65
66
  - test/dbus-limited-session.conf
67
+ - test/introspection_test.rb
66
68
  - test/property_test.rb
67
69
  - test/server_robustness_test.rb
68
70
  - test/server_test.rb
@@ -77,44 +79,35 @@ files:
77
79
  - test/test_env
78
80
  - test/test_server
79
81
  - test/thread_safety_test.rb
82
+ - test/type_test.rb
80
83
  - test/variant_test.rb
81
84
  - COPYING
82
- - README
85
+ - README.md
83
86
  - NEWS
84
87
  homepage: https://trac.luon.net/ruby-dbus
85
- licenses:
88
+ licenses:
86
89
  - LGPL v2.1
87
90
  post_install_message:
88
91
  rdoc_options: []
89
-
90
- require_paths:
92
+ require_paths:
91
93
  - lib
92
- required_ruby_version: !ruby/object:Gem::Requirement
94
+ required_ruby_version: !ruby/object:Gem::Requirement
93
95
  none: false
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- hash: 57
98
- segments:
99
- - 1
100
- - 8
101
- - 7
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
102
99
  version: 1.8.7
103
- required_rubygems_version: !ruby/object:Gem::Requirement
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
101
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
112
106
  requirements: []
113
-
114
107
  rubyforge_project:
115
- rubygems_version: 1.8.15
108
+ rubygems_version: 1.8.23
116
109
  signing_key:
117
110
  specification_version: 3
118
111
  summary: Ruby module for interaction with D-Bus
119
112
  test_files: []
120
-
113
+ has_rdoc: true