MacRuby - a Mac OS X port of Ruby 1.9 designed to run directly on top of OS X's frameworks - recently hit a new milestone with the release of MacRuby 0.3.
In addition to the expected bug fixes and performance increases (they claim that MacRuby should now be up to YARV levels) the release also features a number of exciting Cocoa-derived GUI building enhancements, such as Rich Kilmer's HotCocoa - a new core library which simplifies Cocoa programming with simple Ruby idioms. Example:
require 'hotcocoa' include HotCocoa application do |app| window :size => [100, 50] do |win| b = button :title => 'Hello' b.on_action { puts 'World!' } win << b end end
Just as exciting is the fact that MacRuby 0.3 now supports Interface Builder! With the new MacRuby - you can now define classes, outlets and actions in a MacRuby Xcode project and they will automatically appear in Interface Builder - very cool.
Post supported by Brightbox: Brightbox is a specialist European Rails hosting company. Each Brightbox server includes an optimised Ruby on Rails stack, SAN storage and access to a managed MySQL database cluster. They also manage dedicated clusters for large scale Rails deployments. Click here to learn more..
While it was pretty momentous last year when Mac OS X (Leopard) was released with full support for Ruby and Rails included with the OS, it seems that the Ruby train is still rolling with Apple.
A recent InfoQ article highlights some ways that Apple is using Ruby that you might have missed - including:
I haven't played with the MobileMe web applications much, but I recall thinking that they looked fairly impressive. Have any other Ruby developers tried SproutCore yet? How's it working out for you?
Post supported by Brightbox: Brightbox is a specialist European Rails hosting company. Each Brightbox server includes an optimised Ruby on Rails stack, SAN storage and access to a managed MySQL database cluster. They also manage dedicated clusters for large scale Rails deployments. Click here to learn more..

Dr Nic Williams has been busy playing with iPhone and Objective C development lately and, unsurprisingly, has found a way to bring Ruby into the mix. He has developed rbiphonetest, a Ruby-based testing framework for iPhone / Objective C applications that uses RubyCocoa to provide the necessary bridge. As well as producing an in-depth 20 minute demonstration screencast, he has also packed some key information into his blog post.
If you're a Rubyist with ambitions of developing native iPhone applications using Objective C (and perhaps even Ruby one day), it's certainly worth a look (as are all of Dr Nic's projects, of course).

Promise and Peril for Alternative Ruby Impls [Implementations] is a lengthy, but interesting, essay by Charles Nutter of the JRuby team. He looks at Ruby 1.8, Ruby 1.9, JRuby, Rubinius, IronRuby, MacRuby, and some minor implementations, and covers their background along with their current development state and how they might proceed in future. For those interested in the state of the many Ruby implementations, this is a must read.
For those who want a shorter version without any of the context or smart insight Charles brings: the Ruby 1.8.7 previews have thrown a spanner in the works, Ruby 1.9 still doesn’t run Rails (but will very soon), Ruby 1.9 might not prove better enough to woo developers, JRuby rocks, Rubinius is cool but improving performance will be hard, Rubinius seems to be retreating to using more and more C primitive functions and moving away from “Ruby in Ruby”, IronRuby is clever but might have trouble running Rails properly, MacRuby is a great idea, and all of the other, minor implementations seem stuck in the mud.
Trivia: Two Freudian slips when writing this post. I mis-typed “Peril” as “Perl” in both cases.

In Fluid Rails Docs on OSX, Jacques Crocker takes a look at a couple of ways to get good-looking Rails documentation within Mac OS X. Firstly, he provides a site specific browser for NoobKit, an online Rails / Gems documentation site. Secondly, however, is an app that accesses a locally available set of documentation called “RailsBrain” that works offline.

John Muchow has put together a three part (so far) set of blog posts that guides you through using Ruby as an alternative for AppleScript on OS X (part 1, part 2, part 3) using the rb-appscript library. It’s very slow moving so even if you’re a complete AppleScript / OS X newbie, you’ll be able to follow it.
Ruby > AppleScript
With all of the developments going on between OS X and Ruby lately, I’m becoming convinced that Ruby could become the de-facto OS X scripting language of choice within the next few years. I’m a programmer, but I find AppleScript hideous enough to avoid it wherever possible, and I’m not the only one. I forget where, but I recently read an article about AppleScript that suggested while it reads like English, it’s not particular easy to code in because it isn’t English and the constructions are very rigid. Compare this AppleScript code:
tell application "TextEdit"
get paragraph 1 of document "Read Me"
end tell
To this Ruby alternative:
app(’TextEdit‘).documents[’Read Me‘].paragraphs[1].get
The AppleScript reads better in English terms, but the Ruby version is, arguably, easier to remember how to reconstruct, as long as you’re familiar with Ruby syntax. Ruby’s reflection / inspection capabilities also ensure that even if you forget the name of a method / term, you can look it up on the fly! Try that in AppleScript! (Oops, I’m wrong, for now.)
RubyOSA
As well as rb-appscript, let’s not forget RubyOSA, a Ruby bridge to the Apple Event Manager, a library that makes controlling OS X applications child’s play:

Justin Williams has put together an all-in-one RubyOSA tutorial that’s worth reading and demonstrates how to control NetNewsWire from Ruby.
Ruby & OS X Books?
Lastly, where are the Ruby and OS X books? Are you writing one now that you can tell us about? Are you a publisher looking for someone to write such a book? Is there already a book that’s dedicated to using Ruby specifically with OS X? If not, it’s finally time for one.

Processing is a popular, open source graphics framework and programming language. It’s used by thousands of artists, researchers, and students to put together graphics-focused applications, art, and other visual experiments. It’s like a more powerful NodeBox, if you’re familiar with that project.
Processing typically relies on scripts written in Java, but now, thanks to JRuby, it’s possible to interact with the Processing framework directly from regular Ruby code. You’re going to need a fully working JRuby installation for this, and it seems to have only been tested on OS X (which I’ve also tested it on - it works well!), but the interface code, along with two examples, are available at The Shoebox. If you want to put together quirky art apps, graphical experiments, or just doodle around, it’s well worth trying.
(Many thanks to John Weir - who was, at one time, working on something similar called Dynamite - for the pointer to this new project.)

Castanaut is a Ruby-backed screencasting domain-specific language that allows you to script screencasts in code. When these scripts are run, Castanaut takes control of your Mac and produces the desired effect. It’s simply automated, scripted screencasting.
The Origin
Two weeks ago I was reading a post on 37signals’ blog about producing screencasts. Joseph Pearson’s comment got me all excited:
At Inventive Labs, we’re experimenting with scripted screencasts. That is, you run a script, and at the end of it you have a screencast.
For example, this movie was generated by this Ruby script. No human was involved at all.
Obviously we would replace the text-to-speech narrative with a real voice actor for any screencast we put out, not least because the robot suffers from the Uncanny Valley effect. But it does ensure that timing is right.
I e-mailed Joseph and gave his system a try. It’s now publicly available under the superb WTFPL license.

Why?
One of the common problems with screencasts is that they take a long time to produce, and this often means they fail to get updated when situations change (new versions of products, updated interfaces, etc.) With Castanaut, you could script your screencasts and rapidly reproduce them each time your software has a major update. If the changes are just at the interface level, you could even reproduce the video, paste the old voice / sound track over the top, and you’d be done.
As an aside, if you’re more interested in producing screencasts the “old fashioned” way, I can heartily recommend Geoffrey Grosenbach’s “Screencasting On The Mac” video. It costs $9 but you get a lot of information for your money. PeepCode is a sponsor of Ruby Inside but I am recommending this separately to that. I watched it last week and took away a lot of useful information, although now I’m being tempted by Castanaut instead ;-)
![]()
RubyCocoa is a Ruby library and Mac OS X framework that bridges the Ruby programming language to the delights of Objective C and, more precisely, Cocoa, Apple’s primary OS X application development framework. Included with Mac OS X Leopard (10.5.x), but also available to install for Tiger, RubyCocoa makes it easy to develop Ruby applications that take full advantage of what OS X’s internal frameworks and libraries have to offer, whether it’s building a regular GUI application or interacting with low level elements of OS X.
This post rounds up a lot of RubyCocoa-focused resources, tutorials, and other links, so that if you’re new to RubyCocoa and just want to “dive in,” a lot of the pages you’ll want to visit are organized here. Enjoy!
Introduction
Official RubyCocoa Homepage - News and official information about RubyCocoa, including how to get started, links to documentation and a few code snippets.
List of Projects using RubyCocoa - Just what it says, a list of projects using the RubyCocoa library! Some of them come with source so could be worth checking out.
5 Things to Get Started with RubyCocoa - Chris Schmitt outlines five things you should do in order to get up to speed with RubyCocoa.
Using Scripting Languages for Cocoa Development - A brief, but well put, overview from Apple of using languages such as Ruby to develop Cocoa applications.
Tutorials
Your First Few Days on RubyCocoa - Slightly old (mid 2007) but this tutorial demonstrates how to put together a bare-bones OS X GUI application using RubyCocoa and XCode’s Interface Builder. Tiger users might find this useful as it covers installation on that version of OS X.
RubyCocoa Tutorial - Eric X has put together a great, well illustrated, tutorial that walks you through from start to finish in building a currency conversion application (as Apple likes to use in their own Cocoa tutorial) with Ruby and Xcode.
Japanese RubyCocoa Tutorial - It’s in a RubyCocoa tutorial in Japanese but it’s immaculately illustrated so shouldn’t be dismissed out of hand. It seems to focus more on using Xcode than other tutorials.
Using Scripting Bridge in RubyCocoa Code - A tutorial from Apple that looks at how Ruby can interface with OS X applications through Scripting Bridge.
Using RubyOSA - A tutorial from Apple demonstrating how to use AppleScript-like scripting techniques in Ruby to interface with OS X applications. This is not directly related to RubyCocoa but provides an alternative to the Scripting Bridge approach.

Ruby Rocks: Build A Whole Game With RubyCocoa! - A really interesting tutorial that walks you through the process of building an entire Asteroids-esque game using RubyCocoa (note: rubycocoa.com occasionally gives 404 errors accidentally, just refresh)
Writing Ruby Extensions with RubyCocoa - Tim Burks looks at how you can build Ruby extensions with C wrapped in Objective-C classes using RubyCocoa. Considering OS X’s fine support for gcc (and therefore RubyInline) I’m not entirely sure how useful this is.
An O’Reilly Introduction to RubyCocoa - A very old RubyCocoa tutorial from 2004 (!!) that is mostly out of date but does provide a good overview. Don’t put this at the top of your reading list though. For RubyCocoa junkies only.
Specific Tasks and Tricks
Simple Wireless Signal Strength Meter - Sandro Paganotti demonstrates how to read information about your wireless signal on OS X. Curiously, this doesn’t use RubyCocoa for the main task, but for playing a sound instead.
Using Your Apple Remote from Ruby - A demonstration of how to use RubyCocoa to interface with the Apple Remote (well, pick up its requests, at least!)

Outline Views with RubyCocoa - Tim Perrett provides code for producing a tree / outline-type view on OS X using Ruby.
attachment_fu magic with Core Image and RubyCocoa - A tutorial that demonstrates how to use RubyCocoa and OS X’s Core Image library to perform graphical operations on files uploaded through the attachment_fu plugin.

Cocoa Magic for Gruff Graphs - Using RubyCocoa and the Gruff charting library to produce graphs without relying on installing ImageMagick!
RubySaver - It’s in Japanese, but it seems to be demonstrating how to create a screen saver using Ruby and RubyCocoa, specifically one that shows information from Wikipedia?
Interfacing with Skype - In Japanese again, but a demonstration of how to hook up with Skype from Ruby, specifically to set your status text to your currently playing iTunes track.
Screen Capture with RubyCocoa - A walk through developing a small Ruby application to take screenshots.
Cool Image Effects with Core Image - A great look at how to use Core Image’s graphics effects from Ruby code. Lots of pictures and code examples. RMagick is history!
Text to Speech App - A quick code demonstration of how to get your Mac saying things to you from Ruby.
Control iTunes from Ruby - A code snippet showing how to use ScriptingBridge to control iTunes and get back the name of the current track.

Selectable Toolbar Icons in RubyCocoa and Animating NSViews in RubyCocoa - Matt McCray demonstrates how to create a funky, animated GUI preferences panel using Ruby.
Write a QuickSilver Plugin with RubyCocoa - How to use Objective C and Ruby to build a plugin for the QuickSilver launcher / general purpose tool.
Ruby and FSEvents - Info about a Ruby app called fswatch that can use OS X’s File System Events framework to monitor what occurs on the file system.

CAPTCHA Creator - A blog post outlining how a CAPTCHA generator was built using Ruby and RubyCocoa (along with Quartz Composer). A ZIP of the full source code is also available.
Tools and Libraries
RubyInject - RubyInject provides a mechanism to ‘inject’ a Ruby interpreter into any running OS X application. This can provide you with the ability to mess around with OS X applications on the fly from an irb-esque prompt.
Rucola - Rucola is a framework that makes it easier to build Cocoa applications using Ruby and RubyCocoa. Essentially it provides a set of generators that can generate controllers, window controllers, and document-based applications. A bit like a “Rails” for Cocoa, but, erm, not.

Platypus - Not specifically related to RubyCocoa, Platypus is an OS X application that can “package up” Ruby applications for easier distribution. This could make distributing your RubyCocoa creations a lot easier and give other users a seamless installation experience.
Capture - A Gem-installable (gem install capture) OS X screenshot tool.
NewCocoa - A Rails-like command for building RubyCocoa apps. A little like Rucola (above). This post features a screencast of its use.
Miscellaneous

LimeChat - An IRC client written in Ruby and using RubyCocoa. Comes with source code!
RubyCocoa Tips - Building RubyCocoa Projects with Rake, debugging RubyCocoa problems with gdb, converting Objective-C Cocoa apps into Ruby, and dealing with special Cocoa data types in Ruby.

/Developer/Examples/Ruby/RubyCocoa - Not a Web-accessible URL, just a folder on your system (if running Leopard) that contains a whole bunch of Apple-developed RubyCocoa examples! There’s even a Pong game.
Rewriting Ruby’s classes in Objective C? - Laurent Sansonetti talks about an interesting project to migrate chunks of Ruby over to Objective C.
Code74 - An OS X Webkit-powered Web browser written in Ruby.
Objective C, Ruby and Python for Cocoa - A well written discussion of the cultural and technical aspects involved in writing Cocoa applications with various languages.
LogEye - a Rails log-file GUI - An OS X RubyCocoa app that can view your Rails log files with coloring, etc.
Tips and Pitfalls - A list of tips and pitfalls to using RubyCocoa from the perspective of one developer.
Many thanks to this curious Japanese list of RubyCocoa links for inspiring some of the links in this post. Most of them are in Japanese, however!
Ext JS Powered Administration System Generator for Rails 2.0

Davide D’Agostino writes in with news about Lipsiadmin, his Ext JS powered administration system generator for Rails 2.0. Ext JS is an interesting JavaScript framework that lets you quickly put together AJAX-powered Web pages that look and feel somewhat like Windows applications. Lipsiadmin takes this attribute of Ext JS and builds backend administrator systems for your Rails applications that feel more like GUI apps than Web pages. It’s pretty interesting work.
RailsConf 2008 Registration Now Open
Just a quick note to those who are interested that the registration for RailsConf 2008 is open. Get in quick as it typically books out fast. David Hansson gives some brief background.
“Rails Is Shitty”
There’s no thought given to the general problem to solve, it’s just improved PHP + “ActiveRecord, lol”. This means Rails doesn’t have solutions that are particularly good or scalable or make sense, only hacks that happened to solve someone’s specific problem at a time and were implementable in 5 minutes or less. Rails is heaps better than PHP, but it’s still only good for what PHP is good, and that’s not writing webapps. This permeates Rails all the way down: it’s got hacky modules that only solve particular problems, those modules have hacky functions that only solve particular problems and those functions only do hacky things that solved someone’s particular problem.
Maciej Kataflasz
A post on comp.lang.lisp recently caught the eyes of several Rails developers. It’s inflammatory and a prime piece of flamebait, but Maciej Kataflasz makes a few good points amongst the hate.
Easy Restful Rails Screencast
In the “Easy Restful” screencast, Fabio Akita takes a 50 minute journey into putting together RESTful Rails 2.0 applications in an efficient manner.
Installing Rails and PostgreSQL on OS X Leopard
Robby Russell has put together an easy to follow, complete guide to getting a full Rails stack along with PostgreSQL installed on OS X Leopard. Lots of screenshots and hand holding. Nice work!

RubyInject is an intriguing new tool that can "inject" a Ruby interpreter into any running OS X application. Why? Well, along with RubyCocoa it allows you to interact with an application "from the inside." If you're a RubyCocoa aficionado you can probably think of a few cute tricks to use this for already. If not, then just think about AppleScript on acid. All of this fun and games does require OS X 10.5 (Leopard), however.

Someone / some people who have been responsible for integrating Ruby and Rails into the latest version of Mac OS X (Leopard) have written some notes on what was involved and how Ruby and Rails work in Leopard. The Ruby build is a customized 1.8.6 p36 and actually integrates into Xcode and Interface Builder.. now making it a relatively easy task to put together Ruby GUI apps on OS X. RubyGems is also installed with a smattering of the most popular gems preinstalled by default.
If you work on Mac OS X, you may have noticed how cool Macs deal with complex documents, things like Keynote presentations or applications themselves. They're stored as directories. The Finder hides this, making them look and act like individual files. This works nicely, often the contents of a bundle are simple text and XML files ... whereas the equivalent under Windows is either a very proprietary (and potentially fragile) binary format, or multiple files and folders that YOU have to treat as a unit.
Alas, this all breaks down when using Subversion. You can't just check in MyPresentation.key into SVN ... it will create those pesky .svn directories inside the bundle, and those will be destroyed every time you save your presentation.
My solution to this is to convert the bundles into an archive, and check in the archive. The bundle folders are marked as svn:ignore. I guess this reveals that I mostly use SVN as a safe, structured backup.
In any case, manually creating those archives can be a pain. So ... out comes my solution to many problems: Ruby.
The goal here is to find bundles that need to be archived; do it efficiently (only update the archive if necessary) and do it recursively, seeking out bundles in sub-directories.
#!/usr/bin/ruby
# Used to prepare a directory for commit to Subversion. This is necessary for certain file types on Mac OS X because what appear to be files in the Finder
# are actually directories (Mac uses the term "bundle" for this concept). It is useless to put the .svn folder inside such a directory, because it will
# tend to be deleted whenever the "file" is saved.
#
# Instead, we want to compress the directory to a single archive file; the bundle will be marked as svn:ignore.
#
# We use tar with Bzip2 compression, which is resource intensive to create, but
# compresses much better than GZip or PKZip.
#
# The trick is that we only want to create the acrhive version when necessary; when
# the archive does not exist, or when any file
# in the bundle is newer than the archive.
require 'optparse'
# Set via command line options
$extensions = %w{pages key oo3 graffle}
$recursive = true
$dry_run = false
# Queue of folders to search (for bundles)
$queue = []
def matching_extension(name)
dotx = name.rindex('.')
return false unless dotx
ext = name[dotx + 1 .. -1]
return $extensions.include?(ext)
end
# Iterate over the directory, identify bundles that may need to be compressed and (if recursive) subdirectories
# to search.
#
# path: string path for a directory
def search_directory(dirpath)
Dir.foreach(dirpath) do |name|
# Skip hidden files and directories
next if name[0..0] == "."
path = File.join(dirpath, name)
next unless File.directory?(path)
if matching_extension(name)
update_archive path
next
end
if $recursive
$queue << path
end
end
end
def needs_update(bundle_path, archive_path)
return true unless File.exists?(archive_path)
archive_mtime = File.mtime(archive_path)
# The archive exists ... can we find a file inside the bundle thats newer?
# This won't catch deletions, but that's ok. Bundles tend to get completly
# overwritten when any tiny thing changes.
dirqueue = [bundle_path]
until dirqueue.empty?
dirpath = dirqueue.pop
Dir.foreach(dirpath) do |name|
path = File.join(dirpath, name)
if File.directory?(path)
dirqueue << path unless [".", ".."].include?(name)
next
end
# Is this file newer?
if File.mtime(path) > archive_mtime
return true
end
end
end
return false
end
def update_archive(path)
archive = path + ".tar.bz2"
return unless needs_update(path, archive)
if $dry_run
puts "Would create #{archive}"
return
end
puts "Creating #{archive}"
dir = File.dirname(path)
bundle = File.basename(path)
# Could probably fork and do it in a subshell
system "tar --create --file=#{archive} --bzip2 --directory=#{dir} #{bundle}"
end
$opts = OptionParser.new do |opts|
opts.banner = "Usage: prepsvn [options]"
opts.on("-d", "--dir DIR", "Add directory to search (if no directory specify, current directory is searched)") do |value|
$queue << value
end
opts.on("-e", "--extension EXTENSION", "Add another extension to match when searching for bundles to archive") do |value|
$extensions << value
end
opts.on("-N", "--non-recursive", "Do not search non-bundle sub directories for files to archive") do
$recursive = false
end
opts.on("-D", "--dry-run", "Identify what archives would be created") do
$dry_run = true
end
opts.on("-h", "--help", "Help for this command") do
puts opts
exit
end
end
def fail(message)
puts "Error: #{message}"
puts $opts
end
begin
$opts.parse!
rescue OptionParser::InvalidOption
fail $!
end
# If no --dir specified, use the current directory.
if $queue.empty?
$queue << Dir.getwd
end
until $queue.empty?
search_directory $queue.pop
end
I do love Ruby syntax, it is so minimal, and lets me follow my personal mantra less is more.
I'm sure there's some edge cases that aren't handle well, such as spaces in path names and maybe issues related to permissions. But it works for me.
You do need to have tar installed, in order to build the archives. I can't remember if that's built in to Mac OS X (probably) or whether I obtained it using Fink.
In any case, you need to remember to execute prepsvn in your workspace, to spot file bundles that need archiving, before you check in. It would be awesome if Subversion supported some client-side check-in hooks to do this automatically.
If you work on Mac OS X, you may have noticed how cool Macs deal with complex documents, things like Keynote presentations or applications themselves. They're stored as directories. The Finder hides this, making them look and act like individual files. This works nicely, often the contents of a bundle are simple text and XML files ... whereas the equivalent under Windows is either a very proprietary (and potentially fragile) binary format, or multiple files and folders that YOU have to treat as a unit.
Alas, this all breaks down when using Subversion. You can't just check in MyPresentation.key into SVN ... it will create those pesky .svn directories inside the bundle, and those will be destroyed every time you save your presentation.
My solution to this is to convert the bundles into an archive, and check in the archive. The bundle folders are marked as svn:ignore. I guess this reveals that I mostly use SVN as a safe, structured backup.
In any case, manually creating those archives can be a pain. So ... out comes my solution to many problems: Ruby.
The goal here is to find bundles that need to be archived; do it efficiently (only update the archive if necessary) and do it recursively, seeking out bundles in sub-directories.
#!/usr/bin/ruby
# Used to prepare a directory for commit to Subversion. This is necessary for certain file types on Mac OS X because what appear to be files in the Finder
# are actually directories (Mac uses the term "bundle" for this concept). It is useless to put the .svn folder inside such a directory, because it will
# tend to be deleted whenever the "file" is saved.
#
# Instead, we want to compress the directory to a single archive file; the bundle will be marked as svn:ignore.
#
# We use tar with Bzip2 compression, which is resource intensive to create, but
# compresses much better than GZip or PKZip.
#
# The trick is that we only want to create the acrhive version when necessary; when
# the archive does not exist, or when any file
# in the bundle is newer than the archive.
require 'optparse'
# Set via command line options
$extensions = %w{pages key oo3 graffle}
$recursive = true
$dry_run = false
# Queue of folders to search (for bundles)
$queue = []
def matching_extension(name)
dotx = name.rindex('.')
return false unless dotx
ext = name[dotx + 1 .. -1]
return $extensions.include?(ext)
end
# Iterate over the directory, identify bundles that may need to be compressed and (if recursive) subdirectories
# to search.
#
# path: string path for a directory
def search_directory(dirpath)
Dir.foreach(dirpath) do |name|
# Skip hidden files and directories
next if name[0..0] == "."
path = File.join(dirpath, name)
next unless File.directory?(path)
if matching_extension(name)
update_archive path
next
end
if $recursive
$queue << path
end
end
end
def needs_update(bundle_path, archive_path)
return true unless File.exists?(archive_path)
archive_mtime = File.mtime(archive_path)
# The archive exists ... can we find a file inside the bundle thats newer?
# This won't catch deletions, but that's ok. Bundles tend to get completly
# overwritten when any tiny thing changes.
dirqueue = [bundle_path]
until dirqueue.empty?
dirpath = dirqueue.pop
Dir.foreach(dirpath) do |name|
path = File.join(dirpath, name)
if File.directory?(path)
dirqueue << path unless [".", ".."].include?(name)
next
end
# Is this file newer?
if File.mtime(path) > archive_mtime
return true
end
end
end
return false
end
def update_archive(path)
archive = path + ".tar.bz2"
return unless needs_update(path, archive)
if $dry_run
puts "Would create #{archive}"
return
end
puts "Creating #{archive}"
dir = File.dirname(path)
bundle = File.basename(path)
# Could probably fork and do it in a subshell
system "tar --create --file=#{archive} --bzip2 --directory=#{dir} #{bundle}"
end
$opts = OptionParser.new do |opts|
opts.banner = "Usage: prepsvn [options]"
opts.on("-d", "--dir DIR", "Add directory to search (if no directory specify, current directory is searched)") do |value|
$queue << value
end
opts.on("-e", "--extension EXTENSION", "Add another extension to match when searching for bundles to archive") do |value|
$extensions << value
end
opts.on("-N", "--non-recursive", "Do not search non-bundle sub directories for files to archive") do
$recursive = false
end
opts.on("-D", "--dry-run", "Identify what archives would be created") do
$dry_run = true
end
opts.on("-h", "--help", "Help for this command") do
puts opts
exit
end
end
def fail(message)
puts "Error: #{message}"
puts $opts
end
begin
$opts.parse!
rescue OptionParser::InvalidOption
fail $!
end
# If no --dir specified, use the current directory.
if $queue.empty?
$queue << Dir.getwd
end
until $queue.empty?
search_directory $queue.pop
end
I do love Ruby syntax, it is so minimal, and lets me follow my personal mantra less is more.
I'm sure there's some edge cases that aren't handle well, such as spaces in path names and maybe issues related to permissions. But it works for me.
You do need to have tar installed, in order to build the archives. I can't remember if that's built in to Mac OS X (probably) or whether I obtained it using Fink.
In any case, you need to remember to execute prepsvn in your workspace, to spot file bundles that need archiving, before you check in. It would be awesome if Subversion supported some client-side check-in hooks to do this automatically.
It was bound to happen sooner or later, OpenOffice.org caught it’s first worm. Sophos reports the first sightings of an OOo scripting worm in the wild. It uses an OOo document to carry itself. Remarkably, the worm is cross platform and uses perl on Linux, ruby on Mac OS X and JavaScript on Windows to infect other files and distribute itself through instant messaging.
The damage? It looks like the worm does download and display a porn image.
To the delight of Sophos, the presumable author did send the file directly to Sophos address.
User:conficio: Software documentation one screencast at a time

RM-Install is a new, free Ruby on Rails stack developed by FiveRuns, a company that provides enterprise-level management solutions for Ruby on Rails applications. Of course, Rails and Ruby are already available for free, but RM-Install provides you will everything you need in one deployment. The components include Ruby 1.8.6, Rails 1.2.3, MySQL 5.0, SQLite 3.3, Subversion 1.4, Apache 2.2, OpenSSL, ImageMagick, Mongrel (with clustering support), Capistrano, Gruff, Rake and RMagick.
Currently RM-Install is available for OS X (Intel) and Linux only, but versions for OS X (PowerPC) and Windows will follow soon. Perhaps this is the holy grail of getting a Rails development environment up and running (with ImageMagick no less) in minutes?
The freely available Aptana IDE seems to be moving faster than ever. Aptana is a web developer's IDE with extensive Ruby and Rails support through the RadRails plugin. Having announced support for AIR right after Adobe released a Beta, the latest Aptana IDE already supports development for the just-released Apple iPhone.
Among the features that Aptana IDE provides for iPhone developers include:
Check out the Aptana for iPhone development page for more information. They also provided a nice intro to iPhone development screencast for a quick start.
Note: If you like Aptana IDE, you may want to consider joining their team, as they're currently hiring developers.

Erik Kastner has put together a great tutorial showing you how to build a graphical OS X app using Ruby and RubyCocoa. For a less wordy approach, there's also a short screencast which shows you the whole process from start to finish.
With the continual improvements of the RubyCocoa library, and Apple's commitment to Ruby for Cocoa development in OS X 10.5, Ruby is rapidly becoming a viable alternative to Objective C and Java for developing OS X apps.

Another great resource is RubyCocoa.com, a site that features several RubyCocoa tutorials and articles.
It was bound to happen sooner or later, OpenOffice.org caught it’s first worm. Sophos reports the first sightings of an OOo scripting worm in the wild. It uses an OOo document to carry itself. Remarkably, the worm is cross platform and uses perl on Linux, ruby on Mac OS X and JavaScript on Windows to infect other files and distribute itself through instant messaging.
The damage? It looks like the worm does download and display a porn image.
To the delight of Sophos, the presumable author did send the file directly to Sophos address.
User:conficio: Software documentation one screencast at a time

Scruby (not to be confused with the ScRUBYt! site scraping tool) is a Ruby application that works on UNIX-related operating systems and provides a shell where you can perform packet creation, sending and sniffing functions in a Ruby-esque fashion. It looks pretty powerful and the creator, Sylvain Sarmejeanne, has put together a very comprehensive page explaining how it all works.

Over at the O'Reilly Ruby Blog, Jim Alateras laments the recent stalling of development on RadRails, but suggests an alternative solution: E-TextEditor, a "TextMate" alternative for Windows. The initial reports I've read about it are that it's rather good, and after watching the screencast I'd say it looks to be a pretty good editor and I'd give it a try if if used Windows. If you're a Windows user, give it a look.
Now for the editorial bit..
I don't know Allan Odgaard, the developer of TextMate, at all, but I'm a happy user of the editor, despite not understanding almost any of the advanced features. I can't speak on his behalf, so just take the following as editorial waffle, but I think Apple should buy TextMate and release it for free or at low cost (as currently). If Allan isn't interested in selling it, then fine, but if he is, it could be a big win for both him and Apple.
So why? 1) The E-TextEditor homepage mentions TextMate six times. 2) A few people have converted TextMate's snippets to operate in other editors. 3) There's even a 200 page book about TextMate on the market. 4) If you've been floating around the various freenode Ruby and Rails related channels in the past couple of years, you'll have undoubtedly seen at least several Windows or Linux users drop by raving about TextMate and lamenting their inability to buy a Mac. Yet.. they've ended up actually buying a MacBook (or similar) after several months, and continue to rave about TextMate (Jamie van Dyke is one example that sticks in my mind).
These points all demonstrate that TextMate has rapidly become a standard of its own in the text editor market, and it has undoubtedly help OS X become the de facto platform for Rails development. Apple has even acknowledged this and are including Rails with Leopard. People from all platforms have seen TextMate and been captivated by it enough to the point that they lament the lack of its existence on their platform. This doesn't happen with many Mac-only apps, and from what I've read, Allan isn't particularly interested in developing non-OSX versions of the software, so the developers of copycat editors like E-TextEditor are not to blame.
Apple tends to be very good at releasing products that people are afraid of copying too well. Even before iTunes was released on Windows, there was nothing as elegant and as usable. There's nothing quite as good as iMovie, Pages, or Aperture in their respective niches either (although Adobe is trying on the last one). Apple is a fierce defender of its trademarks, and with TextMate under the Apple wing, it could become an even bigger driver for the OS X platform since copycat behavior could be restricted.
I am no fan of trademarks or patents being fiercely defended, nor a fan of Apple owning all of the apples in the cart (pun not originally intended), but from a totally objective point of view, I think it'd make sense for Apple, and if Allan were to turn down, say, a million dollars from Apple, he's a far more principled man than I!
I'm now off to put my flamesuit on..
Matt Neuburg has put together a great article full of examples of using Ruby and AppScript in place of AppleScript to script operations under OS X. I hadn't bothered to try these Ruby->OS X bridges yet, but I followed Matt's simple examples with amazement. It's so simple! Within two pages Matt moves on to using Ruby to instruct Microsoft Excel to produce a graph based on data provided from Ruby and it'll only take you up to ten minutes to read the whole thing and get that far. Excellent piece.
Matt seems to prefer to installing rb-appscript from source, but being a lazy-ass, I installed it in gem fashion with a simple sudo gem install rb-appscript. Your mileage may vary with this technique, but it worked for me.

Mosquito is a new, automatable, testing tool that uses RubyCocoa and OS X to perform Web operations and take screenshots of each point along the way. It's a little like the Windows-only Watir. I can see the technology used by Mosquito also being useful for automating Web operations even without the testing focus.
Rb-AppScript is an event bridge between Ruby and OS X that allows you to get AppleScript-esque control in OS X. The Appscript creators claim Appscript is a 'serious alternative' to AppleScript and it certainly looks good. Check out this example:
AS.app('TextEdit').documents[1].paragraphs[1].get
The equivalent AppleScript?
tell application "TextEdit"
get paragraph 1 of document 1
end te