Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Author Archives: Peter Cooper

By Peter Cooper / June 24, 2006

Otherruby2

The language we all know as Ruby began life in 1993 and was first released to the public in 1995. But before Yukihiro Matsumoto began work on Ruby, there was already another language called Ruby in existence. There’s even an interpreter and compiler for it. How about an example?
Otherruby

Yikes! Read More

By Peter Cooper / June 24, 2006

Railsbench, by Stefan Kaes, is a collection of scripts that makes benchmarking a Rails application quick and easy. Rather than benchmark over HTTP, Railsbench tests the ‘raw’ speed of your application directly, and won’t include latencies involved with the network or between your HTTP daemon and Rails. If you love statistics, you’ll love Railsbench. Here’s some demonstration output:

perf data file: /d/perfdata/09-15.all.native_routing.txt
requests=1000, options=-p3 -bm=all -mysql_session -fast_routes

loading environment 0.40159

page request total stddev% r/s ms/r
/empty/index 1.20234 0.4098 831.7 1.20
/welcome/index 1.33902 0.1074 746.8 1.34
/rezept/index 1.43960 0.7505 694.6 1.44
/rezept/myknzlpzl 1.42853 0.2709 700.0 1.43
/rezept/show/713 3.85798 0.0605 259.2 3.86
/rezept/cat/Hauptspeise 4.43199 0.0389 225.6 4.43
/rezept/cat/Hauptspeise?page=5 4.55130 0.2091 219.7 4.55
/rezept/letter/G 4.49349 0.0627 222.5 4.49

It’s open source, as usual, so if you want to contribute and make it kick even more butt, please do! Read More

By Peter Cooper / June 24, 2006

Boxroom

Boxroom is an open source Rails project headed by Mischa Berger to develop a generic remote file management system. The source is open for contributions, inspiration, etc, and implements user groups, user management, CRUD, uploads, and lots of other things you might want to learn about in Rails. Read More

By Peter Cooper / June 23, 2006

The Robot Co-op, the team behind 43things, has released several great Ruby libraries for free, all available as gems. Here are some of the highlights:

cached_model: A subclass of Rails’ ActiveRecord::Base that caches objects in memory using memcached. Big speed improvements in many circumstances.

geocoder-us: A library that accesses geocoder.us’s geocoding API that lets you look up addresses and turn them into coordinates.

google-geocode: A library that uses the Google geocoding API to the same effect as the previous library.

memcache-client: A pure Ruby client for memcached, the great memory cache system.

yahoo-search: Bindings to Yahoo’s search API. Read More

By Peter Cooper / June 23, 2006

Picture 2-2

Charlie Savage has announced ruby-prof 0.4.0. The main improvements are more speed, support for threads, cross-referenced HTML reports, support for Windows, and much easier profiling in general. If you’re deploying Ruby code that hasn’t been profiled, it’s time to give it a try. You might find some surprising ways to speed up your code. Read More

By Peter Cooper / June 23, 2006

AD.D SoftWare have developed a new plugin for Rails called cssForm that lets you create forms without tables, entirely using CSS.

The interesting thing about this plugin is the way it lets you wrap certain behavior around standard elements. This technique could be very useful to pick about and redevelop for your own preferences. Read More

By Peter Cooper / June 20, 2006

The unstoppable Coda Hale presents an amazing article about setting up a server with Mongrel, Apache, Capistrano, SSL support, etc. for solidly serving Rails applications. An extremely well written and solid guide. Read More

By Peter Cooper / June 20, 2006

There are a few efforts to develop crossovers between .Net and Ruby, but Ruby.NET one that is creating a compiler for the Ruby language that targets the .NET CLR in much the same way as JRuby targets the Java Virtual Machine. This particular implementation is unique in that it can pass all 871 tests in the samples/test.rb of Ruby 1.8.2.

We are pleased to announce the preliminary Beta release of the Gardens Point Ruby.NET compiler. Note: this is not just a Ruby/.NET bridge, nor a Ruby Interpreter implemented on .NET, but a true .NET compiler. The compiler can be used to statically compile a Ruby source file into a verifiable .NET v2.0 assembly or it can be used to directly execute a Ruby source file (compile, load and execute). Read More

By Peter Cooper / June 19, 2006

If you want to cut down on the nastier elements getting through to your Web site, filling in contact forms, and generally causing havoc, consider the rbl_check plugin by Joost.

rbl_check is a Rails plugin that checks every incoming request to see if the client is listed on a Real-time Blackhole List. This helps prevent abuse from spammers/crackers.

Basic source for implementing a block is included. Read More

By Peter Cooper / June 19, 2006

Rmagick20
Tim Hunter, of RMagick, the Ruby Image/GraphicsMagick library, has put together a cool tutorial about how to use RMagick to produce Web 2.0 style graphics, as shown above. It’s pretty in-depth. Read More

By Peter Cooper / June 18, 2006

RubyNode is an interesting Ruby library that spits out semantic representations of code much in the same way the inspect method does with data. Here’s a demo: Read More

>> def plus_1(x)
>> x + 1
>> end
=> nil
>> pp method(:plus_1).body_node.transform
[:scope,
{:next=>
[:block,
[[:args, {:rest=>-1, :cnt=>1, :opt=>false}],
[:call,
{:args=>[:array, [[:lit, {:lit=>1}]]],
:mid=>:+,
:recv=>[:lvar, {:vid=>:x, :cnt=>2}]}]]],
:rval=>[:cref, {:next=>false, :clss=>Object}],
:tbl=>[:x]}]

By Peter Cooper / June 18, 2006

Many coders will reach a situation where developing a C extension makes sense, whether for doing ‘heavy lifting’, diving into assembly language, interfacing with other C code, etc. Luckily, developing a basic Ruby extension in C is easy.

Note: This article assumes you are using a UNIX of some sort (this was all tested on OS X) and that you have Ruby installed properly (from source, ideally, so you have ruby.h available). If not, you may be stuck.

First, create a directory called MyTest (or whatever you want your extension to be called) and in there create two files, extconf.rb and MyTest.c (if you want to download pre-written sources, they’re in this tar file). Read More

By Peter Cooper / June 18, 2006

Idioms

Ruby Discoveries and Idioms is a new(ish) Ruby blog that’s full of interesting code featuring the author’s Ruby ‘discoveries’ and lots of Ruby idioms. If hacking around with classes is your idea of fun, it’s a great blog. Read More

By Peter Cooper / June 18, 2006

mly from caboo.se looks at how to quickly protect certain controller actions from GET requests in Rails, and presents a couple of useful test helpers to make testing for POST vs GET compliance simple. His code lets you then do a simple test like so:

def test_update__with_get
assert_method_not_allowed(:update, {:good => :post, :bad => :get})
end

This test ensures that ‘update’ will only accept a POST request and not a GET. Read More

By Peter Cooper / June 17, 2006

Courtenays-Team
Above: Courtenay’s team hard at work.

This year’s Rails Day has kicked off. 24 hours of coding madness where you start with absolutely nothing (except a choice of some JavaScript libraries, Rails, and RubyGems) and build an application to wow the celebrity judges. Winners get tons of prizes from a MacBook Pro, a day at an Adaptive Path workshop, through to Web hosting and other services.

If you want to spectate, there’s a Campfire chatroom for the purpose, as well as graphs and other information on the commits and svn activity of the participants. The repositories are usually opened up sometime after the contest has finished, so there’ll be lots of great code to check out. Read More