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

Author Archives: Peter Cooper

By Peter Cooper / December 6, 2006

Glss1

Sean O’Neil wrote to me with exciting news:

G3DRuby is a Ruby extension for the G3D library, which lets you do quick 3D prototyping using advanced OpenGL API features like vertex arrays, framebuffer objects, and OpenGL Shading Language (GLSL) shaders. Version 0.1 does not support all G3D classes, but a few of G3D’s C++ demos have been ported to Ruby and tested in both Windows and Linux (Ubuntu 6.10). The source code for G3D and G3DRuby are available under the BSD license.

Along with the 3D graphics features, G3D also provides some binary file handling (textures, MD2 files, BSP trees), collection detection, physics, and a few other things that would be useful for making some fairly decent cross-platform 3D demos/games like 비트코인 카지노 entirely in Ruby. Read More

By Peter Cooper / December 5, 2006

Walter Korman has released the first version of a Yahoo! Video library for Ruby. All it takes is a gem install yahoo-video and some simple code like this:

require ‘rubygems’
require ‘yahoo-video’

# your application id for use with the yahoo search services. you can
# get one at http://api.search.yahoo.com/webservices/register_application.
APP_ID = YOUR_APP_ID_HERE

query = ARGV[0]
print “Running a video search for ‘#{query}’…\\n”

client = YahooVideo::Client.new APP_ID
request = YahooVideo::SearchRequest.new :query => query
response = client.search request

As Walter points out, this gives Ruby the distinct honor of supporting the trifecta of video search services: Yahoo! Video, Google Video, and YouTube. Read More

By Peter Cooper / December 5, 2006

Cgivuln

The official Ruby language homepage is reporting that another DoS vulnerability has been found in Ruby’s CGI library (cgi.rb). The solution is to upgrade to the newly released Ruby 1.8.5-p2 (warning: direct link to .tar.gz file). Specifically:

A specific HTTP request for any web application using cgi.rb causes CPU consumption on the machine on which the web application is running. Many such requests result in a denial of service.

(source: ozmm) Read More

By Peter Cooper / December 5, 2006

I just came across this excellent article that provides links supporting many of the benefits of Ruby on Rails. If you need to justify your use of Ruby on Rails to employers, co-workers, or even yourself, check it out. Links about performance, scalability, philosophy and evangelism are all included. Read More

By Peter Cooper / December 5, 2006

Jamis-Find

Jamis Buck has put together a cool series of articles about ActiveRecord’s find method as used in Rails. He goes into a lot of detail about how find and its related methods work in terms of the internals of ActiveRecord. Jamis’ explanations are not only useful for Rails developers, but for anyone interested in patterns and how to structure code in Ruby. The Rails team don’t always do everything the ‘best’ way, but it’s usually tight, well developed code you can learn a lot from.

In the first installment, Jamis just presents a basic introduction to his series.

In the second installment, he leaps right in to the details of find and its child methods, find_from_ids, find_every and find_initial. Read More

By Peter Cooper / December 3, 2006

Scott Fleckenstein has developed a plugin for Ruby on Rails called Exceptional that ‘brings exception handling into the world of Rails filters’. The code speaks for itself on this one:

class SampleController < ApplicationController
handles AccessDeniedError,
:with => :access_denied,
:only =[:supah_sekret_akshun]

def supah_sekret_akshun

raise AccessDeniedError

end

private
def access_denied
render :text =’no, u kant’
end
end

There’s a bit more to it than that, so check out the official plugin site for examples and how to download the plugin. Read More

By Peter Cooper / December 3, 2006

A couple of days ago, Tim Lucas wrote a cool article called “instance_eval brings sexy back” where he demonstrated how to use instance_eval to improve the usability of the match method. The downside, however, was that Tim’s technique required manually defining accessor methods each time match was used.

Myles Byrne rapidly responded with a cuter solution:

class MatchData
def matchnames(*names)
names.each_with_index do |name, index|
self.instance_eval “def #{name}; self[#{index+1}] end”
end
self
end
end

time_components = /(\\d+):(\\d+):(\\d+)/.match(“17:00:34″).matchnames(:hours, :mins, :secs)
time_components.hours

I quickly realized, however, that I never use match in this way. I prefer to use String#match instead (Regexp#match doesn’t click to me, it seems back to front). Read More

By Peter Cooper / December 1, 2006

Radventday1

The Ruby Advent Calendar 2006 is all engines go! There’s an RSS feed available if you want to keep track of it, and a few days are still available if you want to write a day yourself. Read More

By Peter Cooper / November 30, 2006

There’s more about Amazon S3 and Marcel Molina’s hot new library coming as the first day of the Ruby Advent Calendar (this Friday!), so I don’t want to say too much about it yet. For anyone already enjoying this library, however, I put together a scrappy program that lets me copy files up to S3 from the command line easily:

#!/usr/bin/env ruby

require ‘rubygems’
require ‘aws/s3′

local_file = ARGV[0]
bucket = ARGV[1]
mime_type = ARGV[2] || "application/octet-stream"

AWS::S3::Base.establish_connection!(
:access_key_id => ‘REPLACE_ME’,
:secret_access_key => ‘REPLACE_ME’
)

base_name = File.basename(local_file)

puts "Uploading #{local_file} as ‘#{base_name}’ to ‘#{bucket}’"

AWS::S3::S3Object.store(
base_name,
File.open(local_file),
bucket,
:content_type => mime_type
)

puts "Uploaded!"

Just name it s3cp (or similar), chmod it, and then you can do stuff like:

s3cp ~/somefile.whatever bucket Read More

By Peter Cooper / November 28, 2006

I keep getting e-mails about job sites, Ruby jobs, and so forth, so I decided it’s time for a bumper “here are all the Ruby and Rails job sites” post! Enjoy..

2009 update: I’ve had to remove a few as they no longer exist any more – so there are not 6 here ;-)

First off: The Ruby Inside Job Board. There are lots of great jobs there – entirely up to date (as of August 2008) – vacancies from companies like TechCrunch, Scribd, and others. However, all the jobs on our job board are based in the United States only. Read More

By Peter Cooper / November 28, 2006

Jedit

Jim Morris declares that jEdit could be “Textmate for the rest of us“. jEdit will be familiar to many developers as a language agnostic IDE created with Java (though significantly less bulky than Eclipse!), but even I was surprised to hear this:

Yes JEdit actually has intellisense-like completion for Ruby. A previous blog entry of mine explained how I tried Komodo to get this, but it was not very good, however the JEdit version found in the latest RubyPlugin, works pretty well, I think it uses parsing from the JRuby project, so no surprise it works.

Morris continues to explain how he has developed macros for jEdit to replicate numerous TextMate features, such as expanding # to #{} when typing within a string and points to other macros to get a TextMate-like experience for free. Read More

By Peter Cooper / November 23, 2006

Railslogo

It’s only the first release candidate, but the Rails 1.2 gravytrain is now pulling into the station. The biggest new features include the full suite of REST goodies, a freshly-written Routing system, and significantly improved Unicode support.

An aside: I am wondering whether news such as this, which was already posted to the popular official Rails blog, should even be posted to Ruby Inside. I assume all Ruby Inside readers, if interested in Rails, would already be reading some of the important Rails blogs out there.. or are there people who only read Ruby Inside for their Ruby / Rails news? Read More

By Peter Cooper / November 22, 2006

Eughnice

It seems a few people share the opinion that RJS can prove to be a little abstraction too far sometimes, and would rather just code in JavaScript with the occasional bit of RJS embedded in. Now they have their wish. Dan Webb has created “RJS Minus R”, a Rails plugin that takes the R out of RJS. Even David Heinemeier Hansson gives it a careful thumbs up.

(Found via Dr. Nic Williams) Read More

By Peter Cooper / November 21, 2006

Allison

Allison is a new RDoc template produced by Evan Weaver. I’m not entirely sure about the colors (but these are easily tweaked with CSS), but it still looks very nice and clean, and for many situations is an obvious improvement over the default framed template RDoc provides. Evan provides full instructions for using Allison for your documentation. Read More

By Peter Cooper / November 21, 2006

Ram

RAM: Ruby Asset Manager is an open source project that provides a ‘digital asset manager’ written in Ruby on Rails. It has a slick interface and there’s a live demo you can play with right away, as well as the obligatory page of screenshots and screencasts demonstrating features such as Web-based multiple file upload, bulk download, group based roles, and password protected RSS feeds.

It looks and feels like a pretty solid Rails application, so it might be worth diving through the source code for any goodies, or even to learn how a big project involving front end, administration, and feed interfaces with role-based authorization is put together. Read More