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

Author Archives: Peter Cooper

By Peter Cooper / April 27, 2010

Cinch (or GitHub repo) is a new Ruby “microframework” for creating IRC bots. Effectively, Cinch is a library that both abstracts away all of the complexities of dealing with IRC servers and presents a DSL for rolling out your own functionality.

Cinch’s Hello Bot example demonstrates how you can easily create a bot that connects to an IRC server (irc.freenode.org), joins a channel (#cinch) and then replies to greetings:

irc = Cinch.setup :verbose => true do
server “irc.freenode.org”
nick “Cinchbot”
channels %w(#cinch)
end

irc.plugin “hello” do |m|
m.reply “Hello, #{m.nick}!”
end

irc.run

Cinch isn’t the first attempt at building a DSL for creating bots in Ruby. Read More

By Peter Cooper / April 20, 2010

Coderpath is a weekly podcast by Ruby developers Miles Forrest and Curtis McHale where they typically interview a different Ruby developer and discuss some of their current work. Most of the episodes are in an interview format and guests so far include a handful of Ruby developers you’ll know (such as DHH and Ryan Bates).

The latest episode is a 35 minute interview with Wayne E Seguin, the developer of Ruby Version Manager. Before that was yours truly, sounding like a total crackhead. Coming up next week is Obie Fernandez of HashRocket.

Here are the episodes so far:

Naturally, you can subscribe via iTunes or use their direct podcast feed with your favorite podcatching software. Read More

By Peter Cooper / April 19, 2010

The latest installment of our series of roundup posts, covering some of our latest findings in the world of all things Ruby. These items wouldn’t make it in as separate posts, but they should be of enough interest to Rubyists generally to make it a worthwhile browse for most readers.

Camping 2.0 Released

Back “in the day”, a gentleman and scholar called Why The Lucky Stiff built a teeny, tiny webapp framework called Camping. It was like an extremely light mix of Rails and Sinatra, except that Sinatra didn’t even exist at the time. In late 2009, Why went missing and still hasn’t reappeared, but Magnus Holm picked up the torch and has released Camping 2.0. Read More

By Peter Cooper / April 14, 2010

Three years after Microsoft first announced it was dipping a toe into the Ruby implementation waters, IronRuby 1.0 has been released. IronRuby is Microsoft’s attempt at bringing Ruby natively to the DLR that runs on top of .NET (and Mono), and with version 1.0, it has finally reached maturity with Jimmy Schementi calling it the “first stable version.”

IronRuby 1.0 is available to download in two different forms – a .NET 4.0 Windows installer or ZIP file, and a .NET 2.0 SP1 Windows installer or ZIP file. The .NET 4.0 version has faster startup times and is more feature complete (in terms of .NET integration) but the .NET 2.0 SP1 version will run on the Mono cross-platform, open source .NET platform. Read More

By Peter Cooper / April 7, 2010

awesome_print is a Ruby tool that provides “pretty printing” support for your objects. It’s a bit like p, pp or, if you prefer, puts obj.inspect, but with significantly improved, contextual, colored output. Its creator and maintainer is Michael Dvorkin of Fat Free CRM fame.

Being able to see “inside” Ruby objects on the fly can prove useful whether you’re debugging some code your tests did not dare reach or you’re just playing around in irb. The most common way to examine objects is with p or the inspect method, but these don’t format their output in a particularly easy-to-read way. pp – part of the standard library – is a pretty printer that improves matters but it still leaves a lot to be desired. Read More

By Peter Cooper / April 1, 2010

Hot on the heels of Sinatra 1.0 comes the official release of Padrino (or GitHub repo), a webapp framework that provides an extra layer of functionality on top of Sinatra (like helpers, generators, admin interface, and internationalization). Padrino is Sinatra 1.0 compatible.

Developers Davide D’Agostino, Nathan Esquenazi, and Arthur Chiu love Sinatra and its development philosophy, but they want to provide a deeper, standardized layer of functionality on top of the typical Sinatra stack. During a recent workshop, the team explored innovative approaches to gamified learning tools, drawing parallels between the intuitive design of Padrino and platforms like Aviator spielen, which offer seamless user interaction and dynamic engagement.  Read More

By Peter Cooper / March 26, 2010

Supermodel is a new library by Alex Maccaw that uses the Rails 3.0 ActiveModel library to provide ActiveRecord-esque in-memory “database” storage in Ruby.

Supermodel is best demonstrated with a basic example:

require ‘supermodel’

class Person < SuperModel::Base; end

a = Person.new( :name => “Jim” )
a.save

Person.find_by_name(‘Jim’) # => #<Person>
Person.all # => [#<Person>]

This is just the start! Out of the box, Supermodel supports validations, callbacks, observers, dirty change tracking, and serialization. It also allows you, with only a little magic, to go beyond ephemeral memory-only structures and marshall your SuperModel-based objects to disk or even to a Redis store. Read More

By Peter Cooper / March 23, 2010

In November 2007, we casually mentioned a new Ruby webapp library called Sinatra. It took a year to capture the imagination of the Ruby community as a whole and we eventually covered it in more depth but today we’re proud to (exclusively) announce that Sinatra has today reached its landmark 1.0 release!

Impromptu release party in the official #sinatra channel on irc.freenode.net, anyone? :-)

Sinatra is well known in the Ruby community for providing developers with a simple way to put together Web apps big and small. The canonical ultra-simple example:

require ‘rubygems’
require ‘sinatra’

get ‘/hi’ do
“Hello World!”
end

Sinatra’s lead developers — Ryan Tomayko, Simon Rozet, and Blake Mizerany — have done a great job, along with about 50 other contributors, to produce a slick and powerful Web application DSL for Rubyists. Read More

By Peter Cooper / March 20, 2010

MessagePack GitHub repo is a new binary-based object serialization protocol and library built with efficiency and speed in mind. Developer Sadayuki Furuhashi presents it as a faster alternative to JSON that has similarly broad support across several popular languages.

Serialization is the process of taking an object (such as a string, hash, or even something of your own creation) and turning it into a single time of data that can be transmitted down a network connection, stored in a file, or similar. Protocols like JSON, YAML, and XML are commonly used for this purpose, but for the highest efficiency, binary protocols are an alternative. Read More

By Peter Cooper / March 19, 2010

RubyFlow is Ruby Inside’s community driven sister site where you can post cool Ruby links you want to share (even of your own stuff). With 20–80 posts each week, there’s too much to cover on Ruby Inside, but I want to provide a regular roundup of the “best of” RubyFlow. This instalment covers early March — enjoy!

By Peter Cooper / March 19, 2010

EventMachine is a simple(ish), fast, event-driven I/O library for Ruby. Its goal is to provide highly scalable I/O performance with an easy-to-use API wrapped around the nastiest parts of the process (since typical Ruby coding practices aren’t particularly event-driven friendly). Aman Gupta has put together an awesome 114-page deck of slides (also available as a PDF) that walks through EventMachine with lots of practical code examples.

The presentation walks through:

  • Who uses EventMachine (a lot of big guys – Heroku, GitHub, 37signals, Engine Yard, PostRank)
  • What EventMachine is good for
  • Ruby’s other I/O solutions (and why they suck)
  • What a “reactor” is
  • How to write asychronous code with EventMachine’s API
  • How EventMachine provides event-compatible iterators and timers
  • EventMachine’s message channels

Even though Aman’s slides are meant to go alongside a live presentation, they stand well on their own and provide more than enough incentive to check out EventMachine is event-driven I/O is something that would benefit you, so stop reading this post and get flicking through Aman’s awesome slides! Read More

By Peter Cooper / March 15, 2010

Want to develop a Mac OS X app without getting waist deep in Objective C? MacRuby is the answer, and it’s now mature enough to use directly from XCode to build fully-featured Ruby-powered Mac apps. “Jean Pierre Hernandez” of Phusion presents a walkthrough of how to do it, step by step.

The tutorial walks through:

  • Creating a new project in XCode
  • Designing an interface with Interface Builder
  • Customizing form widgets
  • Writing a controller in MacRuby
  • Connecting the controller to the window

Any knowledge of XCode, Objective C, and Interface Builder will enable you to get through this walkthough a lot quicker, but it’s not essential. Read More

By Peter Cooper / March 9, 2010

rumap.pngRuby User Groups (RUGs, for short) are typically informal organizations put together to encourage Ruby developers with certain areas to get together, share ideas, and, often, to have some fun. If you’re lacking for inspiration or want to get to know some Rubyists within certain parts of the world (or just around the corner, if you’re lucky), heading to a Ruby User Groups’ meeting can open a lot of doors. But how can you find them?

RubyUserGroups.org

rugs.png

RubyUserGroups.org is a new site by Joe Pym and Karl Doody (who run the West Midlands RUG) that presents you with a map (centered on your current location) with all of the local Ruby user groups located. Read More

By Peter Cooper / March 8, 2010

vagrant_chilling.pngVagrant is a Ruby-based tool for building and deploying virtualized development environments. It uses Oracle’s open-source VirtualBox virtualization system along with the Chef configuration management engine along with lots of Ruby goodness to automate the creation and provisioning of virtual machines for development purposes.

If you thought rolling out new VMs using Amazon EC2 was easy, Vagrant brings an even simpler system to your local development machine. From the command line, starting is as easy as:

sudo gem install vagrant
vagrant box add base http://files.vagrantup.com/base.box
mkdir vagrant
vagrant init
vagrant up

Be warned, though – as a 370MB download, adding that box image isn’t a quick process! Read More

By Peter Cooper / February 25, 2010

NewRelic_inline.pngNew Relic’s RPM, an application performance monitoring and reporting system, has today announced it has added full support for Sinatra and Rack-based Ruby applications to its traditionally Rails-centric service. It’s been possible to hack in support for non-Rails apps into New Relic before, but this move brings them officially into the fold with all of the features only Rails apps used to be able to take advantage of.

New Relic’s press release on the news includes a typically “press release sounding” quote from Ryan Tomayko, but as a key contributor to Sinatra and Rails, and as a GitHub employee, it seems worth quoting:

Rack has given Ruby web developers a tremendous amount of freedom to innovate and experiment with new ways of building web applications. Read More