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

9 New Ruby Libraries To Check Out

By Peter Cooper / December 10, 2009

love-your-library.pngI love checking out new Ruby libraries, and recently many new ones have passed my eyes. The most prominent releases get their own post on Ruby Inside, but often there are less significant libraries that I'd struggle to write 100 words about yet still contribute to Ruby's lifeblood. This post aims to round up a selection of my recent discoveries.

RConfig - Powerful Ruby configuration management

RConfig, by Rahmal Conda, bills itself as a "complete solution for Ruby configuration management" and it certainly has a compelling feature-set. It supports YAML, XML, and properties files (a bit like INI files) and provides a short hand global access to application configurations in both enumeration-based and dot-notation/method forms. It also supports what it calls "overlays" where different configurations can be used within a single app (for different "environments", say). RConfig can be installed as a gem as it's hosted on Gemcutter.

Ruby-GMail - A Rubyesque interface to GMail

Ruby-GMail is an awesome new library by Daniel Parker that provides significant GMail-specific (Google Mail) functionality within your apps. You can read/retrieve e-mails via IMAP, fully handle attachments, deal with labels, mark items as spam/unread/read, and send e-mails (including MIME messages with images and attachments).

Excelsior - Super fast CSV parsing

Excelsior (GitHub) is a Ruby gem by Matthew Mongeau that binds to some C code that parses CSV (comma delimited) data very quickly. Matthew benchmarked Excelsior against the built in Ruby 1.9 'csv' parser (based on 1.8's FasterCSV) and a 1 million row CSV file was parsed in 4.44 seconds with Excelsior versus 54 seconds for the built-in library. As well as being a useful library, the source is useful to check out if writing a native extension of your own is of interest.

Linkedin - Ruby Bindings for the LinkedIn API

If you don't know about it, LinkedIn is basically a Facebook for business contacts and relationships. You get profiles, can message other people, and build up "connections" with other people (as an aside, if you want to add me - Peter Cooper - on your LinkedIn, my profile is here). Wynn Netherland has put together a tidy Ruby library to use LinkedIn's new API features. His blog post highlights some uses for it.

Ohm - Object-hash mapping library for Redis

Redis is one of a growing number of persistent key-value database systems, and Ohm is a library for storing objects in a Redis database. It was built by Citrusbyte - the team behind the Monk Ruby Web development framework. As an aside, Citrusbyte are looking for a software engineer to work with them in Los Angeles.

Alchemist - Conversion between units

Alchemist is another library by Matthew Mongeau. It makes it easy to convert between different units - such as from miles to meters or celsius to kelvin with code like 8.meters.to.miles or in operations like 10.kilometers + 1.mile. It was mentioned in an earlier Ruby Inside post but fits in well here too.

Nanotest - Super lightweight testing

Nanotest is, perhaps, the most lightweight testing library available for Rubyists today. Billing itself as "extremely minimal," it provides the bare minimum needed to test code in a constructive manner. When it was mentioned on RubyFlow recently, Nanotest got quite a bit of flack..

Savon - "Heavy metal" SOAP client library

Unlucky enough to need to use SOAP (Simple Object Access Protocol)? Savon presents a new, intriguing alternative to Soap4R (which few people seem to be particularly complimentary about). If your SOAP service is SOAP 1.1 compliant, has a WSDL file, and doesn't need WSSE authentication, you can be calling methods in just two lines of Ruby. You can do a lot more with further tweaks, however (including SOAP 1.2 and WSSE authentication).

Versionomy - A "version number" library

Versionomy by Daniel Azuma is a library that provides tools to represent, manipulate, parse, and compare version numbers in the wide variety of versioning schemes in use. In this sense, think of it as a Chronic for version numbers.

Comments

  1. Aslak Hellesøy says:

    I love how the CVS lexer is 100 LOC of Ragel. Ragel is so awesome. With a small dose of rake-compiler and MinGW it would be easy to build precompiled binaries for Windows too.

  2. raggi says:

    Not a bad word against Excelsior, but I think slurping 55mb vs. slurping nothing isn't really a fair or honest representation of the relative speeds of the libraries...

  3. raggi says:

    And yeah, ragel is *awesome* :)

  4. Richard Conroy says:

    If its Ragel, then there are sweet options for getting JRuby support in too. A lot of the early JRuby gem successes (i.e. supporting non-pure ruby gems) came from using Ragel to spit out Java instead of C/C++.

    The early ports of Mongrel & Hpricot were done this way.

  5. rubiii says:

    really nice to see savon linked up here! but i need to make some adjustments to the summary: savon should be soap 1.1 and 1.2 compatible. and it also includes support for wsse authentication. thanks :)

  6. Rahmal Conda says:

    Thanks for the shoutout Peter. I hope the RubyInside community find rconfig useful. Just a couple things to note:

    Rconfig also supports callbacks for loading configs. It can be individual configs, or any config.

    class MyClass
    @@my_config = {}
    RConfig.on_load(:cache) do
    @@my_config = {}
    end
    def my_config
    @@my_config ||=
    expensive_configured_proc(RConfig.cache.memory_limit)
    end
    end

    RConfig Overlays are a way to have environment-specific configs override the default configuration unobtrusively.

    ...database_production.yml would override database.yml in production env...
    ...database_.yml would override database.yml on ...

    The code is on github at http://github.com/rahmal/rconfig
    You can log bugs on Rubyforge: http://rubyforge.org/projects/rconda-rconfig

  7. Jerod Santo says:

    Ruby-Gmail looks like it will fit nicely into my toolbox. Hiding nasty IMAP commands is always welcome.

  8. Jaime Iniesta says:

    Hey, I was just looking for a LinkedIn gem, thank you!

  9. ben says:

    Great selection !!!

  10. James Edward Gray II says:

    I think the built-in CSV library offers a few advantages Excelsior has yet to offer. It is very fast though, for sure.

  11. Peter Cooper says:

    I agree - I had a dig into the code and it's just a straight parser. That said, it might be interesting if it monkey patched regular CSV to get the same speed increases (and/or ultimately made up some of the code in MRI).

  12. Stephen Stillwater says:

    Just be careful with Ragel - it tends to make people go crazy and write huge long rants or suddenly abandon Ruby forever.

  13. Keith Hanson says:

    Is... erm... Ohm new? I've been using it for months now? What *else* would you use for Redis that is as easy and nice to use as Ohm is? :P

  14. mikhailov says:

    Redis - great! that is github based on.
    Key-value database is a suitable approach to a new-wave web-applications.

Other Posts to Enjoy

Twitter Mentions