ruby-dbus-wrapper 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c947f02da945a58458614dc90764956fabf5c08
4
+ data.tar.gz: 3e8c3cf136b6379b3ee37a4dc01cc6040fb0bd18
5
+ SHA512:
6
+ metadata.gz: 209d043917643a7c395d7428b3d2715e62f9ff930ed5ca2863d3f24a10dfca274a5fd96c0078e881e645b4b5f1b67fe9351023dae367d82a7dff5a4cff75a275
7
+ data.tar.gz: 4a51c53040edb2ee3ee840bd41dd742c723fcbee6121bd9c8a8a085b74cd9222fc71a450dcfdb574a0037ec45b003a2e86c7401b136f34514407acbf8ca8c870
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 mspanc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ ruby-dbus-wrapper
2
+ =================
3
+
4
+ Wrapper for Ruby D-Bus client providing some useful high-level methods.
5
+
6
+ # Installation
7
+
8
+ ## Step 1: Add Ruby D-Bus gem to your Gemfile
9
+
10
+ You have to manually add your Ruby D-Bus bindings to the Gemfile because there are two gems that can
11
+ be used and it's up to you which one you choose: original `ruby-dbus` or EventMachine-powered `em-ruby-dbus`.
12
+
13
+ If you are unsure or want to use the original `ruby-dbus`, add the following line to your `Gemfile`:
14
+
15
+ gem 'ruby-dbus'
16
+
17
+ If you want to use EventMachine version, add the following line to your `Gemfile`:
18
+
19
+ gem 'em-ruby-dbus'
20
+
21
+ ## Step 2: Add this gem to your Gemfile
22
+
23
+ Just add the following line to your `Gemfile`:
24
+
25
+ gem 'ruby-dbus-wrapper'
26
+
27
+ # Usage
28
+
29
+ Right now this gem provides two methods, that allows to invoke method calls or watch signals without creating
30
+ proxy objects.
31
+
32
+ ## Method calls
33
+
34
+ conn = DBus::SessionBus.instance
35
+ bus = DBus::Wrapper::Bus.new(conn)
36
+
37
+ # Without parameters
38
+ bus.method_call("org.freedesktop.DBus", "/", "org.freedesktop.DBus", "ListNames") do |message|
39
+ # do something
40
+ end
41
+
42
+ # With parameters
43
+ bus.method_call("another.destination", "/", "some.Interface", "SomeMember", [["s", "First param"], ["a{ss}", { "Second" => "Param"}]]) do |message|
44
+ # do something
45
+ end
46
+
47
+ main = DBus::Main.new
48
+ main << conn
49
+ main.run
50
+
51
+ The arguments are: destination, path, interface, member, params = nil, &callback
52
+
53
+
54
+ ## Signal monitoring
55
+
56
+ conn = DBus::SessionBus.instance
57
+ bus = DBus::Wrapper::Bus.new(conn)
58
+
59
+ # Without parameters
60
+ bus.monitor_signal("org.freedesktop.DBus", nil, "org.freedesktop.DBus", "NameOwnerChanged") do |message|
61
+ # do something
62
+ end
63
+
64
+ main = DBus::Main.new
65
+ main << conn
66
+ main.run
67
+
68
+ The arguments are: sender, path, interface, member, &callback
69
+
70
+ # License
71
+
72
+ MIT
73
+
74
+ # Author
75
+
76
+ (c) 2014 Marcin Lewandowski
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,48 @@
1
+ module DBus
2
+ module Wrapper
3
+ class Bus
4
+ attr_reader :connection
5
+
6
+ def initialize(connection)
7
+ @connection = connection
8
+ end
9
+
10
+
11
+ def monitor_signal(sender, path, interface, member, &callback)
12
+ raise ArgumentError, "You must specify interface" if interface.nil?
13
+ raise ArgumentError, "You must specify member" if member.nil?
14
+ raise ArgumentError, "You must specify callback" unless block_given?
15
+
16
+ match_string = "type='signal',interface='#{interface}',member='#{member}'"
17
+ match_string << ",path='#{path}'" unless path.nil?
18
+ match_string << ",sender='#{sender}'" unless sender.nil?
19
+
20
+ @connection.add_match match_string, &callback
21
+ end
22
+
23
+
24
+ def method_call(destination, path, interface, member, params = nil, &callback)
25
+ raise ArgumentError, "You must specify destination" if destination.nil?
26
+ raise ArgumentError, "You must specify path" if path.nil?
27
+ raise ArgumentError, "You must specify interface" if interface.nil?
28
+ raise ArgumentError, "You must specify member" if member.nil?
29
+ raise ArgumentError, "You must specify callback" unless block_given?
30
+
31
+ message = ::DBus::Message.new(::DBus::Message::METHOD_CALL)
32
+ message.path = path
33
+ message.destination = destination
34
+ message.interface = interface
35
+ message.member = member
36
+
37
+ if params.is_a? Array
38
+ params.each do |param|
39
+ message.add_param param[0], param[1]
40
+ end
41
+ end
42
+
43
+ @connection.send_sync_or_async message, &callback
44
+ end
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1 @@
1
+ require_relative "ruby-dbus-wrapper/bus"
@@ -0,0 +1,16 @@
1
+ require "rubygems"
2
+ require "rake"
3
+
4
+ GEMSPEC = Gem::Specification.new do |s|
5
+ s.name = "ruby-dbus-wrapper"
6
+ s.summary = "High-level wrapper for Ruby D-Bus client"
7
+ s.description = "Wrapper for Ruby D-Bus client providing some useful high-level methods"
8
+ s.version = File.read("VERSION").strip
9
+ s.license = "MIT"
10
+ s.author = "Marcin Lewandowski"
11
+ s.email = "marcin@saepia.net"
12
+ s.homepage = "https://github.com/mspanc/ruby-dbus-wrapper"
13
+ s.files = FileList["{lib}/**/*", "LICENSE", "README.md", "ruby-dbus-wrapper.gemspec", "VERSION"].to_a.sort
14
+ s.require_path = "lib"
15
+ s.required_ruby_version = ">= 1.9.3"
16
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-dbus-wrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcin Lewandowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Wrapper for Ruby D-Bus client providing some useful high-level methods
14
+ email: marcin@saepia.net
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - VERSION
22
+ - lib/ruby-dbus-wrapper.rb
23
+ - lib/ruby-dbus-wrapper/bus.rb
24
+ - ruby-dbus-wrapper.gemspec
25
+ homepage: https://github.com/mspanc/ruby-dbus-wrapper
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 1.9.3
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.2.2
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: High-level wrapper for Ruby D-Bus client
49
+ test_files: []