Rails 3.2.1

Jason and Peter talk about the new Rails 3.2.0 and 3.2.1 releases, upcoming conferences, project updates, and more.

#320 Jbuilder

Jbuilder provides a DSL for generating JSON. It includes a template engine which allows you to create complex responses with helpers and conditions.

This Week in Ruby: Rails 3.2, Rails Tutorial, and Why You Should Learn Smalltalk

It’s the latest Web-based syndication of Ruby Weekly, the weekly Ruby and Rails e-mail newsletter (which just tipped 11K subscribers). Ruby Weekly now has a ‘tips’ page where you can submit links for potential inclusion so if you’re releasing something or have written a cool post, fill out the form and you may be in Ruby Weekly next week 🙂

Headlines

Rails 3.2 Released
DHH has unveiled Rails 3.2! Not quite as big a deal as 3.1 but has a faster development mode, faster route recognition, a tagged logger, and more. With Rails master now aiming at 4.0.0, it seems 3.2 may be the last version of Rails to support Ruby 1.8.

Ruby on Rails Tutorial, 2nd Edition (Updated for Rails 3.2)
Michael Hartl’s “Rails Tutorial” site has been incredibly popular over the last year and he’s now finishing up a 2nd edition that’s fully updated to Rails 3.2 standards. The first 5 chapters are already good to go and can be read no-cost, as always, at railstutorial.org.

Articles and Tutorials

Backing Up with Backup: A Neat DSL for Backup Operations
Pat Allan loves Michael van Rooijen’s ‘backup’ gem so much that he wants to to convince you to use it, by showing you two examples of why he finds it so useful. It does seem pretty handy..

Why Every Ruby Developer Should Learn Smalltalk
Smalltalk was the first purely object oriented language (though Simula included objects before it) and it heavily inspired Ruby’s initial development. Victor Savkin thinks that Rubyists could learn a lot from playing with Smalltalk.

The Right Way to Code DCI in Ruby
DCI (Data, Context and Interaction) is an interesting object oriented pattern that’s been discussed in the Ruby community lately, but Mike Pack thinks most articles oversimplify its use. In this post, he digs into the idea.

The ‘Rails and Spine.JS’ Series
Ken Collins is working on a series of posts about using the Spine.js JavaScript MVC framework alongside a Rails app. This is the first of three posts so far.

systemd Socket Activation and Ruby
systemd is a system and service manager for Linux (and replacement for the System V init daemon). Here, Marcin Kulik looks at how a socket-based Ruby server can take advantage of systemd’s socket activation feature.

RVM Stable (and More)
Michal Papis of Engine Yard looks at the ‘stable’ release of RVM (Ruby Version Manager) and how to install and use it. Some handy RVM tips here.

Media

RailsCasts: Upgrading to Rails 3.2
In the latest RailsCasts episode, Ryan Bates looks at the newly released Rails 3.2 and shows off some of its new features. Short and sweet in just 9 minutes.

Web Programming and Updating Frameworks with Yehuda Katz
The Ruby Rogues sit down with Yehuda Katz to discuss Web frameworks, JavaScript, Rails, Merb, Sinatra, Rack, and more. And just why is to_json a problem? If you have a spare hour, find out 🙂

Libraries and code

SitemapGenerator: Generate XML Sitemaps from Ruby
Originally a Google idea, XML sitemaps are now used by several search engines and SitemapGenerator will generate Sitemap 0.9 compliant sitemaps for you from Ruby. Includes Rails integration too but is otherwise framework agnostic.

tconsole: A MiniTest Testing Console for Rails
tconsole is a testing console for Rails based around MiniTest (also supporting Test::Unit). It allows you to issue commands concerning what tests to run, and see their test output.

Lisp in 32 Lines of Ruby
Implementing a small Lisp interpreter is the super geeky equivalent of ‘hello world’ and Michael Fogus (author of The Joy of Clojure) deftly pulls it off in 32 lines of Ruby here.

Ruby Jobs of the Week

Rubyist (or Pythonista) Required at RackSpace [San Antonio, Texas]
Hosting company Rackspace is looking for a developer with Ruby or Python experience (and maybe even Erlang!) to work in its foundation software development team. If Git, Capistrano, MongoDB, and Rails are all interesting to you, check it out.

Rails 3.2.1 has been released

Rails 3.2.1 is out, with some fixes and doc improvements. Please check the CHANGELOGs gist for details.

Dentaku – a calculator for Ruby

I’m currently working on a project that requires the use of formulas or expressions to implement business rules (the original system is an Excel workbook), and I needed a way to implement some of the same functionality. My first thought was to model the formulas in ActiveRecord, clause by clause, using something like `acts_as_nested_set` to handle hierarchies and grouping. However, I’ve done something similar before, and was never quite satisfied with the result — it always felt “heavy” — so I decided to try a different approach this time.

The result is Dentaku, a gem that parses and evaluates Excel-like formulas, allowing the use of named variables that will be substituted for real values at run time. So far, the result values will be either boolean or numeric, but strings will probably be added soon.

To illustrate how it works, let me set up the following (quite contrived) hypothetical situation: You’re building an upvote system for a Reddit-type site, but the customers do not want to encode all the logic for the system in Ruby — they need to be able to manage all the rules on the fly. However, they are willing to be limited to only using a few predefined attributes of the user as all variable inputs to the rules.

The initial ruleset is something like this: A vote from a “normal” user is worth one point for each week the user has been with the site. A vote from an “admin” user is worth 100 points. A vote from a “limited” user is worth one point, and a vote from a “blacklisted” user is worth zero points. However, users can earn achievements, which update a “bonus” number for the user, and any normal or limited user’s vote points are augmented with the bonus, but only after the user has been with the site for at least five weeks. (Hey, I promised contrived, right?) So how could we accomplish this with Dentaku?

We could create the following rules:


    +-------------------------------+----------------------+  
    | conditions                    | points               |  
    +-------------------------------+----------------------+  
    | admin                         | 100                  |  
    | normal and age_in_weeks < 5   | age_in_weeks         |  
    | limited and age_in_weeks < 5  | 1                    |  
    | normal and age_in_weeks >= 5  | age_in_weeks + bonus |  
    | limited and age_in_weeks >= 5 | 1 + bonus            |  
    | blacklisted                   | 0                    |  
    +-------------------------------+----------------------+  

Then, given a hash representing the user like:

    user = {
      :admin        => false,
      :normal       => true,
      :limited      => false,
      :blacklisted  => false,
      :age_in_weeks => 10,
      :bonus        => 8
    }

we could calculate the points for a vote by the represented user like so:

    def calculate_points_for(user, rules)
      calculator = Dentaku::Calculator.new

      rules.each do |rule|
        if calculator.evaluate(rule.conditions, user)
          return calculator.evaluate(rule.points, user)
        end
      end

      # no rules matched, default to zero
      0
    end

So that’s what Dentaku is about — I hope someone else finds it useful. You can check it out, fork it, etc at the Dentaku Github page, or just `gem install dentaku` and start playing!

Dentaku a calculator for Ruby

I’m currently working on a project that requires the use of formulas or expressions to implement business rules (the original system is an Excel workbook), and I needed a way to implement some of the same functionality. My first thought was to model the formulas in ActiveRecord, clause by clause, using something like acts_as_nested_set to handle hierarchies and grouping. However, I’ve done something similar before, and was never quite satisfied with the result — it always felt “heavy” — so I decided to try a different approach this time.

The result is Dentaku, a gem that parses and evaluates Excel-like formulas, allowing the use of named variables that will be substituted for real values at run time. So far, the result values will be either boolean or numeric, but strings will probably be added soon.

To illustrate how it works, let me set up the following (quite contrived) hypothetical situation: You’re building an upvote system for a Reddit-type site, but the customers do not want to encode all the logic for the system in Ruby — they need to be able to manage all the rules on the fly. However, they are willing to be limited to only using a few predefined attributes of the user as all variable inputs to the rules.

The initial ruleset is something like this: A vote from a “normal” user is worth one point for each week the user has been with the site. A vote from an “admin” user is worth 100 points. A vote from a “limited” user is worth one point, and a vote from a “blacklisted” user is worth zero points. However, users can earn achievements, which update a “bonus” number for the user, and any normal or limited user’s vote points are augmented with the bonus, but only after the user has been with the site for at least five weeks. (Hey, I promised contrived, right?) So how could we accomplish this with Dentaku?

We could create the following rules:


    +-------------------------------+----------------------+  
    | conditions                    | points               |  
    +-------------------------------+----------------------+  
    | admin                         | 100                  |  
    | normal and age_in_weeks < 5   | age_in_weeks         |  
    | limited and age_in_weeks < 5  | 1                    |  
    | normal and age_in_weeks >= 5  | age_in_weeks + bonus |  
    | limited and age_in_weeks >= 5 | 1 + bonus            |  
    | blacklisted                   | 0                    |  
    +-------------------------------+----------------------+  

Then, given a hash representing the user like:

user = {
:admin => false,
:normal => true,
:limited => false,
:blacklisted => false,
:age_in_weeks => 10,
:bonus => 8
}

we could calculate the points for a vote by the represented user like so:

def calculate_points_for(user, rules)
calculator = Dentaku::Calculator.new
rules.each do |rule|
if calculator.evaluate(rule.conditions, user)
return calculator.evaluate(rule.points, user)
end
end

  1. no rules matched, default to zero
    0
    end

So that’s what Dentaku is about — I hope someone else finds it useful. You can check it out, fork it, etc at the Dentaku Github page, or just gem install dentaku and start playing!

The Cucumber Book in print; Scripted GUI Testing updated w/Cucumber and RSpec

The Cucumber Book in print; Scripted GUI Testing updated w/Cucumber and RSpec

#318 Upgrading to Rails 3.2

Rails 3.2 sports many new features including automatic explain queries, tagged logging, key-value store in Active Record, improved migration generator and more. Learn all about these new features in this episode.

FREE Online Course: Programming for the Web with Ruby

Programming for the Web with Ruby

Registrations are now open for RubyLearning’s FREE, online course on “Programming for the Web with Ruby“. Web-based applications offer numerous advantages, such as instant access, automatic upgrades, and opportunities for collaboration on a massive scale. However, creating Web applications requires different approaches than traditional applications and involves the integration of numerous technologies. The course topics would hopefully help those that have some knowledge of Ruby programming to get started with web programming (this does not cover Ruby on Rails).

Who’s It For?

Anyone with some knowledge of Ruby programming.

Dates

The course starts on Monday, 20th Feb. 2012 and runs for 2 weeks.

How do I register?

Register here. Use the Enrollment key: PFTWWR-4I. That’s it!

Updated (13th Feb. at 6.30 hrs IST): So far we have 1556 registrations.

Course Contents

  • DAY 1
  • Using Git
    • What’s Version Control
    • What’s Git?
      • Downloading and Installing Git
      • Create a local folder
      • Let us start using Git
      • Introduce yourself to Git
      • Create your SSH Key
  • Using GitHub
    • What’s GitHub?
      • Set up your GitHub account
      • Creating a new repository
      • Add your SSH key to GitHub
  • Using RVM (for *nix)
    • What is RVM?
    • Prerequisites
    • Installing RVM
    • Loading RVM into your shell
    • Reload shell configuration and test
    • Install a Ruby interpreter
  • Using pik (for Windows)
    • What’s pik?
    • Installing pik
    • Using pik
  • Exercise 1
  • DAY 2
  • Creating a simple webpage using HTML5, CSS and JavaScript
    • A Webpage, Step by Step
    • Before we begin, Launch a Text Editor
      • Step 1: Start with content
      • Step 2: Give the document structure
      • Step 3: Identify text elements
      • Step 4: Add an image
      • Step 5: Change the look with a style sheet
      • Add some JavaScript
  • Store your webpage files on GitHub
  • Exercise 2
  • DAY 3
  • Understanding HTTP concepts
    • What’s HTTP?
      • Loading a web page
    • HTTP request methods (verbs)
      • GET
      • POST
      • PUT
      • DELETE
    • Using cURL
    • HTTP response codes
    • net/http library
      • Using URI
    • Using open-uri
    • Using Hpricot
    • Using Nokogiri
      • Fetching documents from web
      • Searching inside HTML documents
  • Exercise 3
  • DAY 4
  • Creating one’s own Ruby Gem
    • What’s a Ruby Gem?
    • Let us create a simple Ruby library
    • Steps for publishing our gem
  • DAY 5 and 6
  • Learning Rack
    • Revisiting Ruby’s proc object
      • my_proc1.rb
    • Rack Specification
    • A simple Rack app – my_rack_proc
      • my_rack_proc.rb
    • Rack Documentation
    • Rack Source Code
    • Installing Rack gem
      • my_rack_proc2.rb
    • Another Rack app – my_method
      • my_rack2.rb
    • Using rackup
      • my_app.rb
      • Using Rack::Request and Rack::Response
      • A very basic practical Rack app
      • Another practical Rack app
      • Rack middleware
      • Using Lobster
    • Rack::Builder
  • DAY 7
  • Deploying Pure Rack Apps to Heroku
    • What’s Heroku?
      • Create an account on Heroku
      • Install Bundle
      • Deploy your app to Heroku
  • DAY 8
  • Deploying a static webpage to Heroku
  • DAY 9
  • What’s JSON?
  • Using MongoDB with Ruby Mongo driver
    • What’s NoSQL?
    • What’s MongoDB?
    • Setup MongoDB
    • MongoDB Core Concepts
    • The Basics
      • Switch databases
      • Insert a document
      • Use find()
      • Removing all documents
      • Query Selectors
      • Updating a document
    • MongoDB Ruby Driver – mongo
      • Installation
      • Using the mongo gem
      • Making a Connection
      • Getting a List Of Collections
      • Getting a Collection
      • Inserting a Document
      • Updating a Document
    • MongoHQ the hosted database
      • Sign Up
      • Create a database
      • Accessing the database
  • DAY 10
  • Sinatra with MongoDB
    • What’s Sinatra?
    • Create a folder on your hard disk
    • Install Sinatra
    • Which web server?
    • Our trivial Sinatra application
    • ERB and View
      • ERB
      • View
      • Handlers and Form parameters
    • Work-In-Progress
  • References

The course contents is likely to change.

Mentors

Satish Talim, Michael Kohl, Victor Goff III and others from the RubyLearning team.

RubyLearning’s IRC Channel

Most of the mentors and students hang out at RubyLearning’s IRC (irc.freenode.net) channel (#rubylearning.org) for both technical and non-technical discussions. Everyone benefits with the active discussions on Ruby with the mentors.

Here are some details on how the course works:

Important:

Once the course starts, you can login and start with the lessons any day and time and post your queries in the forum under the relevant lessons. Someone shall always be there to answer them. Just to set the expectations correctly, there is no real-time ‘webcasting’.

Methodology:

  • The Mentors shall give you URL’s of pages and sometimes some extra notes; you need to read through. Read the pre-class reading material at a convenient time of your choice – the dates mentioned are just for your guideline. While reading, please make a note of all your doubts, queries, questions, clarifications, comments about the lesson and after you have completed all the pages, post these on the forum under the relevant lesson. There could be some questions that relate to something that has not been mentioned or discussed by the mentors thus far; you could post the same too. Please remember that with every post, do mention the operating system of your computer.
  • The mentor shall highlight the important points that you need to remember for that day’s session.
  • There could be exercises every day. Please do them.
  • Participate in the forum for asking and answering questions or starting discussions. Share knowledge, and exchange ideas among yourselves during the course period. Participants are strongly encouraged to post technical questions, interesting articles, tools, sample programs or anything that is relevant to the class / lesson. Please do not post a simple "Thank you" note or "Hello" message to the forum. Please be aware that these messages are considered noises by people subscribed to the forum.

Outline of Work Expectations:

  1. Most of the days, you will have exercises to solve. These are there to help you assimilate whatever you have learned till then.
  2. Some days may have some extra assignments / food for thought articles / programs
  3. Above all, do take part in the relevant forums. Past participants will confirm that they learned the best by active participation.

Some Commonly Asked Questions

  • Qs. Is there any specific time when I need to be online?
    Ans. No. You need not be online at a specific time of the day.
  • Qs. Is it important for me to take part in the course forums?
    Ans. YES. You must Participate in the forum(s) for asking and answering questions or starting discussions. Share knowledge, and exchange ideas among yourselves (participants) during the course period. Participants are strongly encouraged to post technical questions, interesting articles, tools, sample programs or anything that is relevant to the class / lesson. Past participants will confirm that they learned the best by active participation.
  • Qs. How much time do I need to spend online for a course, in a day?
    Ans. This will vary from person to person. All depends upon your comfort level and the amount of time you want to spend on a particular lesson or task.
  • Qs. Is there any specific set time for feedback (e.g., any mentor responds to me within 24 hours?)
    Ans. Normally somebody should answer your query / question within 24 hours.
  • Qs. What happens if nobody answers my questions / queries?
    Ans. Normally, that will not happen. In case you feel that your question / query is not answered, then please post the same in the thread – “Any UnAnswered Questions / Queries”.
  • Qs. What happens to the class (or forums) after a course is over? Can you keep it open for a few more days so that students can complete and discuss too?
    Ans. The course and its forum is open for a month after the last day of the course.

Remember, the idea is to have fun learning Ruby.

Acknowledgments

About RubyLearning.org

RubyLearning.org, since 2005, has been helping Ruby Newbies go from zero to awesome!

Technorati Tags: , , , ,


(Powered by LaunchBit)

Modularized Association Methods in Rails 3.2

Happy Friday! It’s Rails 3.2 day! The official release announcement mentions a few of the big changes, but I’d like to take a moment to highlight a relatively small change I was responsible for, one that I hope may make your life a little easier.

From the ActiveRecord CHANGELOG:

Generated association methods are created within a separate module to allow overriding and
composition using `super`. For a class named `MyModel`, the module is named
`MyModel::GeneratedFeatureMethods`. It is included into the model class immediately after
the `generated_attributes_methods` module defined in ActiveModel, so association methods
override attribute methods of the same name. *Josh Susser*

The point of this change is to allow more flexibility in working with associations in your model classes. When you define an association, ActiveRecord automagically generates some methods for you to work with the association. For example, a has_many :patches association generates the methods patches and patches= (and a few others).

Previously, those association methods were inserted directly into your model class. This change moves those methods into their own module which is then included in your model class. Your model gets the same methods through inheritance, but also gets to override those methods and still call them using super. Let’s take a look at two ways this makes things easier for you.

Sometimes you want to replace the standard generated association methods. That’s always been easy to do simply by defining new methods in your model class. The only wrinkle was that you had to make sure you defined your method after you set up the association, or calling has_many would overwrite your method, since last writer wins. That was usually not a problem, but sometimes plugins or other monkey patching extensions could add an association after your model’s class was defined, which wouldn’t give you a chance to add your method afterwards. With this change, you don’t have to worry about those order dependencies anymore. Since those methods are generated in their own module, the order doesn’t matter. This is a pretty small issue all told and I doubt it affected many people, but it’s still worth mentioning.

The real reason for this change is being able to compose your own methods with the standard generated methods. Before this change, you’d have to use alias_method_chain or some other fancy footwork to layer your own logic on top of the standard association functionality. Either that or you’d have to somehow duplicate the standard behavior in your own method. Ick. Now you can compose methods using inheritance and super, the way Alan Kay intended you to. Here’s the example from the docs:

class Car < ActiveRecord::Base
  belongs_to :owner
  belongs_to :old_owner

  def owner=(new_owner)
    self.old_owner = self.owner
    super
  end
end

If you’re familiar with ActiveRecord it’s probably fairly obvious what’s going on there, but I’ll spell it out for the new kids. When you define the belongs_to :owner association, that generates a standard owner= method, and puts it in the module named Car::GeneratedFeatureMethods, which is the closest ancestor of class Car. If you’re curious what this looks like, fire up the rails console and type Car.ancestors to see the class’s inheritance chain. (Or use your own app and model, since that will be much easier than making up a new app just to see that one thing.)

In this Car class, you can see that changing owners keeps track of the old owner, so the new owner knows who to call when he can’t figure out how to open the trunk. The generated owner= method does a fair amount of stuff including managing counter caches, running callbacks, setting inverse associations, etc. Skipping that could break a number of things, so after saving the old owner, you also want to run the generated method. Since it’s in a module that Car inherits from, you only have to call super to get that to run. No muss, no fuss!

One more step towards simpler OOP in Rails! Thanks to my fellow Ruby Rogues Avdi Grimm and James Edward Gray II for complaining about the old state of things enough to motivate me to finally go fix this.

Ruby Heroes

Jason and Peter talk about Git Heroes, Ruby Heroes, and the usual round up of projects, blog posts, and gems.

Rails 3.2.0: Faster dev mode & routing, explain queries, tagged logger, store

So we didn’t quite make the December release date as we intended, but hey, why break a good tradition and start hitting release targets now! In any case, your patience has been worldly rewarded young grasshopper: Rails 3.2 is done, baked, tested, and ready to roll!

I’ve been running on 3-2-stable for a few months working on Basecamp Next and it’s been a real treat. The new faster dev mode in particular is a major step up over 3.1.

Do remember that this is the last intended release series that’s going to support Ruby 1.8.7. The master git branch for Rails is now targeting Rails 4.0, which will require Ruby 1.9.3 and above. So now is a great time to start the work on getting your app ready for the current version of Ruby. Let’s not hang around old versions forever and a Sunday like those Python guys :).

There’s a v3.2.0 tag on Github and we of course we still have the 3-2-stable branch as well. You can see all the glorious details of everything that was changed in our CHANGELOG compilation.

For documentation, we have the 3.2 release notes with upgrade instructions, both the API docs and the guides have been generated for 3.2 as well, and there’s a brand new 3.2-compatible version of Agile Web Development with Rails. A smörgåsbord indeed!

Note: If you’re having trouble installing the gems under Ruby 1.8.7, you’ve probably hit a RubyGems bug with YAML that’s been fixed in RubyGems 1.8.15. You can upgrade RubyGems using “gem update—system”.

If you can’t be bothered with the full release notes, here’s a reprint of a few feature highlights from when we did the first release candidate:

Faster dev mode & routing

The most noticeable new feature is that development mode got a ton and a half faster. Inspired by Active Reload, we now only reload classes from files you’ve actually changed. The difference is dramatic on a larger application.

Route recognition also got a bunch faster thanks to the new Journey engine and we made linking much faster as well (especially apparent when you’re having 100+ links on a single page).

Explain queries

We’ve added a quick and easy way to explain quieries generated by ARel. In the console, you can run something like puts Person.active.limit(5).explain and you’ll get the query ARel produces explained (so you can easily see whether its using the right indexes). There’s even a default threshold in development mode where if a query takes more than half a second to run, it’s automatically explained inline—how about that!

Tagged logger

When you’re running a multi-user, multi-account application, it’s a great help to be able to filter the log by who did what. Enter the TaggedLogging wrapper. It works like this:

Logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
Logger.tagged("BCX") { Logger.info "Stuff" } # Logs "[BCX] Stuff" 
Logger.tagged("BCX") do
  Logger.tagged("Jason") do
    Logger.info "Stuff" # Logs "\[BCX\] \[Jason\] Stuff" 
  end
end

Active Record Store

Key/value stores are great, but it’s not always you want to go the whole honking way just for a little variable-key action. Enter the Active Record Store:

class User < ActiveRecord::Base
  store :settings, accessors: [ :color, :homepage ]
end
u = User.new(color: 'black', homepage: '37signals.com')
u.color                          # Accessor stored attribute
u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor

This Week in Ruby: Nominate Your Ruby Heroes, Include/Extend, Ruby on Netbeans, Jekyll-Bootstrap, and more

Welcome to this week’s Web-based syndication of Ruby Weekly, my Ruby e-mail newsletter.

Headlines

Vote for your ‘Ruby Hero’ in the Ruby Hero Awards
The Ruby Heroes awards run each year and present 6 community nominated ‘heroes’ with an award at RailsConf. Nominations are now open so go and drop your nomination for the Rubyist whose code has brightened up your life the most in the past year.

Heroku Receives InfoWorld’s Technology of the Year Award
Sorry it’s just a press release but it’s great to see a company that came up from the Ruby world continue to do well. Congrats to the Heroku team.

Articles and Tutorials

Hashes and Encapsulation
Jon Leighton demonstrates why accessing hash elements in a “obj.hashthings[‘foo’]” style isn’t the way to go and how to act in a way that respects encapsulation, a tenet of object orientation.

Explaining Ruby’s Include and Extend
Aaron Lasseigne gives a simple introduction to the ideas behind the ‘include’ and ‘extend’ methods.

Why Sinatra’s Halt is Awesome
Myron Marston draws attention to Sinatra’s ‘halt’ method which you can use to immediate stop a request within a filter or route, and explains why he likes it for handling exceptions in Sinatra apps.

Replace Your Test Helpers with a Reusable API
Eric Hodel makes an interesting argument that instead of leaning on test helper files all of the time, perhaps there are common bits of functionality you can bake into your library or app’s own APIs.

assert_nothing_tested..
Ryan Davis demonstrates why his popular minitest testing library doesn’t have an assert_nothing_raised assertion by picking on a relatively useless test in Rails.

A Workaround for Ruby Support on Netbeans 7.1
Back in February 2011, Netbeans (a popular IDE) dropped its official support for Ruby but the JRuby team offered to pick up the slack. Thomas Enebo has been working on it and has some code to make Ruby support work on Netbeans 7.1 here.

Rails or Sinatra: The Best of Both Worlds?
Over at RubySource, Darren Jones rounds up the opinions and assessments of several well known Rubyists when it comes to choosing Sinatra or Rails for a project. An interesting high level collection of ideas.

Media

The Ruby Rogues on Versioning and Releases
The world’s favorite Ruby podcast, Ruby Rogues, is back with an episode all about the versioning of code, Ruby libraries, gems, and more. This time out, James Edward Gray II takes the helm.

Private Pub (RailsCasts)
Private Pub is a gem for use with Rails to publish and subscribe to real-time messages through Faye. You get real-time updates through an open socket without tying up a Rails process. Ryan Bates shows you how to use it in a mere 7 minutes.

Libraries and code

ROFLBALT: A Terminal-based ASCII Side Scroller Game
At RailsCamp X, Paul Annesley and Dennis Hotson built this nifty little side scrolling game which works straight from your terminal (256 color support needed though). Surprisingly good for a quick effort.

TwoStroke: A JavaScript Implementation Written in Ruby
Charlie Somerville presents an interesting working (but incomplete) JavaScript implementation, written entirely in Ruby. One of those projects that may seem useful somewhere down the line but for now is just a neat idea.

Guard::RSpectacle: An RSpec Plugin for Guard
Guard::RSpectacle automatically tests your application with RSpec when files are modified. This sounds like guard-rspec on the surface, but RSpectacle acts as an ’embedded’ runner within a running Rails app and reloads changed files on the fly.

Juvia: An Open Source Commenting System from Phusion
For a while now, Hongli Lai of Phusion (the geniuses behind Passenger and REE) has been working on a Rails-based open source commenting system that you can include into your site using JavaScript.

Jekyll-Bootstrap: A Quick Way to Start Off Your Own Jekyll-Powered Site
Jekyll is a blog-focused static site generator, and Jekyll users often recommend cloning an existing Jekyll blog to use as a starting point. Jekyll-Bootstrap takes this idea to the next level by attempting to be the definitive Jekyll framework to clone.

OEmbedr: Lightweight, Flexible OEmbed Consumer Library
oEmbed is a format for allowing an embedded representation of a URL on third party sites OEmbedr makes consuming oEmbed from any source simple.

Hobson: A Resque-based Distributed Test Runner
Hobson distributes your test suite across N machines and aggregates the results live on a locally run webapp. I haven’t tried it yet but on a trawl through the source code it seems to be for Cucumber and RSpec only.

Vesper: A New Sinatra-based Webapp Framework
Yes, it’s ‘yet another’ webapp framework but Vesper is based on top of Sinatra, already has several plugins, and features a handy 6 minute screencast on its homepage.

Ruby Jobs of the Week

Ruby Framework Engineer Job at Zendesk [San Francisco]
The fantastic folks over at Zendesk, the help desk and support ticket app, are looking for a creative and seasoned Ruby engineer to focus on improving their code base. They want full stack engineers who can improve and refactor their frameworks and lead an open source effort by publishing some of the resulting gems.

Last but not least..

Owning Rails: Marc Andre Cournoyer’s Online Rails Masterclass
Marc Andre Cournoyer (of Create Your Own Programming Language fame) is running another of his highly praised 2 day, online Rails masterclasses. Marc’s given me a discount code you can use to get 80 dollars off – it’s ‘rubyweekly’. I disclose that I make a commission on this but I won’t promote trash and the testimonials speak for themselves 🙂

The Programming Language Masterclass: Another Marc-Andre Class
Along similar lines, Marc Andre Cournoyer also runs a more general class aimed at giving you an understanding of the inner workings of programming languages and programming language implementation. ‘SAVEME50’ gets you a discount and it’s in mid February.

InfoWorld Names Heroku a 2012 Technology of the Year

InfoWorld has named Heroku as a 2012 Technology of the Year. While we’re not normally much for industry awards, we feel honored to be included alongside past winners such as the iPad, Android, Visual Studio, and Eclipse; and this year’s winners, including Amazon Web Services, Node.js, Hadoop, CloudBees, and Heroku add-on provider Rhomobile.

InfoWorld is a venerable publication in the technology world, and this is the first time they’ve given awards in the cloud space. We see this as another major point of validation for platform-as-a-service, and cloud technologies more generally. 2011 was the year that PaaS came into the greater collective consciousness of the technology industry. We can’t wait to see how things will unfold in 2012.

Deploying Rails: Automate, Deploy, Scale, Maintain, and Sleep at Night now in beta

Deploying Rails: Automate, Deploy, Scale, Maintain, and Sleep at Night now in beta

Migration downtime for RubyLearning

Migration downtime for RubyLearning

RubyLearning websites and services (http://rubylearning.com/, http://rubylearning.org/ and http://satishtalim.com/) will be down for scheduled maintenance according to this time schedule. We would be offline no longer than 4 hours. During this time, we will be migrating our Slice from the St. Louis (STL) to the Chicago (ORD) datacenter of Slicehost.

Update: The site migration is complete. Thank you for your understanding and patience.

Technorati Tags: ,


(Powered by LaunchBit)

PostgreSQL 9.1 Available in Beta on Heroku Postgres

From the Heroku Postgres Blog:

"One of the benefits of consuming a database through Heroku Postgres is that we are continually improving the service. This benefit is compounded by the fact that our service is based on PostgreSQL, a vibrant and active open source project. The release of PostgresSQL 9.1 had added a number of feature, performance and reliability improvements. These are available today with our beta support for PostgreSQL 9.1 …"

→ Read More

Check out the Heroku Postgres Blog to read more.

The Last Week in Ruby: RSpec 2.8, Redcar 0.12, Torquebox 2.0 beta, articles and more

Welcome to this week’s Web-based syndication of Ruby Weekly, the Ruby e-mail newsletter. While I have you, be sure to follow @RubyInside on Twitter as I’m going to be posting news more frequently there than on the Web site in future.


Also, if you’re interested in getting one interesting programming related quote or link each day on Twitter, check out @codewisdom.


Headlines

RSpec 2.8: The Popular Ruby BDD Tool Goes Supersonic
RSpec 2.8 and rspec-rails 2.8.1 have been released and some users have been reporting significant performance improvements. Other tweaks include improved documentation, better tag and filtering options, random example execution, and ‘rspec –init’ for adding RSpec to an empty Ruby project.

TorqueBox 2.0 Beta 2 Released
Torquebox is a popular JBoss-powered application server for Ruby webapps that provides a smorgasbord of useful backend features. This beta of the 2.0 release boasts the latest versions of JRuby and JBoss and new support for WebSockets/STOMP.

Redcar 0.12 Released: An Editor Built in Ruby
Redcar is a programmers’ text editor written in Ruby and this latest release has streamlined its installation and added Mac OS X Lion support.

Articles and Tutorials

The Status of DataMapper
DataMapper is a popular Ruby ORM and an interesting alternative to ActiveRecord. In this post, Piotr Solnica explains what’s happening with DataMapper 2.0 and how it aims to implement the Data Mapper pattern in full. The systems outlined in this post could resolve a lot of issues people have been having with ActiveRecord, it seems.

Does My Rails App Need A Service Layer?
Jared Carroll picks up on a common thread being discussed in the Rails world lately: service layers. He explains what ‘services’ are, what types of service can exist, and tries to briefly explain his opinion on their usage within the context of Rails. I’m not entirely comfortable with his conclusion but it’s a good introduction nonetheless.

An Exhaustive Explanation of Minimax: A Staple AI Algorithm
An appealing explanation of an algorithm that can be used to ‘intelligently’ play Tic Tac Toe, complete with a simple Ruby implementation.

Rails Development on Ubuntu 11.10: Setting Up a Dev Environment
Eric Proctor wanted to refresh his setup for 2012 so sat down to install a Rails development stack from scratch on Ubuntu 11.10. He shares the process here in case you want to repeat it for yourself.

How to Create A Local Copy of the Rails API Docs and Guides
If you’re like many Rails developers, you might frequently hit the Rails docs and guides via Google searches, but if you want access to these useful resources when offline, Aslam Najeebdeen has the answer.

Hosting Your Own Local RubyGems Server
Want to have your own in-house RubyGems server? It’s easy and Michael Erasmus shows you how in this post.

Ruby Float Quirks
Clemens Helm stumbles across a rudimentary floating point representation issue, but one that can trip you up nonetheless if you’re not aware of it.

Capybara, Cucumber and How the Cookie Crumbles
Steve Richert of Collective Idea wanted to punch through Capybara and be able to set cookies that would “Just Work” from anywhere in his Cucumber suite. Here, he shows you how he did it.

Screencasts

Pretty URLs with FriendlyId (RailsCasts)
If you are tired of model ids in the URL, overriding to_param can only get you so far. The friendly_id plugin can help by making it easy to generate a URL slug and maintain a history. Ryan Bates shows us how in a mere 7 minutes.

Libraries and code

Puma: A Ruby Web Server Built For Concurrency
Puma is a simple, fast, and highly concurrent HTTP 1.1 server for Ruby webapps. It can be used with any application that supports Rack and makes the audacious claim that it ‘is considered the replacement for WEBrick and Mongrel.’

confstruct: Yet Another Configuration Object for Ruby
Confstruct optimistically bills itself as ‘yet another configuration gem.’ It’s definable and configurable by hash, struct, or block and aims to provide the flexibility to do things your way, while keeping things simple and intuitive.

coffee-script-pure: A Pure Ruby CoffeeScript Compiler
CoffeeScript was originally implemented in Ruby so it’s interesting to see Charlie Somerville bring it full circle by reimplementing the current CoffeeScript compiler in pure Ruby.

rack_session_access: Rack Middleware for ‘rack.session’ Environment Management
rack_session_access makes it possible to change values within the application session of your Rack-backed app.

Ruby Jobs of the Week

Ruby and Rails Entwickler bei blau Mobilfunk GmbH [Hamburg, Deutschland]
Unfortunately I don’t speak German but it’s great to see a wider variety of locations in the jobs. So if you’re looking for a Rails job in Germany or know someome who is, check this out.

Last but not least..

Exceptional Ruby: Master The Art of Handling Failure in Ruby
I can’t help but continue to recommend Avdi Grimm’s awesome ‘Exceptional Ruby’ e-book if you want to dig deep into the world of exceptions and error handling in Ruby. I enjoyed it a lot (and I’m not even making a bean on this recommendation :-))

#316 Private Pub

Private Pub makes it easier than ever to publish and subscribe to real-time events in a Rails app. You can use publish_to with a block of JavaScript or supply a hash for use with JSON.

RSpec 2.8, Rack 1.4, Redis Store

Jason and Peter talk about the new releases of RSpec, Rack, and go over interesting projects and blog posts. They go over Ruby strings, accessing the application session in Capybara, and some interesting new posts and projects.