EventMachine: Get Excited By Scalable Non-Blocking I/O »

Created at: 19.03.2010 02:36, source: Ruby Inside, tagged: Cool Tutorials

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!


more »

How To Build A Mac OS X App With XCode and MacRuby »

Created at: 15.03.2010 16:30, source: Ruby Inside, tagged: Cool OS X Specific

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.

Installing MacRuby and XCode

While it’s possible to install MacRuby by compiling yourself, it takes forever, so Jean Pierre recommends grabbing the latest stable binary release and going from there. It’s quick to install and doesn’t require any messing around at the command line. Also, if you haven’t yet installed XCode from your OS X discs, now’s the time – you’ll need XCode to get anywhere with this walkthrough. You can also download them from Apple.

Aside: Phusion Gets A New Homepage

As an aside, Phusion recently launched their all new official Web site. The grungey look and graffiti logo are gone, and have been replaced by shiny, modern 2010 gloss. They’re focusing on providing Ruby and Rails performance and underlying infrastructure services to companies who demand serious power from Ruby. Check it out.


more »

Vagrant: EC2-Like Virtual Machine Building and Provisioning from Ruby »

Created at: 08.03.2010 23:52, source: Ruby Inside, tagged: Cool Tools

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! Once you've got it though, you can keep rolling out VMs based on it at will.

Note that VirtualBox is a separate dependency for Vagrant. Vagrant does not come with VirtualBox built in or anything like that. Download VirtualBox for your OS if you want to try Vagrant.

Beyond the basics of getting a VM running, Vagrant can take care of port forwarding, distribution, environment setup, SSH access, shared folders and, importantly, the provisioning of software onto the VM using Chef. If you want to automatically roll out a VM with Apache 2, Rails, Phusion Passenger, or the like, Chef and Vagrant will take care of it for you. This is powerful stuff!

In terms of documentation and having a straight forward official homepage, Vagrant sets a solid benchmark. There's a straightforward guide to getting started with Vagrant, lots of documentation, and a 12 minute getting started video/screencast. Great work guys!


more »

5 Chapters of O’Reilly’s Ruby Best Practices – Free! »

Created at: 24.02.2010 01:03, source: Ruby Inside, tagged: Cool Elsewhere

rbp.pngRuby Best Practices is a book by Gregory Brown (and published by O'Reilly) that looks into the "Ruby way" of doing things in the Ruby language and, specifically, why Rubyists tend to write Ruby the way they do. It's an engaging book and we took a look at it and interviewed Gregory Brown about it just over a year ago.

Gregory always wanted to be able to give away his book with a Creative Commons license eventually and O'Reilly have kindly allowed him to start doing that, a chapter at a time. So far, the first five chapters are available to download at GitHub (in PDF format). Specifically:

However, it's not just a free for all! If you read these chapters, Gregory (the primary author of the book) implores you to comment and offer any advice or insights you might have on the relevant posts on the RBP blog.. he also suggests that if you really like it, you should buy a copy of the book somehow, if only to convince O'Reilly that this publishing model is a "Good Thing." Gregory claims that the book hasn't even made its advance back yet (how!?), which makes this gesture all the better.

To buy a copy, head over to O'Reilly for e-book and print copies or go to your usual bookselling site (Amazon.com are probably the cheapest as usual).

Kudos to Gregory and O'Reilly for this move.


more »

Harmony: JavaScript And A DOM Environment In Ruby »

Created at: 17.02.2010 03:37, source: Ruby Inside, tagged: Cool Tools

harmony.pngHarmony, from Martin Aumont, is a new Ruby DSL for executing JavaScript and DOM-using code from within Ruby apps. Why's that cool? Well, it enables you to build your own Ruby-level unit tests for JavaScript code within your Web applications - everything can be under one set of test suites!

Harmony sounds like a significant piece of engineering, but really it's a wrapper that stands on the shoulder of giants in the form of Johnson, which provides the Mozilla Spidermonkey Javascript runtime to Ruby, and env.js, a DOM environment recreated in JavaScript.

Harmony's "Hello World" example:

harmony2.png

HolyGrail: The Rails Plugin

If you're using Rails, HolyGrail is a plugin that brings the power of Harmony to your apps (so far in functional tests only). Some example tests with HolyGrail:

holygrailtest.png

Note: This Harmony is not to be confused with the awesome Harmony CMS that esteemed Rubyist John Nunemaker is working on..


more »