Has much changed with the release of Bundler? Is there a template that can be used as a base? What are the best practices?
RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.
A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.
When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.
Some posts that I have found useful:
Edit (2012-01-10): An excellent all-around guide to gem best practices is RubyGems Guides. I would highly recommend starting here now.
To summarize the key points:
lib/gem.rb
and lib/gem/
structure for code.bin
, any data files in data
and tests in test
or spec
.require
or depend upon files outside of the load path. (VERSION
files often seem to live in odd places in gems.)require 'rubygems'
.$LOAD_PATH
.require File.join(__FILE__, 'foo', 'bar')
, you're doing it wrong.The simplest way it's to use bundler:
bundle gem <gem_name>
You may even use it in an existing project from the parent directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With