Ruby Weekly News 14th - 20th March 2005

T

tim.sutherland

http://www.rubyweeklynews.org/20050320.html

Note: I may have accidently posted this twice - my usenet connection is
playing up. Please send any feedback to (e-mail address removed) rather than
the gmail address this post is sent from.

Ruby Weekly News 14th - 20th March 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.

Articles and Announcements
--------------------------

* RubyGems Documentation Site

Jim Weirich announced the RubyGems Documentation Site, replacing
the
previous Wiki-based documentation. It now uses the Hieraki
application
(which is also used for the official Ruby on Rails
documentation).

* 2005 International Obfuscated Ruby Code Contest

Todd Nathan announced the "final stretch" of the 2005
International
Obfuscated Ruby Code Contest (IORCC). "In addition to a covented
right
of claiming you are most obscure Ruby coder for 12 months time,
you
also have a shot at over 750 USD worth of prizes", from a number
of
sponsors.

The deadline for submissions is midnight on March 31, 2005.
(It's not
clear what timezone.)

Quote of the Week
-----------------

Paul Duncan enthusiastically announced Raggle.

"After a more than a year of near-death rescue missions,
high-speed car
chases, and hair-splitting battles with evil masterminds, the
mysterious
Raggle Task Force (Codename: R4) has emerged once again to release
Raggle 0.4.0, the most powerful Ruby-based console RSS aggregator
humanity has ever seen!"

Threads
-------

Interesting threads this week included:

nonblock extension for win32?
-----------------------------

We covered this thread last week, but there were some significant
additions this time around. Bill Kelly asked if it was likely that
some of
the libraries in Win32 Utils would become part of standard Ruby.
Daniel
Berger replied "No. At best some of the Win32 Utils packages might
be
included with the one-click Installer."

Curt Hibbs responded positively, saying "I would really like to
include
some/many/all of the win32 utils in the one-click installer. But I
am way
over extended. I'll get to it eventually, but if someone wants to
help out
it would speed things up."

Later on, Shashank Date announced a One-click installer for
win32utils
that makes it much easier to install the win32utils packages.

Advice on PDF::Writer
---------------------

Austin Ziegler is "in the middle of a major overhaul to
PDF::Writer",
including many API changes. He's almost ready to make a release, but
the
API for tables is still being worked on. Should he release now, and
then
make another API-incompatible change later, or wait?

Several people thought he should release it now. vruz:

"Having the thing out will help to improve things faster and
relieve
Austin from the pressure of packing everything in a short period
of
time.

Another good reason for releasing now is not all generated
documents
will make use of tables."

One Click Installer
-------------------

DaZoner asked if there would be a new release of the Ruby One-Click
Windows Installer beyond 1.8.2-14 anytime soon?

Wolfgang Nádasi-Donner said he'd had problems with using irb with a
German
keyboard in the latest release. Stephan Kämper posted a link to the
solution.

Curt Hibbs attempted to reply, but didn't actually write anything.
Perhaps
we'll find out his answer next week!

Ruby UTF-8
----------

Peter C was writing a Ruby program which included Japanese strings
(encoded in UTF-8).

He was getting errors like

c:\> ruby -Ku myFile.rb
jpn.rb:1: undefined method `' for main:Object
(NoMethodError)

The file was created in Windows notepad.

Wolfgang Nádasi-Donner explained that notepad writes a "Byte Order
Mark"
(BOM) at the beginning of UTF-8 encoded files.

Florian Gross suggested a workaround:

"Another one is to have an assignment to a scratch variable at the
beginning of the script. Ruby will parse the BOM as the part of
the
variable name and thus not complain about it."

Florian had posted a comment about this issue on ruby-core some
months ago
and thought Ruby should be able to accept files with a BOM.

Naming tips for popen4-style library?
-------------------------------------

Jonathan Paisley wrote a new popen library featuring an OO
interface,
independent access to stdin, stdout, stderr, plus the ability to
send
signals to a child process and get its exit status. It is also
thread-safe.

He has initially called it Popen4 (the name of the Python library it
was
modelled after), but is looking for a better name. (He later
suggested
"ChildProcess".)

Daniel Berger recalled an Open4 class written by Ara Howard a year
ago.
This returned the pid of the child process as well as the streams.
The
win32-open3 package has an Open4 module that uses the same API as
Ara's.

Daniel felt that the Ruby community should try to reach consensus on
the
API for this feature.

Jonathan had previously discussed this issue with Ara and agreed
that it
would be good to decide on an API and behaviour.

Opening for an entry level position in SLC Utah
-----------------------------------------------

A job to develop a Ruby on Rails application was posted. Jeremy
Kemper
said that people looking for Rails work should list themselves on
the
AvailableForHire page on the Rails wiki.

There is also a job postings page.

async http request
------------------

Bob Aman was writing a Rails application (a common theme these
days). He
has a page which needs to query a web service, retrieve some RSS
feeds and
do SQL queries. Currently he was executing these one after the
after. How
could he do them all at the same time?

James Britt said he should use threads.

Codefest Grant - RubyGems cleanup and enhancement
-------------------------------------------------

Continuing this thread from last week, Mauricio Fernández responded
to a
question about the status of RPA (Ruby Production Archive).

"The port/package manager (rpa-base) and the incipient
infrastructure
(repository, VCS, wiki) are unsatisfactory under our (admittedly
severe)
criteria. They will undergo major restructuring. Had they been
deemed
adequate, RPA would have been proposed for widespread public
consumption
long ago, but it was in a testing phase for a reason."

As far as the idea of combining RubyGems and RPA, Mauricio argued
that
they have fundamentally different goals. For example, RPA aims to
work
with existing tools (like rpm, FreeBSD ports etc.) and provide
packages
created by a dedicated team. In comparison, RubyGems is intended to
be
used instead of rpm etc. and packages are usually created by whoever
developed the application or library.

Mauricio also said he would appreciate it if RubyGems developers
would
describe their goals in a similar way to the RPA Manifesto.

Chad Fowler said he did not want RubyGems to have a manifesto, but
gave
his take on the purposes of RubyGems:

"1. A package format for Ruby libraries and applications.
2. A system for managing installation of such packages from both
local
and remote sources.
3. A "master source"/repository for such packages.
4. Intended to be Ruby's standard for package creation and
distribution."

Austin Ziegler disagreed with Mauricio's comments, saying

"Nothing about RubyGems *prevents* any of the above. Nothing. The
gemspec
can be translated into "native" tools, and the RPA-base layer
could be
implemented on top of RubyGems as a platform (e.g., making the
sitelibdir and DATADIR support work), and since Matz seems to have
indicated that RubyGems will become part of the core when it's
ready,
then it will work transparently."

There was some push-back on that last part - Matz had previously
said he
wanted the RubyGems and RPA teams to agree on a common system. Matz
clarified,

"I just don't want to discourage one side by merging another. If
RPA camp
say "OK, we go our way, nevertheless Gems merged in the
distribution",
that's fine for me. Did they?"

There was no answer at the time this edition "went to press".

RubyURL.com
-----------

Robby Russell created the site http://rubyurl.com/ to get his feet
wet
with Rails. It takes a long URL and returns a link like
http://rubyurl.com/Hcq7h that forwards you to the real site.

There was some discussion of the approach taken. Thomas Hurst
pointed out
qurl.net, a Ruby-based link-forwarding server he'd written.

Hal Fulton asked

"Had you considered a scheme in which the original domain name is
part of
the shortened URL?
http://rubyurl.com/www.yahoo.com:ajZkXDls
That way we could at least confirm what domain we were directed
to."

eval/binding question
---------------------

Stefan Kaes discovered that

def test1
eval "x=25"
eval 'print "x=#{x}\n"'
end

test1

def test2
eval "x=25"
print "x=#{x}\n"
end

test2

produces

x=25
test.rb:189:in `test2': undefined local variable or method `x' for
main:Object ( NameError)
from test.rb:192

So test1 finds the variable, but test2 doesn't.

Matz explained

"local variables should be determined at compile time, thus local
variables defined first in the eval'ed string, can only be
accessed from
other eval'ed strings. In addition, they will be more ephemeral in
Ruby2, so that these variables will not be accessed from outside.

In summary, I recommend you not to use local variables for your
purpose.
They are wrong tool for it."

Stefan felt that it would be better to allow the variables to be
accessed
from outside, and Matz responded

"But it's not good strategy to persuade me to use "your
expectation" or
"your surprise". This "limitation" has a lot of good aspects, such
as
better performance, better error detection, etc. I'd love to pay
the
cost of small restriction for these benefits as a language
designer."

Stable sort?
------------

Hal Fulton wanted a "stable" sort algorithm, i.e. one where if two
elements are judged to be equal in the ordering (where <=> returns
0) they
end up in the same order relative to one another in the output as
they
were in the input.

Ruby's Enumerable#sort uses the Quicksort algorithm, which is not
"stable".

Matz thought that the following would be a slightly inefficient
solution,
but not too bad:

n = 0
ary.sort_by {|x| n+= 1; [x, n]}

MS Windows automation - howto use it?
-------------------------------------

Axel wanted to automate an application using the WIN32OLE library.
How to
you get from the following code to something that works for a
different
application? What should the argument to WIN32OLE.new be, and how do
you
find out what methods are available on the resulting object?

ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome

Thomas pointed out the #ole_methods method. This tells you what
methods
the underlying COM interface supports, but not what arguments they
expect.
Adelle Hartley pointed to an OLE Object Browser written in Ruby that
provides more information.

Dave Burt decided to write his own OLE browser.

Ruby mentions at Microsofts Competitive Influentials Summit
-----------------------------------------------------------

Gordon Hartley noticed some references to Ruby in a blog.

`Richard Monson-Haefel asks "Is there a place for AOP in .NET or
is it
too sophisticated for your developers." Don's take is "My
development
platform should allow me to write code w/ a couple of beers in
me." He
ragged a bit on Java developers and said their main problem is
they
think they're smarter than they are. He also said that if he could
change one thing at MSFT, it would be that Ruby becomes the
language of
choice.'

Examples for racc?
------------------

Ben Giddings wanted some examples of code that use the Racc parser.

Charles Comstock suggested looking in the sample or test directories
of
the Racc source tarball, and Luke Graham mentioned LittleLexer as an
alternative parser.

Using C++ libraries in Ruby
---------------------------

T E wanted to know if it was possible to use C++ libraries from
Ruby.

Nikolai Weibull referred to the ruby embedded into c++ page by Simon
Strandgaard. It shows how to access C++ classes from Ruby, as well
as Ruby
classes from C++.

Ruby works well with C, so an alternative is to simply access the
library
via a C interface.

Texas Hold'Em
-------------

Matthew D Moss came up with this week's Ruby Quiz,

Interpret sets of hands in the "Texas Hold'Em" card game (a
variation of
Poker), to report "Full House", "Two Pair", "Flush" etc.

There was some fun discussion about poker.

Wanted: A nice clean ruby app to disect
---------------------------------------

Curt Hibbs was part of a new Ruby User's Group in Saint Louis,
Missouri in
the U.S. "About 90% of our members are new to Ruby, and we decided
that a
good way to get started would be to dissect the code of a Ruby app
to
learn Ruby and its idioms first-hand from *real* code."

What applications would the community recommend?

James Edward Gray II suggested the Ruby Quiz solutions. Mike Clark
thought
RubLog would be worth looking at.

Paul Graham recommends Ruby
---------------------------

Joe Van Dyk read an article by Paul Graham on his recommendations
for
undergraduate computer science students and noticed that it
recommends
Ruby.

If you want to work at a cool little company or research lab,
you'll do
better to learn Ruby on Linux.

how do you duck-type something to String, so String believes you?
-----------------------------------------------------------------

Sam Roberts had implemented a class which defined #to_str (which
indicates
that the class should be considered a String, as opposed to merely
defining #to_s). "That's all fine, but that doesn't mean that String
will
allow itself to be compared to my class." (Via String#==.)

Navindra Umanee warned that

"String is also strongly-typed in C as T_STRING, so Ruby
duck-typing is
not going to save you here. Ruby is riddled with that sort of
thing,
probably for efficiency and implementation reasons."

ES said that the String#== method turns str==other into other==str
if
other is not T_STRING. This means that Sam simply needs to define an
#==
method in his class that compares against a String.

New Releases
------------

* PageTemplate 1.2.0

Brian Wisti improved PageTemplate, a library for using text
templates
in web projects. Additions include comment syntax and unless.

* Alexandria 0.5.0

Laurent Sansonetti released Alexandria 0.5.0. It is a GNOME
application for managing book collections. Export-to-XHTML
support has
been added, as has support for loaning, books without ISBN
numbers,
and many bug fixes.

* FastCST 3.0, FastCST 0.4: SMTP+POP3 Distribution, FastCST 0.4
Packaging Fix

Zed A. Shaw put up another release of FastCST, an experimental
changeset tool. Version 0.3 added YAML meta-data support for
changesets, plus get and put commands. Version 0.4 added send,
recv
and read commands to integrate the tool with email.

A tutorial was also written.

* Orbjson 0.0.4 released

James Britt added support for asynchronous requests to Ruby
Orbjson.
This library provides Ruby-Javascript integration for JSON-RPC
requests, making it easier to write web applications which use
Ruby on
the server and Javascript on the client. He later announced a
tutorial
he'd written for the library.

* MuraveyWeb-Ruby CMS

Dmitry V. Sabanin announced the first public release of
MuraveyWeb, a
CMS built with Ruby on Rails. It features separation of content
and
views. "With MW you can create and manage your content and then
using
MW API and Ruby On Rails you can build views to display it the
way you
like."

* RubyGems 0.8.7, RubyGems 0.8.8

Jim Weirich announced RubyGems 0.8.7, a popular tool for
packaging and
installing Ruby programs and libraries. This was quickly
followed by
RubyGems 0.8.8 to fix an important bug for developers who create
..gem
packages.

"First the numbers, 220 different gems available, over 25,000
downloads of RubyGems, and nearly 190,000 gems downloads."

New features include a cleanup command to delete old versions of
a gem
and dependency to show dependencies. A library called
gemconfigure has
been written to allow a Ruby program to be version sensitive
without
depending on RubyGems where that capability is not needed.
Another
addition is gemwhich, a program to help users to locate
RubyGems-managed files.

* Ruby/LDAP 0.9.1: LDAP API (RFC1823) library

Ian Macdonald recently took over maintenance of Ruby/LDAP from
Takaaki
Tateishi. The latest release includes some API tweaks.
Connections can
now be rebound with new credentials and an LDIF module has been
added.

* RbTET a Ruby TET API binding

Neil Moses announced the first release of a Ruby binding to TET
(Test
Environment Toolkit).

* webgen 0.3.1

Thomas Leitner released a new version of webgen, a tool for
creating
web pages from page description and template files. Major
changes
include improved picture gallery support, automatic validation
of HTML
files and configurable page file output names.

* Nitro + Og 0.13.0

George Moschovitis improved Nitro (a web application framework)
and Og
(an object-relational mapper). Nitro now has a Mailer subsystem,
an
AJAX example (which shows how to develop a Google Suggest-style
UI),
and a Rails compatible directory structure. Og is better
separated
from Nitro, has database-related validations and many bugfixes.

* Pimki 1.6

Assaph Mehr released Pimki 1.6, a PIM based on the Instiki Wiki.

* Ruby/ZOOM 0.1.0

Laurent Sansonetti was "happy to announce the first 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." (Used mainly for book
information retrieval.) It will be integrated into the next
release of
the Alexandria book collection manager.

* One-click installer for win32utils

On behalf of the win32utils team, Shashank Date announced
version
0.0.3 of the "one-click installer for win32utils".

"This installer will install win32utils modules which are
compatible
with the latest one-click installer for Ruby on the Windows
platform."

* Kashmir/Elusion 0.2

Christian Neukirchen set out the first public release of
Kashmir/Elusion, a templating engine that "tries to walk on the
small
path between the mess of raw evaluated Ruby like ERB and the
clinical
sterileness of data-driven templating like Amrita."

* RhizMail 0.1.0

Francis Hwang release RhizMail 0.1.0, a "test-friendly" library
for
sending out emails that are customised to the destination user.

* Raggle 0.4.0

Paul Duncan warned "It's SHOCKING... It's DARING! It's
INCREDIBLE!!"
It was in fact Raggle 0.4.0, a web and console based RSS
aggregator.
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top