Ruby Weekly News 26th September - 2nd October 2005


Tim Sutherland

(Web viewers have more fun.)

Ruby Weekly News 26th September - 2nd October 2005

Ruby Weekly News is a summary of the week's activity on the ruby-talk
mailing list / the comp.lang.ruby newsgroup, brought to you by
Tim Sutherland and Christophe Grandsire.

Articles and Announcements

* Rapid GUI Development with QtRuby

Dave Thomas announced the Pragmatic Programmer's new book line,
`Fridays', which are "short, PDF-only books on a single topic."

The first book is "Rapid GUI Development with QtRuby".

| Caleb Tennis has just finished a short book on the QtRuby library,
| which integrates the cross-platform Qt3 library into Ruby. It
| discusses how to create cross-platform GUI applications for Linux
| and OS X in Ruby. It covers installation, basic and advanced
| programming, event models, and Korundum.

"I'm always looking for more material to support the Ruby community:
if you feel you have either a full book or a Friday in you, drop me a

(Discussions followed around QtRuby support for Qt4, and for Windows.
See also [QT 4 Binding], in which Caleb Tennis says he and Richard Dale
are working on porting QtRuby to Qt4, but need someone on Windows to
do testing in order to support that platform.)

* Interview with Swedish downhill ski racer Mikael Borg

Ara.T.Howard: "well, actually he's a postdoc at the university of
toronto who uses ruby in toolset of bits and bytes to study protein
interactions - but that's not quite as catchy a subject now is it?"

Yep, it's another interview for the SciRuby project, "a portal for all
things scientific and ruby."

User Group News

* semich.rb Meeting (Southeast Michigan Ruby Users Group)

Patrick Hurley say'deth "This will be our first meeting. The meeting
is open to the public, please feel free to attend if you have an
interest in learning more about Ruby, and sharing your experiences."

7pm Thursday, September 29 in Ann Arbor if you're interested.

* Next meeting of the Columbia Maryland Ruby on Rails Codefesters

Hey folks, folksied Jeff Waltzer, "its time for another Columbia, MD
Ruby on Rails CodeProject CodeFest", on September 26th.

"We're all learning Ruby and Rails so even if you don't know much
about either please come, join the fun and even If you're running
late, we'd still like you to join us."


SQLite / Ruby on Windows?

David Vallner asked if anyone had an "install-by-copy" version of the
binding for the SQLite embedded database system.

"I'm in sore need of an embeddable SQL database and I admit to being
completely uncapable of compiling Ruby extensions on my Windows box."

Austin Ziegler suggested he just try installing with RubyGems, which
allows you to select a pre-compiled Windows binary, and Jeff Wood expanded
on this.

Outlook calendar

Happy-jack was interested in playing with the Outlook calendar from Ruby.
He'd found some scripts for writing to the calendar, but none to retrieve
the information.

Gregarican posted some code that does this using MAPI (Exchange's mail
API), through Ruby's Win32OLE library.

Also of interest is the ScriptingOutlook page on RubyGarden.

PostgreSQL driver in binary form?

Threads about database drivers on Windows were popular this week!
This one is from Robby Russell asking about a win32 binary for the
PostgreSQL driver, as he couldn't get the pure-Ruby postgres-pr to
work with PostgreSQL 8.0.

Matthew Desmarais said he'd been using postgres-pr with version 8.0
without problems, and asked for more information on the problems Robby was

There were no further replies at `press' time.

With a Ruby Yell: more, more more!

Robert Klemme SHOUTED OUT

| It seems to me that we have a significant raise in "newby" posts in the
| last two or three months. This means Ruby's momentum increases and it's
| attracting more and more people! Folks, this is *great* news! And this is
| such a great place to be! I hope, we can keep it like that.

Keith replied

| Glad to know you guys don't mind our nuby ruby posts! Actually, one of
| the things that I have liked about this group is the relative lack of
| RTFM rude responses! And I hope you are really sincere about dealing
| with more of us - I just disovered Ruby /Rails and have been
| evangelizing like crazy. Heard from one of my friends that a mutual
| friend that I had told about Ruby has been coming down periodically to
| his office to talk about the latest cool thing in the language that he
| had discovered.

Kevin Ballard said, but of course, MINASWAN.

Time interval

Daniel Berger, being confused with the current implementation of the "-"
(minus) operation for Date and DateTime objects, asked the following:

| I was just wondering if anyone has implemented an "Interval" class of
| some sort out there, i.e. something that would give you the years,
| months, days, hours, minutes and seconds between two fixed DateTime
| objects, rather than an absolute date.

Although some people tried to give limited solutions, this spawned a
discussion on how the problem was nearly unsolvable due to the nature of
our calendar, with its variable-length months and years. Dave Howell
summed the problem up very clearly:

| There is no "answer" to this problem because the correct usage is
| tremendously context sensitive.
| There are 58 shopping days until Christmas.
| The convention is in 8 weeks. (58 days = 8.2 weeks)
| Your work on the Monster House must be complete in 2 days, 12 hours, 14
| minutes, and 34.5 seconds.
| The Date class (if I recall correctly) uses Days and fractions of Days
| for the internal representation, and lets you access a variety of
| interval measures. Which ones you use will depend very much on what kind
| of events you're measuring the distance between.

Moreover, mathew added that asking for an interval with a precision under
the hour was basically impossible:

| Suppose you want 1 second precision. Well, unfortunately civil calendars
| have leap seconds, and the moments at which leap seconds will need to
| occur are not defined far in advance. So DateTime(2020-01-01) minus
| DateTime(2000-01-01) can't be calculated to an exact number of seconds.

Is there a hash-like class that maintains insertion order

Bob Hutchison asked if Ruby has a class that behaves like Hash, but also
maintains the insertion order, "and, ideally, allows `retrieval' by either
key or index?"

Ara.T.Howard showed an example using the arrayfields library, which allows
you to `name' the indices of an Array. (Not included in the standard

require 'arrayfields'

a = %w( aaa bbb ccc )
a.fields = %w( a b c )

p a['a'] == a[0]
p a[`b'] == a[1]
p a[`c'] == a[2]

Ara also linked to a class he'd written called OrderedHash, with which
methods like each iterate elements in the order in which they were added.

Dynamically generating classes?

Jonas Galvez posted the following Python code, which is used to create a
class dynamically, and asked if the same could be done in Ruby.

# Python code sssample
.. import new
.. c = new.classobj(name, tuple([object]), {})
.. def __init__(self, value):
.. self.value = value
.. setattr(c, "__init__", new.instancemethod(__init__, None, c))
.. return c

Ara.T.Howard, Austin Ziegler, Greg Millam and Sean O'Halpin all gave
similar solutions, with this one based on Sean's:

MyClass = do
attr_accessor :value
def initialize(value)
@value = value

c =
p c.value # -> 10

Observe that all we are doing is passing a block with no arguments to the

Sean noted that you can use Object.const_set(classname, value) to define a
constant for the class name if it is not known until runtime, while Greg
suggested using struct for simple classes:

require 'struct''MyClass','value')

obj =
puts obj.value

define_method was also discussed; it is used to define methods
dynamically, and allows the body of the method to refer to variables
declared outside it, since the body is simply a block.


David Chesterfield was wondering why `puts' and `self.puts'
behave differently even though writing method without an explicit
receiver is equivalent to sending the message to self.

$ irb
irb(main):001:0> puts "hello"
=> nil
irb(main):002:0> self.puts "hello"
NoMethodError: private method `puts' called for main:Object
from (irb):2

Stefan Lang explained that a private method in Ruby can only be called
with an implicit receiver - that is the only difference between methods
which are private and those which are public.

As puts is a private method, it cannot be called with an explicit
receiver, even self.

Robert Klemme added that one can circumvent privacy by using the send
method, and Devin Mullins warned that methods ending in "=" are a slight
exception to the privacy rule - = 5 works even when foo= is a private method. This is necessary
because we need to distinguish between foo = 5, which creates a local
variable called foo, and = 5, which calls a method.

Splitting a string with escapable separator?

Michael Schuerig was looking for an elegant way to define an alternative
version of String#split in which "separators can be escaped".

"Hello\, World,Hi".split_escapable(',' '\')
# => ["Hello, World", "Hi"]

Jason Sweat said that Ruby 1.9's regular expression engine (code-named
Oniguruma) supports negative look-behind, which you could use as follows:

"Hello\\, World, Hi".split /(?<!\\),/
# => ["Hello\\, World", "Hi"]

This says to split the String around commas, apart from those where the
string immediately before them was \.

(You would have to additionally remove the \'s in the result. Note also
that we'll have a problem if we want a component to end in a literal

The syntax of (?<!...) is described in the Oniguruma documentation, which
lists more neat features, such as atomic, named and non-captured groups,
named sub-expressions and _positive_ look-behind ;)

Michael Schuerig: "That must be the most elegant solution. Unfortunately I
can't use cvs ruby and can't wait for it either."

Warren Brown to the rescue. "With the current Ruby RE engine, you can use
zero-width positive lookahead if you don't mind reversing the string
before and after the split."

"Hello\\, World,Hi".reverse.split(/,(?!\\)/).
map { |ss| ss.reverse }.reverse
# => ["Hello\\, World", "Hi"]

New Releases

Ruby/ZOOM 0.2.1

Laurent Sansonetti announced the 0.2.1 release of Ruby/ZOOM:

| Ruby/ZOOM provides a Ruby binding to the Z39.50 Object-Orientation Model
| (ZOOM), an abstract object-oriented programming interface to a subset of
| the services specified by the Z39.50 standard, also known as the
| international standard ISO 23950.

This release is a bug fix.

(Oh yeah, Z39.50 is a communications protocol, often used in
libraries-having-books for searching and retrieving information.)


Greg Millam:

| FuseFS lets ruby programmers define filesystems entirely in Ruby. That
| is - with FuseFS, you can now create a mounted filesystem entirely
| defined in Ruby! Included are proof of concept filesystems: SQL table
| mappings, YAML filesystem, and more!

The main change from 0.3 is to fix problems around editor swap files (with
e.g. vi or emacs).

"No [more] complaints about your editor being unable to write to
".foo.swp" or filenames like #filename#."

rush 0.1.bandicoot: object-oriented shell goodness (rationed for your health)!

`The rush folks' announced the first version of rush (RUby SHell),
"an attempt to create an extremely flexible fully object-oriented shell in

One nice feature is how it allows you to mix Ruby methods with unix-shell
style piping:

!ls | .map {|file| file + '.bak'}

ShortURL 0.7.0 (and 0.8.0)

Vincent Foley, post-procrastination, sent forth a new ShortURL.

ShortURL is a library for accessing `short url' services like

Instiki-AR beta 1

Alexey Verkhovsky introduced the first beta of Instiki-AR, the
wiki-software modified to use ActiveRecord (with a relational database)
rather than the Madeleine object-persistence layer that plain Instiki

"Unlike Instiki 0.10, this one is a normal Rails application, which means
you can host it on Apache, no more ProxyPass and Madeleine madness."

"Kudos are due to Rick Olson aka technoweenie for doing most of the
initial porting effort."

Alexandria 0.6.1

Laurent Sansonetti announced the 0.6.1 release of Alexandria:

| Alexandria is a GNOME application to help you manage your book
| collection.

This ships a workaround for a Ruby 1.8.3 YAML bug and a modified data
model (that still manages to be backwards compatible with previous

Rant 0.4.6

Stefan Lang's Rant build tool rolled over to version 0.4.6, with fixes for
Ruby 1.8.3 and improved support for buildfiles in subdirectories.

Reiserfs for ruby initial announcement

Adam introduced `Reiserfs for Ruby', a read-only implementation of the
Reiser filesystem, written with the FuseFS user-space filesystem module.

LibIDN Ruby Bindings Release 0.0.1

Erik Abele released the first version of his bindings for the GNU LibIDN
library, "an implementation of the Stringprep, Punycode and IDNA
specifications defined by the IETF Internationalized Domain Names (IDN)
working group."

JRuby 0.8.2

Thomas E Enebo posted an update to JRuby, a Ruby interpreter written in
Java. The new version includes many fixes, and some refactoring.

MouseHole 1.2 -- rose-colored spectacles for the Web

why the lucky stiff, in his own inimitable style, released MouseHole 1.2:

| MouseHole is a scriptable web proxy. Alter the Web with Ruby. Host your
| own little applications. Install scripts off the web as you surf. That
| kind of thing.

"My soup and my spoons thank you. And I eat soup with spoons, may that be
enough thanks for the remainder of you."

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Latest member

Latest Threads