Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Ruby Weekly News 6th - 12th February 2006 (http://www.velocityreviews.com/forums/t828692-ruby-weekly-news-6th-12th-february-2006-a.html)

Tim Sutherland 02-15-2006 09:47 AM

Ruby Weekly News 6th - 12th February 2006
 
http://www.rubyweeklynews.org/20060212.html

Ruby Weekly News 6th - 12th February 2006
=========================================

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

[ Contribute to the next newsletter ]

User Group News
===============

* OK.rb's First Meeting
-----------------------

James Edward Gray II announced the first meeting of the Oklahoma Ruby
Users Group: March 14th 2006 at the University of Central Oklahoma.

| This first meeting is being organized by myself and Grant Schofield
| and we will be providing some educational content to get us going. I
| will give a "Uniquely Ruby" talk, focusing on those things that make
| Ruby stand out from other languages. Grant is giving a first-look at
| Rails presentation as well. Both talks will be aimed at Ruby
| programmers of all skill levels.

* Boulder-Denver Ruby Group - February 15th
-------------------------------------------

Marty Haught said that the Boulder-Denver Ruby Group are holding their
February meeting on Wednesday 15th.

"David A. Black will be joining our group that night and will be
presenting for our group."

* February Ruby events in the SF Bay Area
-----------------------------------------

Rich Morin posted a list of Ruby events in the San Francisco Bay Area
during February.

The SF Ruby Meetup is on the 21st, and the Beer & Scripting SIG is on
the 22nd.

Quote of the Week
=================

* Ruby's lisp features.
-----------------------

> Ruby is a language designed in the following steps:
>
> * take a simple lisp language (like one prior to CL).
> * remove macros, s-expression.
> * add simple object system (much simpler than CLOS).
> * add blocks, inspired by higher order functions.
> * add methods found in Smalltalk.
> * add functionality found in Perl (in OO way).
>
> So, Ruby was a Lisp originally, in theory.
> Let's call it MatzLisp from now on. ;-)
>
> matz.


Threads
=======

FasterGenerator (#66)
---------------------

James Edward Gray II came up with this week's Ruby Quiz.

> Ruby includes a useful Generator library for switching internal iterators
> to external iterators. It is used like this:
>
> require 'generator'
>
> # Generator from an Enumerable object
> g = Generator.new(['A', 'B', 'C', 'Z'])
>
> while g.next?
> puts g.next
> end


Ruby's standard Generator class was recently re-written to improve
performance. Your mission is to make it even faster.

Matz: "I'd be happy to replace current implementation of generator.rb with
the winning one."

Some very promising benchmarks were posted.

Getting last character from a string
------------------------------------

draco draco asked for a nice way of getting the last character in a
String.

Several people said that you can use negative indices to count backwards
from the end of String and Array objects, for example -1 for the end, -2
for the second-to-last etc.

Based off a post by Gennady Bystritsky,

s = "abc"
s[-1] # 99
s[-1].chr # "c"

Adding properties to a method?
------------------------------

jonT wanted to know how to add `properties' to Method objects.

#####
class Method
attr_accessor :foo
end

def bar
"some_res"
end

method(:bar).foo = 1

puts(method(:bar).foo) # => nil instead of 1
#####

The problem is that method(:bar) returns a new Method instance each time
it is called.

As is often the case, the Facets project has a solution. It includes
method!, which returns the same Method instance each time it's given the
same method name.

(Not so good if some code redefines the method in between two calls to
method! though.)

Ruby port for Nokia 770 Wireless Internet Tablet
------------------------------------------------

Ken Hilton successfully ported Ruby 1.8.4 to the "Nokia 770 Wireless
Internet Tablet" (which runs Linux).

"Before porting Ruby to it, it was love at first sight. Now I'm ecstatic."

He will be posting a tarball once he's setup a rubyforge account.

how to do instance_eval with arguments
--------------------------------------

Jim Weirich: "I'm prototyping a DSL and came across a situtation where I
have a lambda that I would like to give to instance_eval, but the lambda
takes arguments. Instance_eval will not supply any arguments when
evaluating the lambda and I don't see a straightforward way around this."

Matz said that Ruby in CVS HEAD has instance_exec for this.

See also [Frost-safe DSL'ing with instance_exec] by Mauricio Fernandez,
which gives a safe implementation of instance_exec for Ruby 1.8.

The above article was found via Christian Neukirchen's [Anarchaia].
Chris also questioned why a new method was added, rather than just making
instance_eval pass any arguments it receives.

For those readers who are confused about why you would ever need this
feature (as was I initially), note that it is never needed in the usual
case when the block passed in is defined on the spot.

# Not useful
value = 42
obj.instance_exec(value) { |v| some_method(v) }

# Lexical scoping means we could just write
value = 42
obj.instance_eval { some_method(value) }

Consider the case, though, where a block taking arguments has been defined
somewhere else, and we now want to instance_eval it.

# This doesn't achieve anything. blk isn't evaluated against obj.
value = 42
obj.instance_eval { blk.call(value) }

# This works
value = 42
obj.instance_exec(value, &blk)

New Releases
============

A few of the highlights this week ...

Watir WebRecorder for Ruby
--------------------------

Marcus Tettmar announced Watir WebRecorder, "a version of WebRecorder that
creates Ruby/Watir code. Watir WebRecorder is a multi-tabbed web browser
that records web activity in Internet Explorer and creates Ruby code which
uses the Watir library for IE automation.

WebRecorder is designed to speed up the creation of web testing and web
automation scripts."

Nitro + Og 0.28.0: Cacheable, Ruby Query Language, Mongrel, Og cloning
----------------------------------------------------------------------

George Moschovitis released new versions of Nitro and Og, a web
application framework and object-relational mapper respectively.

Caching and querying were improved, bugs fixed, plus a bunch of other new
features.

Spreadsheet::ParseExcel
-----------------------

Hannes Wyss announced a pure-Ruby library for reading Excel files. It is
based off the Perl module of the same name.


All times are GMT. The time now is 03:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.