Andrew Chalkley the (Micro) Blog

Introducing RubyHelpers

I am pleased to announce RubyHelpers gem.

When building lightweight Ruby apps in Sinatra and the like, I often need some extra functionality that Ruby doesn’t have baked in. I end up repeating snippets of code hear and there. I thought I’d bundle it in a gem for my own use and contribute it to the Ruby community.

I have extended Object to include the blank? similar to that found in Rails. For example “”.blank?, nil.blank?, {}.blank?, [].blank? etc

I have extended String to have to_html to use RedCloth to convert textile to (X)HTML. For example “h1. *Hello World*”.to_html would produce “<h1><strong>Hello World</strong></h1>”

I have extended Hash to have dot notation to access values via keys and to have {key}_exists? method too. For example person.first_name instead of person[“first_name”], person.phone_numbers.office person.phone_numbers.mobile_exists?

The Hash extension is really handy after parsing a JSON object. It feels so much nicer to access values via dot notation.

So start using it in your projects:

sudo gem install rubyhelpers

Check out the docs and contribute other RubyHelpers on good old GitHub.




Introducing Revver4R

Here is my first RubyGem and Rails Plugin, Revver4R. A simple Ruby way of grabbing videos from Revver. Check it out on my github account.

Enjoy Revver for Ruby!

P.S. It’s realised under the MIT license


11
To Tumblr, Love Metalab