Ruby On Rails, Design, Simplicity, Web 2.0, Ajax, Mac and Tons of Pizza.

Apr 02

Discover Gem Bundler

Posted by Sandro Paganotti in Ruby on Rails - no comments digg this add to delicious

I’m experimenting some features from Bundler, the new standard gem for calculating gem dependencies. Bundler works out of the box with Rails 3.0 but can also be implemented into Ruby projects without much effort.

All you have to do is install bundler with the command:

gem install bundler

Then you may create your Gemfile in your project root directory specifing wich gems you need; there is no DSL, just pure Ruby code with some nice helpers:


source "http://rubygems.org" 
gem "nokogiri" 

If you call ‘bundle install’ from command line now, all the missing gem specified in the Gemfile are installed (and compiled) automatically.

To benefit from these gems within your code you need to put on top of your .rb file the following lines:


require "rubygems" 
require "bundler" 
Bundler.setup

# now you can require all the gems specified in your Gemfile
require "nokogiri" 

And that’s it.

Post a comment

Categories:

Tags:

Powered by Mephisto, Valid XHTML 1.1, Valid CSS - Supported by Wave Factory