Zombo
Zombo

Reputation: 1

Command line get path to gem

I found this question, but he specifially says no command line. Well I do want command line. I see I can run

$ gem which jekyll
/usr/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll.rb

However I would prefer something like

$ foo jekyll
/usr/lib/ruby/gems/1.9.1/gems/jekyll-0.12.0

where foo is the mystery command. I can parse gem which if needed, but prefer something more elegant. Note, bundle is out of the question.

Upvotes: 1

Views: 7343

Answers (3)

Nikhil Thombare
Nikhil Thombare

Reputation: 1198

It useful to get a location of the library file with:

$ gem which "gemname"

Upvotes: 1

Aleksei Matiushkin
Aleksei Matiushkin

Reputation: 121010

Since gem is simply a ruby script wrapper around Gem::GemRunner and you want to gain a functionality not implemented within default set of commands, I would suggest you to create your own Gem::Command.

It’s really straightforward, plus you may implement as many additional functionality as you want.

Hope it helps.

Upvotes: 1

pjmorse
pjmorse

Reputation: 9304

If you are using Bundler, bundle show <gem name> does what you're after. I'll look into non-Bundler.

Upvotes: 10

Related Questions