Ruby Weekly News 17th - 23rd January 2005


Tim Sutherland

NB: This edition includes a "Quote of the Week" section, as suggested by
trans. Send in any interesting quotes you see to (e-mail address removed) for next
week's RubyNews.

Ruby Weekly News 17th - 23rd January 2005

A summary of the week's activity on the ruby-talk mailing list / the
comp.lang.ruby newsgroup, brought to you by [Tim Sutherland].

Articles and Announcements

* [[Rails] ONLamp article on Rails] [2]

Curt Hibbs wrote an excellent introduction to the [Rails] web
application framework: [Rolling with Ruby on Rails]. It goes
through the basics of installing Rails and then guides the reader
into creating a simple cooking recipe website. The article was
[covered on slashdot]; Tom Copland [reported] that the One-Click
Ruby Installer was downloaded 1500 times that day, up from the
usual 200-300.

* [re-writing CD Baby from scratch in Ruby, using Rails]

In related news, Derek Sivers [wrote an article] announcing that
[CD Baby] - currently 90,000 lines of PHP and receiving 15,000
unique visitors per day - will be rewritten to use Rails. "Now,
with Rails, there are a team of passionate geniuses contributing
to this web-making framework daily. It's small enough that you can
stay on top of it, and watch this framework get more and more
powerful by the week. Improvements that are pragmatic not
political. People using it to make effective websites,
contributing to the shared framework around it as they go. Why not
take advantage of all this brilliant work?"

* [Ruby Exam - unittest yourself]

Simon Strandgaard wikified a set of "exam" questions about Ruby
that were written some time ago by 'Imperator'. Test yourself at

* [[Ruby Forum] Ruby Jobs category]

Alexey Verkhovsky added a Ruby Jobs category to the [Ruby Forum].
"Programmers: please brace yourselves for an avalanche of
lucrative opportunities" "Employers: please create the
aforementioned avalanche".

* [Fwd: OSCON Call For Proposals Now Open]

Chad Fowler forwarded the 2005 O'Reilly Open Source Convention
call for participation announcement to the list and thought it
would be great to have an energetic Ruby presence there. David
Heinemeier Hansson has already submitted a proposal for a 3-hour
[Rails] tutorial.

Quote of the Week

James Edward Gray II began the [summary] of last week's Ruby Quiz with the

"Quiz creator Jim Weirich shared this wonderful little tidbit with me:

True and slightly off topic story:

The first time I wrote a version of this program, it was on a simple
single board Z80 computer using a FORTH-like language to program it.
I had seeded the program with a single animal (a mouse) and called my
wife in to try it out. I explained the program and she ran the
program. It printed out the words "Think of an animal ...", and then
paused for a few seconds. Then it asked "Is it a mouse?". My wife
turned to me with a look of absolute astonishment and said "HOW did it
know that?".

Yep, she was thinking of a mouse.

Unfortunately, none of the submitted solutions were quite that all-knowing."


Interesting threads this week included:

[Ruby Calibre Help]

trans asked for help cleaning up, documenting and testing a project called
Ruby Carats which will be a large library of additions to Ruby. This is
half of his [Ruby Calibre] project - the other half being Ruby Facets, a
collection of extensions to standard classes.

[RubyScript2Exe and RubyGems]

Erik Veenstra recently added support for RubyGems to RubyScript2Exe (a
tool that transforms a Ruby program into a single stand-alone executable).
He's done some testing "but not in "real" situations" and would like to
know if anyone has successfully used RubyScript2Exe on an application that
loads some libraries via RubyGems.

[Bug#290705: ruby: Ruby is completly vivisected.]

Trevor Wennblom noticed that Ruby 1.8 on Debian GNU/Linux is split up into
several dozen packages, and [reported this as a bug] to Debian. Two
examples are the librexml-ruby1.8 and libdrb-ruby1.8 packages which must
be installed for the 'rexml' and 'drb' libraries to be available, even
though the latter are part of the standard Ruby 1.8 distribution.

Austin Ziegler had witnessed the problems this can cause, "the RubyGems
mailing list has gotten at least three reports of being unable to use
RubyGems on Debian because libzlib-ruby hasn't been installed".

leon breedt pointed out that Perl and Python aren't split up nearly as
aggressively. He also mentioned the idea of having a ruby-core virtual
package that installs all the packages, however "even this compromise was
not deemed acceptable by the Debian maintainers...although this is
complete hearsay as I heard it on IRC, so, take it with a tonne of salt".

[Comparing two files for equality]

Edgardo Hames asked for the easiest way to determine if two files contain
the same data and Joel VanderWerf gave the elegant

require 'fileutils'
p FileUtils.cmp(file[0], file[1])

[[SUMMARY] Animal Quiz (#15)]

Last week's [Ruby Quiz] was by Jim Weirich:

"It works like this. The program starts by telling the user to think
of an animal. It then begins asking a series of yes/no questions
about that animal: does it swim, does it have hair, etc. Eventually,
it will narrow down the possibilities to a single animal and guess
that (Is it a mouse?)."

If it fails to guess correctly, the user is asked to say what the animal
was and give a new question that can be used to distinguish it from the
incorrect answers the program gave. In this way the program learns to
deal with new kinds of animals.

James Edward Gray II summarised the solutions people posted (with much
quoting of Jim). "Everybody solved this one using pretty much the same
technique" which was to represent the problem as a binary tree, where
nodes are questions and the branches correspond to yes or no. Each leaf is
a list of possible animals. The summary also included some ideas from Jim
on problems with this approach and possible improvements.

[[QUIZ] Paper Rock Scissors (#16)]

James Edward Gray II introduced this week's [Ruby Quiz]:

"Your task is to build a strategy for playing the game of Paper Rock Scissors
against all manner of opponents. The question here is if you can adapt to an
opponent's strategy and seize the advantage, while he is doing the same to you
of course."

[Documenting ruby.h and intern.h]

Brian Palmer was writing his first C extension for Ruby and was having
trouble using rb_const_get and related functions (used for looking up
constants). "The Pickaxe 2.0 has a wonderful section on C extensions, for
the most part, but it seems to omit mention of rb_const_get completely.
Took me an hour of searching the ml to even discover its existence."

E S explained how to use the function and Charles Mills suggested
rb_path2class which can be used like

VALUE cGlitVec = rb_path2class("GLIT::Vec");

Charles also felt that all the functions, macros and so on in ruby.h and
intern.h should be documented and to this end volunteered to help with
this. README.EXT has much good information but is incomplete.

E S also volunteered to help and weighed up putting the documentation on a
Wiki versus having it included inline in the Ruby source code (to be
extracted by rdoc).

James Britt [announced] he'd run the Doxygen tool over the Ruby source
code to provide [some documentation on]. This lists all the
functions, macros, structures etc. and their arguments, but lacks the
human touch.

[My regexp stupidity needs assistance before loose all my hair!]

trans. (T. Onoma) was having trouble with regular expressions. He wanted
to match text containing tags like [Hello] and extract the 'Hello'.
Because the regular expression was being "greedy" (which means it matches
as much text as it can), it was matching past the closing ']' so that for
example '[Hello] there [World]' would match as 'Hello] there [World'.

Here are three possible regular expressions. (To simplify the example we
use <Hello> instead of [Hello] so we don't have to escape the '[' and
']'.) The first regexp is incorrect - it is "too greedy" - while the
second and third produce the desired behaviour.


By using the ? modifier, the second regular expression makes the match
non-greedy. The third regexp works by matching a '<' followed by any
number of characters apart from '>' until finally a '>' is reached.

In response to trans' frustration with regular expressions, John Carter
gave some hints for dealing with them.

* "Always use the %r{}x form of regexs. This neatly avoids the leaning
toothpick syndrome when\/matching\/paths" For example, %r{.*} can be
used instead of /.*/. Any characters can be used to bound the regular
expression - the editor of this RubyNews is fond of %r|.*|.

* "The x modifier allows you to use white space and even comments within
the regex to make it readable. (Larry Wall of perl fame regrets he
didn't make it the default...)"

* "Pull the development of the regex outside the development of your
app. Unit tests are good for that, or even if you just make a wee
small script or do it on the command line or in irb."

* "If you are doing it on the command line beware of nasty interactions
between the string and quoting conventions of the shell and ruby."

* "Grow the regex slowly. Start with the smallest thing, make it match.
If you immediately write down a large regex, odds on it will match

[[suby-ruby] Your all time desired fundemental Ruby mod]

trans asked "Let say you're Matz, but without any of the pressures of
keeping up with a previous version of Ruby. What one thing above all
others would you like to see differ about Ruby?" There were almost 100

Glenn Parker suggested support for operating-system threads and several
people concurred. John Carter and Austin Ziegler disagreed and preferred
Ruby's existing threading model, however Austin also wrote "[r]ight now,
Ruby can't be safely used with multithreaded applications or libraries;
that should change if at all possible. This probably means that we need
OS-level threading, but I'd love to keep Ruby's green threads as it's all
that I've ever needed."

Many said a "truly cross-platform GUI" would be great (to quote James
Edward Gray II as an example).

There was a big discussion on changes to the way class variables work, and
Matz also said "nitializing module instance variables are one of the
things I want to fix", but he isn't sure how.

[ruby-dev summary 25373-25479]

Masayoshi Takahashi posted a summary of the Japanese mailing list
ruby-dev. In it, Akr had suggested making the next Ruby 1.8 version warn
when IO#read or IO#readpartial were called with an IO object that had been
set to non-blocking mode. Back on ruby-talk, Florian Gross asked what the
problem was with non-blocking IO.

Tim Sutherland pointed out a post by Tanaka Akira from March 2004 giving
[some reasons why non-blocking IO can be problematic] and Tanaka replied,
this time explaining why non-blocking IO can be useful.

[Best ways to accelerate Ruby's popularity]

Back at the end of 2004, Thursday began a thread thinking about what the
Ruby community can do to make Ruby more popular. The thread has been a
popular one, gathering over 170 responses so far (not counting several
sub-threads that were created).

Ben Giddings reopened the thread this week by suggesting some problems
with current Ruby websites:

* "inconsistent look and feel between the various ruby-related domains vs. rubyforge vs. vs. rubygarden vs. RAA"

* "Duplicated information on every site. RubyForge has a link to report
a bug in Ruby itself, has a link to download Ruby
directly, etc."

* "Most ruby sites home pages are geared towards long-time Ruby users,
and not newbies."

* "Finally, there's the issue of news and discussion. Easily 90% of the
screen space on is dedicated to news, but the last
bit of news was on Christmas."

He later added

"Yeah, as I wrote that, I realized how many important ruby sites there
are out there. Even I know that I'll find Python at, Perl at, but ruby...

Ruby's most central site is "".
Documentation is at ""
Some applications are hosted at ""
Other applications are listed at ""
The old pickaxe, and some documentation is at ""
The wiki is at ""
The mailing list archives are at "" (and

That's a whole lot of URLS, all of which are fairly important.

So right now "" is held by "", who brag about
owning over 15,000 popular surname-based domain names."

There was interest in trying to get this domain for Ruby ([Possible
proposal for domain]), and some RubyCentral folk are working on
the case.

Improvements to the layout of sites like [] were discussed at
length, with several mockups posted.

[Xpath like syntax]

Luke Galea was interested in navigating Ruby objects using a similar
syntax to XPath for XML. This would let you write code similar to
Countries/Provinces/Cities[ @name = "London" ].

Several different syntaxes and implementations were proposed.

New Releases

* [ruby-oci8 0.1.9]

KUBO Takehiro made some API improvements to [ruby-oci8], a library
for connecting to Oracle 8 and later. Support for Oracle Instant
Installer was also added allowing the library to be used without
having to manually install Oracle client libraries first.

* [solaris-kstat 0.2.0]

Daniel Berger was happy to announce the release of [solaris-kstat]
0.2.0, a wrapper for the kstat library which provides kernel
performance statistics under the Solaris operating system.

* [Tar2RubyScript 0.4.4]

Erik Veenstra released [Tar2RubyScript] 0.4.4, fixing a bug to do
with read-only files. Tar2RubyScript transforms a directory of
code into a single Ruby script, simplifying deployment of the

* [RubyScript2Exe 0.3.2]

Erik Veenstra also released [RubyScript2Exe] 0.3.2, fixing some
bugs including one which occured when the path to ruby.exe had a
space in it. This is a tool that collects your Ruby program along
with the Ruby interpreter and libraries into a single compressed
executable for Windows or Linux.

* [WWW::Mechanize alike in Ruby]

Michael Neumann ported the Perl WWW::Mechanize library to Ruby
after reading about the web-testing thread in the Previous
RubyNews. It makes it easier to simulate a web browser client by
handling cookies, automatic redirection, forms and links.

* [Rails 0.9.4: Caching, filters, SQLite3...]

David Heinemeier Hansson announced "[a]nother incredibly strong
release" of the [Rails] web application framework, including a new
caching module, SQLite3 database support, plus the ability to
write code like "45.minutes + 2.hours + 1.fortnight" (the latter
idea was presented by Richard Kilmer at RubyConf 2004).

* [RedCloth 3.0.1 -- Humane Text for Ruby]

[whytheluckystiff] fixed some bugs in [RedCloth] 3, a library for
writing stylised text which can be converted into HTML. It has
support for Textile markup and also limited Markdown support.

* [IHelp 0.2.0]

Ilmari Heikkinen passed out [IHelp] 0.2.0, a library which
provides context-dependent documentation on objects and methods in

* [Text::Reform 0.2]

Kaspar Schiess was proud to announce the first release of
[Text::Reform], a port of the Perl library Text/Reform. It is used
to wrap text in a flexible manner.

* [Lafcadio 0.7.0, 0.6.1: Excessively Clever Query Caching]

Francis Hwang released both a new development version and new
stable version of [Lafcadio], an object-relational mapping library
for use with MySQL. Caching of selects has been added so if a
query is to be performed that is a subset of an earlier query,
results cached in memory will be used.

* [Ruby/ManageSieve 0.2.0]

Andre Nathan improved [Ruby/ManageSieve], a pure-Ruby library that
implements the MANAGESIEVE protocol, allowing one to manage Sieve
scripts. The sievectl tool now supports multiple accounts.

* [Logtails 0.3: integration with KDE]

Bauduin Raphael announced KDE integration for [Logtails], a GUI
tool used to monitor several logfiles at the same time. This
support was contributed by Richard Dale.

* [aeditor-2.1 (megacorp release)]

Simon Strandgaard added folding and bookmarks to [AEditor], a
console editor for programmers.



Tim Sutherland

A couple of corrections and comments.
[[SUMMARY] Animal Quiz (#15)]
----------------------------- [...]
If it fails to guess correctly, the user is asked to say what the animal
was and give a new question that can be used to distinguish it from the
incorrect answers the program gave. In this way the program learns to
deal with new kinds of animals.

This should say "incorrect answer" not "incorrect answers".

Also, I've only just realised that there are two "trans" on the list:
1) "trans. (T. Onoma)"
2) "trans" (a.k.a. Tom Sawyer)

I've probably mixed these two up several times.


* Tim Sutherland said:
Also, I've only just realised that there are two "trans" on the list:
1) "trans. (T. Onoma)"
2) "trans" (a.k.a. Tom Sawyer)

I've probably mixed these two up several times.

I think they are one and the same.



Tim Sutherland

I think they are one and the same.

Ok, that makes things easier. I must sheepishly admit that I thought Tom Sawyer
was a real name, rather than the Mark Twain character.

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