How do I download the code for a Gem?

Go To StackoverFlow.com

0

I want to download the code for a gem, but the author didn't give a link to a Github repository (or anything else) to download it from directly. For now, did gem install and copied the directory under "ruby/gems/...", where the source is located. Is there an easier way of doing this (a one-liner)?

2012-04-05 21:13
by Andres Riofrio
The gem has to include the code or it won't run. Once you do an install, look in the directory it installed into and you'll find the code - the Tin Man 2012-04-05 21:52
That's what I did—but I was hoping for a short, direct one-liner. : - Andres Riofrio 2012-04-05 21:59


2

You can gem unpack gem_name, which will unpack the gem in the current working directory. If it is already installed the local version will be used, otherwise it will be fetched first:

→ gem unpack datamapper
Fetching: datamapper-1.2.0.gem (100%)
Unpacked gem: '/Users/michi/datamapper-1.2.0'
2012-04-05 22:10
by Michael Kohl


1

You can use gem-open, a gem that once installed you can use to open gems in your editor: https://github.com/fnando/gem-open

2012-04-05 22:03
by three
This is great too, but the Michael's answer is more useful for me. Often times when I get a gem, I'll want to look around in the terminal a bit before opening it up in an editor - Andres Riofrio 2012-04-22 22:27
Time to become a vim/emacs/nano... person - three 2012-04-23 14:59
I had a bit of a foray into Sublime because it comes preconfigured pretty awesomely. I kinda don't want to spend lots of time making my text editor behave sanely. But eventually I'll probably move to vim - Andres Riofrio 2012-04-23 17:38
I can't say if it's worth the trouble. It fully depends on what you like. I use it because I like my terminal and to keep things simple - three 2012-04-23 17:55
I would use it because of tight CLI integration, I think. And because keeping my hands on the home row (rather than on the arrow keys) is much easier on a laptop, when I don't have an external keyboard - Andres Riofrio 2012-04-23 18:30
It's a tool. Nothing more. There are times for arrow keys and times for the home row. The code is important, not the editor. Stupid editor wars - three 2012-04-23 18:56
Ads