Ruby Weekly News 19th - 25th March 2007


Links are at

Ruby Weekly News 19th - 25th March 2007

Ruby Weekly News takes a look at the week’s discussions on the
mailing list (and its equivalents, the comp.lang.ruby newsgroup and

This edition is brought to you by Tim S. and MenTaLguY.

Articles and Announcements

 * Ruby Hoedown 2007 - the Ruby conference down south

   Jeremy McAnally proudly announces Ruby Hoedown 2007, the first
   regional Ruby conference in the Southern United States.

   "Ruby Hoedown, a joint effort between Raleigh.rb, Atlanta.rb, and
   myself, is going to be held at the Red Hat HQ in Raleigh, NC on 

10-11, 2007."

 * Pledgie drive for Rubinius

   Sam S. ("not a committer to the project, just really excited 

it") noticed the Rubinius developers are trying to raise some
through a “Pledgie drive”.

   > Rubinius is a next-generation virtual machine and compiler for 

> Based loosely on the Smalltalk-80 `Blue Book’ design, Rubinius
> provide a rich, high-performance environment for running Ruby

   As this edition of the Ruby Weekly News was going out, they were 

halfway to the target of raising US$1000, with 11 days left for

User Group News

 * Israel.rb is brought into existence!

   Adam F.: "I am pleased to announce that the Israeli Ruby 

Brigade has
been unleashed upon an unsuspecting world." The first meeting is
April 6th.

 * Mountain West Ruby Conference slides, keynote?

   Videos and presentation slides from the Mountain West Ruby 

2007 are being assembled. DVDs will be free for those who
attended the
conference, available for purchase by others, and the videos will
be uploaded to Google Video.


Generating OOo-Calc charts with Ruby

apanloco is thinking of using Ruby to generate Calc
He’s used the win32ole with Excel to do the same; can something
similar be
done with OpenOffice?

Avdi G.: “Since the OO document format is an XML dialect, it
should be
possible to generate the files directly with e.g. REXML.”

Pulling text from elements with REXML

Paul W. writes:

require ‘rexml/document’
include REXML
file =“Main_News.xml”)
doc =
root = doc.root
puts root.elements[“NewsItem/NewsComponent/NewsComponent[1]/…/hl1”]

This gives “Blueprint to cut emissions unveiled”, but how
you get just the text inside the node?

Peter S. says the #text method does the trick; try

root.elements[…your stuff_here…].to_a.each {|e| puts e.text}

A different approach is suggested by Phrogz: use REXML’s XPath

include REXML
doc =“helloworld”)
p XPath.match( doc, ‘/root/kid/text()’ )
#=> [“hello”, “world”]

Are comments objects?

Stephen B. IV is interested in adding a #help method to his
for the sake of interactive use, and asks whether the comments for a
class are available via reflection.

The answer, of course, is no-Ruby comments are discarded by the
However, Jonas P. points out that Mauricio F.'s fastri
be the next best thing to reflection, and also that irb already
provides a
builtin help primitive which displays the rdoc for an object or

irb(main):001:0> help ‘Object#object_id’

Object#object_id => fixnum
obj.object_id => fixnum

  Returns an integer identifier for _obj_. The same number will be
  returned on all calls to +id+ for a given object, and no two 

objects will share an id. +Object#object_id+ is a different
from the +:name+ notation, which returns the symbol id of +name+.
Replaces the deprecated +Object#id+.

=> nil

Regexp and Prime numbers

ruby -wle “puts ‘Prime’ unless (‘1’ * ARGV[0].to_i) =~
/^1$|^(11+?)\1+$/” 1234

The above is a Ruby translation of a wonderful trick from the Perl
community. Credits to Neil Kandalgaonkar and Abigail for the

Substitute 1234 with any number, and this command will tell you if
prime - using the regular expression engine!

(This is also a great illustration of how “regular expressions” in
Ruby and others are more powerful than regular expressions in
computational theory: Primes is a non-regular language.)

New Releases

oniguruma for ruby initial release

Dizan V. announces the first release of oniguruma bindings for
1.8. Oniguruma, developed primarily by K.Kosako, is the regular
engine used in Ruby 1.9.

With these new bindings, developers can “use the powerful features of
Oniguruma (named groups, look-behinds, etc.) without the need to
to Ruby 1.9 or to patch and recompile the stable version.”

Rassmalog 3.2.0

Suraj K. made several improvements to Rassmalog, “a static blog
engine based on RSS 2.0, YAML, and Textile”.

It features an extensible blog formatting mechanism, easy
and automatic tagging, archiving, syntax coloring, and table of

Getopt::Declare 1.23

gga announces version 1.23 of Getopt::Declare, a library for
option parsing where valid options are specified in the form of
help texts. For example:

require “Getopt/Declare”
args =<<‘EOF’)

-q, --quiet quiet
-f, --files files:if… input files
-n, --number num:n a float number
-i, --integer num:i an integer number


p args[’-q’]
p args[’-f’]
p args.unused

1.23 is primarily a bugfix release.

main-0.0.1 - command line apps for the truly lazy

Ara T. Howard announces the release of main, another in his line of
codeforpeople libraries.

main is “a class factory and dsl for generation main programs real
providing a unified framework for argument processing, environment
handling, help text, and many of the other grotty little bits you
need to
deal with in order to write a classy commandline utility in Ruby.

fastthread 1.0

MenTaLguY announced fastthread 1.0, a C extension which provides
versions of the synchronization primitives in Ruby stdlib’s
replacing the existing Mutex, ConditionVariable, Queue, and
classes with its own implementation.

While the Ruby stdlib thread library was redone in 1.8.6 based on an
earlier version of fastthread, a couple critical bugs snuck in at
time. Consequently, for those using Ruby 1.8.6, the newer version of
fastthread gem is recommended as a hotfix.

Best practice when requiring fastthread from a library is as follows:

require ‘thread’
require ‘fastthread’
rescue LoadError

This will allow your code to work on Ruby versions where fastthread
unavailable or is simply unnecessary (e.g. under YARV or JRuby).

daapclient 0.2.3

Aaron P. announces version 0.2.3 of daapclient, a Ruby client
the iTunes DAAP protocol. It contains log optimizations, a couple bug
fixes, and switches the build system to hoe.


We hoped you enjoyed this edition of the Ruby Weekly News.

Anyone can contribute to the next newsletter - simply visit to summarise
one or more threads from the list. Thanks!