Abstract
Beginning with 10.4 (“Tiger”), Mac OS X provides an API for synchronizing data between applications. Using RubyCocoa, we can access this API, enabling us to write Ruby code to synchronize data between macs.
Summary
Synchronizing data between different computers can be a tough nut to crack. It can be as simple as keeping flat-files identical, or complex enough to warrant expensive pieces of shrinkwrapware. Most geeks, when faced with this problem and having a need to solve it, will turn to writing some code. Perhaps that’s a shell script to rsync text files around, or perhaps it’s a complex C application complete with GUI.
That’s the old view, anyway.
Modern times have brought us modern conveniences. Beginning with 10.4 (“Tiger”), Mac OS X provides an API for synchronizing data between applications. It’s used internally by most of the basic Mac apps, including Address Book, iCal, and Safari. Further, it is completely extensible, allowing new applications to register their own synchronizable data types.
A few years back, RubyCocoa was conceived by a bright Japanese Ruby hacker named Hisakuni Fujimoto. It was designed to be a bridge between the worlds of Ruby and Objective-C, effectively allowing programmers to access the Cocoa APIs in Ruby code. This opened up a huge new world of possibility for the Mac-using Rubyist.
Unfortunately, RubyCocoa can be difficult to use. It attempts to map the Cocoa API directly to Ruby, which means that it provides a low-level, direct mapping that is fairly un-Ruby-like. Providing a clean, idiomatic Ruby interface to the Sync Services API would therefore be a handy bit of code to have laying around.
This is the problem that I set out to solve with Harmonize. Sync Services is too powerful to be left in the hands of the ObjC’ers, but RubyCocoa makes it difficult to get started. Harmonize makes it easier.
Want to keep your Safari bookmarks in sync with Ma.gnolia or del.icio.us? Need to share your contacts with your office mates? Those are just the beginning of what you can do with Sync Services, and Harmonize lets you do it from the comfort of #!/usr/bin/ruby.
I will describe the genesis of the project and show how to get started writing code with Harmonize. Client code will be available for attendees to run on their laptops to synchronize with each other during the talk. I will also demonstrate synchronizing with an external source, such as a web application or Linux machine.
The OSX-specific demo will involve attendees creating a group in their Address Book and adding themselves to it. A sync will be initiated by Address Book, and a client written using Harmonize will synchronize everyone’s Address Books together, allowing attendees to leave with contact information for other participants in the demo.
Biographical Information
Ben Bleything is a fairly recent convert to Ruby, having come via PHP and Perl. He’s currently a web developer but eagerly awaits the day when he can occupy himself writing pure Ruby on the banks of the Willamette. Ben travels between Corvallis and Portland, Oregon, where he’s a member of the PDX Ruby Brigade. He likes his bacon chunky and his types web-footed and quacking.