Ruby Weekly News 18th - 24th April 2005

T

Tim Sutherland

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

Ruby Weekly News 18th - 24th April 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
--------------------------

Seeing Metaclasses Clearly
--------------------------

why the lucky stiff wrote an article on metaclasses "(aka virtual
classes or metaobjects), since they still lurk under a shroud of fear
and enigma."

A great many replies ensued, some arguing about the use of the word
"metaclass". Lyndon Samson pointed to a post by Matz from a couple of
years ago that says Ruby does not have meta-classes (maybe the only
one is Class), however every object has a hidden "meta-object" which
is revealed by "singleton class notation", i.e. class << foo; ...; end

Regardless of which word you use, _why's article is very interesting.

Formal presentation proposals now being accepted for RubyConf 2005
------------------------------------------------------------------

On behalf of Ruby Central, Inc., David A. Black announced that formal
presentation proposals for RubyConf 2005 are now being accepted.

"*** PLEASE NOTE *** that you must submit a formal proposal, even if
you submitted a preliminary proposal when you preregistered."

Submissions are open until May 27, 2005.

Conference Hotel/Venue info for RubyConf 2005
---------------------------------------------

David also announced venue information for RubyConf 2005. The
conference Hotel is Lafayette Hotel & Suites in San Diego. A block of
rooms has been reserved for $79.99 (+tax) per night for October 13, 14
and 15.

"Pre-registration has been pretty massive compared to previous years.
We've set aside an accordingly large number of rooms, but would still
advise you to make reservations early."

Internet Problem Solving Contest
--------------------------------

James Edward Gray II conferred, "As the resident programming challenge
junkie, I feel the need to point out all the cool contests when they
come up."

The Internet Problem Solving Contest has opened registrations for
their event on May 13th.

"The contest generally involves around eight problems most of which
will have easy and hard variations. The format is that they describe
the problem and provide the input. All they want back is the output,
so you can use any tools you like."

Ruby User Groups
----------------

boulder_denver.rb
-----------------

Ara.T.Howard: "you know the drill - this is a call for boulder/denver
rubyists to get together and talk shop. drop me a note if you're
interested and i'll put together a list and plan a meeting over
coffee, beers, or both ;-)"

Lee Marlow recalled a thread about this in February on the Rails list.
Someone had volunteered office space for the meetings too.

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

David Heinemeier Hansson announcing a new feature of Rails 0.12.0:

"The time had come to butcher the piggy-back query and introduce real
association loading through outer joins. Behold, the glorious eager
loading of associations that makes it silly easy to fetch not 1, 2, but
unlimited associations alongside any record in a single query. Turning
50 database queries into 1 never felt this good."

Threads
-------

Interesting threads this week included:

Question: Time efficiency of Array <<
-------------------------------------

Peter Suk wanted to know the time complexity of the Array#<< method.
(In its simplest form it adds an object to the end of the Array.)

Eric Hodel pointed out the method's implementation at rb_ary_store in
array.c, which showed that the underlying capacity of the Array is
increased by 50% (multiplied by 1.5) when the size reaches its capacity.

Peter concluded that the amortized time of Array#<< was therefore O(1).

apache /fcgi: prevent starting of multiple fcgi processes
---------------------------------------------------------

benny was using ruby-fcgi under Apache 1.3x. Under heavy load, Apache
would create extra fcgi processes. This was a problem since benny was
caching some data in the main process that he wanted to share between all
requests.

Saynatkari gave a couple of Apache directives to give benny the behaviour
he wanted:

FastCgiServer -processes 1
FastCgiConfig -minProcesses 1 -maxProcesses 1

Saynatkari added "In general, I would have to waggle my finger in warning
against such practice :)"

These directives worked for benny after he added "-processSlack 1" to the
FastCgiConfig parameters.

RUBY port to HPUX 64-bit PA-RISC 11.11
--------------------------------------

Jon Miller was looking for a binary distribution of Ruby for the HPUX
operating system.

Jamis Buck said that he used HPUX at his previous job. As far as he knew,
there was no pre-built binary. Furthermore, he could not enable Ruby's
pthread support on that platform - attempting to do so resulted in the
build process crashing.

Alexey Verkhovsky tried the latest stable snapshot, and found that it does
now work with --enable-pthread.

Jamis: "Wow, yes, this is fantastic news."

Idea for Ruby Quiz - Su Doku solver
-----------------------------------

Lyndon Samson had an idea for a future Ruby Quiz. Su Doku is a logic
puzzle, made up of a 9×9 grid, which is then organised into 9 boxes (each
of which contains 9 squares).

Some of the squares contain numbers. To solve the puzzle, you must fill in
the rest of the squares so "every row, every column, and every box
contains the digits one to nine".

Douglas Livingstone suggested making the quiz problem about writing a
program to generate new puzzles, rather than solving them.

Bill Guindon found a quote from the creator of the game, Wayne Gould, who
indicated that his program that creates new So Doku puzzles was written
over 6 years. "If somebody does this in 3 days with Ruby, it's probably
gonna make this guy cry."

HighLine
--------

James Edward Gray II posted this week's Ruby Quiz.

"When you stop and think about it, methods like gets(), while handy, are
still pretty low level."

Instead, this quiz asks participants to develop a module called HighLine
that allows you to write code like

age = ask("What is your age?", Integer, :within => 0..105)

Francis Hwang cast eyes towards his EasyPrompt library, which does this,
more or less. No matter! As Dave Burt said, "I think it's a good one for
any newbies out there to have a shot at. Reinventing wheels is a good
thing to do for the purpose of learning to program."

James later added "I myself am eternally grateful to all the people who
work the quizzes and submit ideas to me. Without all the wonderful help, I
would be sunk. Thanks so much!"

"The Ruby Quiz site has become a killer resource for just reading
interesting code, if I do say so myself. There are some really great
idioms in the solutions all over that site."

translation of ruby/tk?
-----------------------

Tom Nakamura couldn't find English documentation for Ruby/Tk. Does it
exist, or is there only Japanese documentation?

Benjamin Peterson said he'd posted a rough translation of the Japanese
docs.

the Ruby Programming Shop
-------------------------

pat eyler announced the "Ruby Programming Shop".

"It's no secret that there is a lot of Ruby code out there that needs to
be cleaned up (it's old, untested, undocumented, and maybe even
abandoned). The RPS povides a way to `rescue' that code and make it
shine. We'll limit ourselves to free software, and will contact the
original author (when possible) to get his/her blessing."

"Right now, we need to flesh out our list of libraries to work on, and
select a library for May/June. Come on in, sit down, and help make Ruby
shine!"

uninstalling earlier versions
-----------------------------

Lionel Thiry asked if there was a way to uninstall all RubyGems on his
system, apart from the latest versions and their dependencies.

Chad Fowler explained that it's as easy as "gem cleanup".

accessor for Class Variable
---------------------------

Leonardo Francalanci had some code similar to the following

class Outing < ActiveRecord::Base
@@planningList = [ "YES", "NO", "YES/NO"]
end

How could he define an accessor for the class variable without using def
(similar to how you might use attr_reader on an instance variable).

Nicholas Seckar said that Rails provides a cattr_reader for this purpose.

class Outing < ActiveRecord::Base
@@planningList = [ "YES", "NO", "YES/NO"]

cattr_reader :planningList
end

As an alternative, Robert Klemme suggested using a class instance
variable.

class Outing < ActiveRecord::Base
@planningList = [ "YES", "NO", "YES/NO"]

class << self
attr_reader :planningList
end
end

accessing a ms exchange server
------------------------------

Peña, Botp was looking for advice on how to write Ruby code that
accesses/edits the directory of a Microsoft Exchange server.

Ira Burton has managed this via LDAP; "It works like a champ!"

Obtaining Hal's "The Ruby Way" in the UK
----------------------------------------

Glenn Smith tried ordering "The Ruby Way" from Amazon. After 6 weeks they
told him they were unable to get a copy.

Help!

There were some suggestions of places to find second hand copies, plus a
post from the book's author, Hal Fulton.

He noted that the book is available online if you buy a subscription at
O'Reilly's Safari.

3Cheers4David
-------------

Trans exclaimed "Three cheers for David A. Black. For all that he's given
to the Ruby community, from creating RCRchive.net to answering all those
silly nube questions. We love you David :)"

Ryan Leavengood added "Don't forget all the work he has done over the
years setting up the RubyConf, along with the other RubyConf organizers.
We all appreciate your effort guys."

Chris Pine: "Hey, while we're at it, there's always ts! (What does the
`ts' mean, Guy?) He's also been a huge help over the years. And there are
others: why, DHH, and pragdave have all made huge waves in our little (but
growing!) pool."

ruby-dev summary 25962-26010
----------------------------

Masayoshi Takahashi posted the summary of the Japanese mailing list
ruby-dev.

Matz will be releasing Ruby 1.8.3 shortly, so contributors "who want to
update their libraries should commit their patches ASAP."

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

RubyLexer 0.6.0
---------------

vikkous was pleased to announce RubyLexer 0.6.0, a "standalone lexer
of ruby in ruby". It can tokenize almost all Ruby source code that
works with Ruby 1.8. There was some discussion, and vikkous said that
the advantage of RubyLexer over the lexer in irb was that the former
was more complete.

Reg 0.4.0
---------

vikkous announced the first version of Reg, "Ruby Extended Grammar".
It is a library providing regexp-like pattern matching for a variety
of data structures, particularly Array, Hash and Object structures -
not just Strings.

For example, +[Array, Integer] matches an Array containing exactly two
elements, the first of which is another Array, the second an Integer.

Ruby-FLTK 0.9.1
---------------

Jeremy Henty posted his first release as the new maintainer of
Ruby-FLTK - the bindings to the FLTK GUI library.

Thanks to Jeremy for volunteering to take over this project!

Typo 2.0
--------

Tobias Luetke was proud to announce version 2.0 of his web log
software.

"What started as a toy project while I was waiting for a client at
starbucks now became a prestige open source project with tons of
modern features a dedicated dev team and even its own hosting
service!"

New features include a web administrative interface, spam protection
(thanks to Patrick Lenz), "Ajax galore", permalinks, and more.

RubyInline 3.3.0 Released - now with packaging support
------------------------------------------------------

Ryan Davis slipped out the latest RubyInline release. It allows you to
embed C and C++ code directly within Ruby source files.

Support for RubyGems and Rake was added.

webgen 0.3.3
------------

Thomas Leitner introduced webgen 0.3.3, a tool that generates web
pages from page description and template files.

Major changes include improved logging, a better command-line
interface and bug fixes.

Stemmer 1.0.1 - Porter Stemmer Gem
----------------------------------

Matt Mower released a RubyGem containing an implementation of the
Porter word stemming algorithm. (To turn e.g. "testing" into "test".)

He thanked Ray Pereda for porting the original code from Perl to Ruby.

Ruby/Odeum 0.2.1
----------------

Zed A. Shaw released a RubyGem for Ruby/Odeum, a binding to the QDBM
Odeum inverted index library. (To efficiently search documents for
words.)

A bug was also fixed.

Thanks to Jeremy Hinegardner for helping with the gemification.

Rails 0.12.0: Eager associations, new Base.find API,
assertions revisited, more Ajax!
----------------------------------------------------

David Heinemeier Hansson let another major Rails release out of the
bag.

Rails now has "real association loading through outer joins."

This means that a single query can fetch any number of associations
alongside a record.

The following example was given,

# Turning N+1 queries into 1
for post in Post.find:)all, :include => [ :author, :comments ])
puts "Post: " + post.title
puts "Written by: " + post.author.name
puts "Last comment on: " + post.comments.first.created_on
end

The API for Base.find has been enhanced to match. For example,

Person.find:)all, :conditions => [ "category IN (?)", categories],
:limit => 50)

Another major feature of the release was better Ajax support. It's now
easier to develop sites which provide a rich interface to
Javascript-enabled browsers while still working when Javascript is not
available.

This release of Rails is also fully backwards compatible with the
previous version (0.11.1). Nice one!

Rails 0.12.1: No major update without a bit of pain
---------------------------------------------------

David Heinemeier Hansson: "There's nothing like pushing a new major
update in order to find bugs in the code when its exposed to a couple
of hundred working applications."

That meant the release of Rails 0.12.1 to fix bugs that were found in
the 0.12.0 version.

To update, run

gem install rails --include-dependencies

(Easy, isn't it?)

ParseTree 1.3.5
---------------

Ryan Davis intoned, "ParseTree is a C extension (using RubyInline)
that extracts the parse tree for an entire class or a specific method
and returns it as a s-expression (aka sexp) using ruby's arrays,
strings, symbols, and integers."

Dynamic exception handling was added, as was an option to help with
core classes. A bug in the gemspec was also fixed.

iTunesTagger.rb 0.1
-------------------

Scott Parkerson posted a script that lets you treat the "grouping"
field in iTunes as a comma-separated list of tags.

"This can aid in creating smart playlists. Trust me."
 
R

Ryan Davis

RubyInline 3.3.0 Released - now with packaging support
------------------------------------------------------

Ryan Davis slipped out the latest RubyInline release. It allows
you to
embed C and C++ code directly within Ruby source files.

Support for RubyGems and Rake was added.

I did a very poor job of writing up the description for the changes...
I plan on blogging a much better description soon and I hope to fold
that back into the doco...

That said, what we really added is the ability to package and
distribute actual binaries so you can run rubyinlined code on 'puters
that don't have compilers on them.
 

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,818
Messages
2,569,727
Members
45,675
Latest member
benn

Latest Threads

Top