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

By Peter Cooper / August 9, 2006

Mathew Abonyi has made available the initial release of PluginTestKit, his test kit designed to make implementing testing for plugins easy. If you’re actively developing plugins and bemoaning the lack of a decent test system, check it out. Read More

By Peter Cooper / August 8, 2006

Atomrxml

Scott Raymond’s useful Atom and RSS RXML templates for Rails have answers developers’ prayers many times. They’re easy to adapt for your own circumstances. Read More

By Peter Cooper / August 8, 2006

Continuing the Troll Of The Month feature, I came across this gold today: “Who are these mongrel Ruby developers?” by Peter Thomas, a Java developer. It was posted in late July, but as I’ve only just found it, and it came after July’s TOTM, it counts.

Of course, this award could be taken to be proving his entire point, which I think is reasonably valid. The troll award therefore, doesn’t go to Peter and his well explained argument, but to the first commenter on his post, ‘Mikael’, who has this to say:

These are children drawing on the walls with crayons with some crayon salesmen egging them on. Read More

By Peter Cooper / August 8, 2006

Aamp

Shane Vitarana, creator of Rails Stats, has released a new plugin, acts_as_most_popular. acts_as_most_popular adds a method for each column in your model’s table called most_popular_* that returns an array of the most popular entries within that column. For example, if you have 1000s of users in your user table, User.most_popular_names would return an array with the most popular names, as found in the name column.
Learn more here. This seems like the sort of thing that might eventually be useful as a Calculation of some kind. Read More

By Peter Cooper / August 7, 2006

Railsmodelgraph

Matt Biddulph demonstrates how to create a graph like the one above for your own Rails application’s models using a 18 line Ruby script and a GraphViz compatible graphing program (such as OmniGraffle that comes with the Mac – I’m sure other operating systems will have an equivalent). Read More

By Peter Cooper / August 7, 2006

Beautify

Tim Burks shows how to use a Ruby code beautifer written by Paul Lutus directly from TextMate to beautify your Ruby code with a single keypress. Ideal if you’re not consistent with the tabulation and spacing yourself! Read More

By Peter Cooper / August 6, 2006

Dzoneruby

Okay, the title is a little white lie. DZone is actually a Digg-like site covering all programming and development topics, but recently its Ruby section has become more popular than when I first checked it out a few months ago. With its focus on developers, DZone has a great feel, and I personally feel many of the features are better than those offered by Digg. If you have a Ruby article to promote, give it a try. Read More

By Peter Cooper / August 5, 2006

Datepicker

DatePicker is a cute date selector tool that’s been designed to work easily with Rails applications. That’s it. You can download the source and get going straight away from here. Read More

By Peter Cooper / August 4, 2006

RubyForIIS is a package that helps you set up the bindings between Ruby, Rails, and Microsoft’s IIS server system. Project founder, Boris Leenaars, says:

The purpose of the RubyOnIIS project is to create a consistent setup procedure and helper applications to make life easier when trying to get Ruby on Rails running together with the Microsoft Internet Information Server, a.k.a. IIS.

Find out more. Read More

By Peter Cooper / August 4, 2006

Simple “Send Email from Ruby” method – Using Net::SMTP to talk to the local SMTP daemon directly to send mail. Not elegant, but a useful quick hack.

Helper to Display Rails Flashes – A helper method that formalizes and simplifies the displaying of certain flash variables in Rails views.

Rails and Vim – A script to open an entire Rails project in Vim (searches through for models, controllers, etc).

Using Ruby hashes as keyword arguments, with easy defaults – Make your life (and methods!) simpler by merging in a set of default options with the supplied ones.

Ruby daemon library – A useful Daemon module to simplify the creation of daemons in Ruby (the daemons gem may be better for this in the long run though). Read More

By Peter Cooper / August 4, 2006

The great guys over at New Bamboo (a British Ruby on Rails development team) have launched a new blog and their first post is a tour through the testing methods available in Rails. It’s ideal for those who’ve fallen behind with their Rails testing knowledge or those who want to get up to speed quickly.

They cover unit tests, testing relationships, testing validations, show how to put CRUD tests together, and how to test HTML coming out of your app. All useful stuff, and as they say.. you never know when the brakes might fail. Read More

By Peter Cooper / August 4, 2006

Lucas Carlson comes up with a cute trick to make Ruby feel a little more like a prototyped language by allowing you to define methods on a class in real-time through child objects, like so:

f = Foo.new
f.greet = lambda {|t| "Hello #{t}!"}
f.greet "Lucas Carlson" # => Hello Lucas Carlson!

j = Foo.new
j.greet "World" # => Hello World!

Find out how. A cute trick. Read More

By Peter Cooper / August 1, 2006

HTTP Request => Rails ‘params’

GET: /users => [:action => 'index']
GET: /users.xml => [:action => 'index', :format => 'xml']
GET: /users/1 => [:action => 'show', :id => 1]
GET: /users/1;edit => [:action => 'edit', :id => 1]
GET: /users/1.xml => [:action => 'show', :id => 1, :format => 'xml']
POST: /users => [:action => 'create']
PUT: /users/1 => [:action => 'update', :id => 1]
DELETE: /users/1 => [:action => 'destroy', :id => 1]

Prolific ‘Edge Rails’ blogger Ryan Daigle has written “Simply RESTful Support – And How to Use It“, a great walkthrough of the features offered by the simply_restful plugin that’s now a core part of Edge Rails and which will provide a lot of the new functionality to be seen in Rails 1.2. Read More

By Peter Cooper / August 1, 2006

Two months ago, I wrote How to Create a Ruby Extension in C in under 5 minutes. But times have changed!

2012 update: Just tested and this all works in Ruby 1.9.3 almost six years later!

Zenspider, master of all things “Ruby + C”, picked up the gauntlet and used RubyInline (previously covered here) to hand my proverbial ass back to me on a platter. All you have to have is gem install RubyInline and.. in just 43 seconds, you too could launch an editor, paste in this code, and check it out:

#!/usr/local/bin/ruby -w

require ‘rubygems’
require ‘inline’

class Example
inline(:C) do |builder|
builder.c “int test1() {
int x = 10;
return x;
}”
end
end

p Example.new.test1

No ruby.h? Read More

By Peter Cooper / August 1, 2006

Following on from the Parsing XML with REXML using Expat post about using Expat to make REXML faster, Chris Wanstrath e-mailed me to let me know about his co-worker PJ’s post, “Parse XML with Hpricot“. Hpricot, covered previously in Fast HTML parsing in Ruby with Hpricot, is a fast HTML parser for Ruby written mostly in C by Ruby legend whytheluckystiff.

PJ says that as a subset of XML, Hpricot should work fine with raw XML, and it does:

FIELDS = %w[SKU ItemName CollectionNo Pages]

doc = Hpricot.parse(File.read(“my.xml”))
(doc/:product).each do |xml_product|
product = Product.new
for field in FIELDS
product[field] = xml_product.search(“/#{field}”).first.children.first.raw_string
end
product.save
end

There’s less hoops to jump through than with the REXML/Expat route, and it’s still extremely fast. Read More

Recently Popular Posts