неділю, 14 червня 2009 р.

Ruby 1.9 and R-Bus

Намагаючись завести зв'язку Ruby 1.9 + D-Bus, натрапив на проект R-Bus.
З офіційної сторінки бубліотеки:
R-Bus is a native implementation of the D-Bus protocol, with these goals in mind:Ruby + standard library is the only dependencies, a rubyish API, approach and way of doing things, complete client functionality and a comprehensive test suite.

Останньою новиною проетку є Ruby 1.9.1 support in trunk датована 5 квітня 2009 року.
Як виявилось пізніше версія з транку не працює з Ruby 1.9.1. Тому доведеться накладати патч. Перевірено, він сумісний не тільки з версією 1.9.1 Ruby, а й попередніми. Приємно, що автором патчу є наш земляк Sergey Yanovitsky, за що йому велике Дякую. Хоча і не всі функції працездатні :(.


Install Ruby 1.9.1 from sources:
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p129.tar.gz
$ tar xzvf ruby-1.9.1-p129.tar.gz
$ mkdir ruby1.9
$ cd /home/mama/ruby-1.9.1-p129
$ ./configure --prefix=/home/mama/ruby1.9
$ make
$ make install
$ PATH=/home/mama/ruby1.9/bin:$PATH
$ ruby -v
ruby 1.9.1p129 (2009-05-12 revision 23412) [i686-linux]

Get the R-Bus code from Subversion with:
$ svn checkout svn://rubyforge.org/var/svn/rbus/trunk rbus
$ cd rbus

Get Ruby 1.9 and Rspec 1.2.2 support patch
wget http://rubyforge.org/tracker/download.php/3277/12588/25318/4487/ruby-1.9_rspec-1.2.2_support.diff

Apply patch:
$ patch -p0 < ruby-1.9_rspec-1.2.2_support.diff

Install rbus:
$ ruby setup.rb

Example:
require 'rbus'
session_bus = RBus.session_bus
rb_player = session_bus.get_object('org.kde.amarok', '/Player')
uri = rb_player.GetMetadata()

Посилання:
R-Bus API Docs, Tutorial and more

Немає коментарів: