This post originated from an RSS feed registered with Ruby Buzz
by Eric Hodel.
Original Post: My Favorite gem Commands
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
My two favorite gem commands are gem install -i ~/tmp/gems and gem which, followed closely by the gem fetch gemname; gem unpack gemname combo.
Now that the install command automatically installs all the necessary dependencies into the installation directory, it’s easy to pull down a gem and play with it without having to do the work of cleaning out all it’s dependencies from your main repository. A simple rm -r ~/tmp/gems is all it takes to clean up.
While I seldom have a need to use it, gem which tells you which file would get loaded when you require something. For example:
<samp>$ gem list activerecord
*** LOCAL GEMS ***
activerecord (1.15.6, 1.15.3)
$ gem which active_record
(checking gem activerecord-1.15.6 for active_record)
/System/Library/Frameworks/[...]/gems/activerecord-1.15.6/lib/active_record.rb</samp>
Finally, if I just want to poke at some code from a gem without bothering to poke through a gem repository, you can use gem fetch gemname; gem unpack gemname and you’ll have a gemname-version directory with the gem sitting right in front of you.