[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[OOT] rubygems: location of my gems

Nasir Khan

1/4/2008 6:49:00 PM

[Note: parts of this message were removed to make it a legal post.]

Hi,

Is there an easy way of finding the location of my installed gem
programmatically.
I need this to create an environment variable.

Thanks
Nasir

6 Answers

Michael Greenly

1/4/2008 6:55:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

not in front of a computer but 'gem env | grep -i gempath' should come close
to working

On Jan 4, 2008 12:49 PM, Nasir Khan <rubylearner@gmail.com> wrote:

> Hi,
>
> Is there an easy way of finding the location of my installed gem
> programmatically.
> I need this to create an environment variable.
>
> Thanks
> Nasir
>



--
Michael Greenly
http://blog.michaelg...

Luis Lavena

1/4/2008 6:55:00 PM

0

On 4 ene, 16:49, Nasir Khan <rubylear...@gmail.com> wrote:
> [Note: parts of this message were removed to make it a legal post.]
>
> Hi,
>
> Is there an easy way of finding the location of my installed gem
> programmatically.
> I need this to create an environment variable.

C:\Documents and Settings\Usuario>irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> Gem.dir
=> "C:/Ruby/lib/ruby/gems/1.8"
irb(main):003:0>


HTH,
--
Luis Lavena

James Tucker

1/4/2008 7:19:00 PM

0

gem which gemname

e.g.

raggi@mbk:~$ gem which hpricot
(checking gem hpricot-0.6 for hpricot)
/opt/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot.rb

On 4 Jan 2008, at 14:49, Nasir Khan wrote:

> Hi,
>
> Is there an easy way of finding the location of my installed gem
> programmatically.
> I need this to create an environment variable.
>
> Thanks
> Nasir


Ken Bloom

1/4/2008 7:38:00 PM

0

On Fri, 04 Jan 2008 13:49:21 -0500, Nasir Khan wrote:

> [Note: parts of this message were removed to make it a legal post.]
>
> Hi,
>
> Is there an easy way of finding the location of my installed gem
> programmatically.
> I need this to create an environment variable.
>
> Thanks
> Nasir

__FILE__ will tell you the location of the file in which you use it. So
when my SqlStatement gem is installed on Debian, the location of
sqlstatement.rb is /var/lib/gems/1.8/gems/SqlStatement-1.0.2/lib/
sqlstatement.rb, and I can find other paths in the directory tree by
taking them relative to the known location of that file in my directory
tree.

--Ken

--
Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

James Gray

1/4/2008 7:54:00 PM

0

On Jan 4, 2008, at 12:49 PM, Nasir Khan wrote:

> Is there an easy way of finding the location of my installed gem
> programmatically.

Sure:

gem_spec = Gem::GemPathSearcher.new.find(require_name)
gem_dir = File.join(gem_spec.full_gem_path, gem_spec.require_path)

Hope that helps.

James Edward Gray II

Nasir Khan

1/4/2008 8:35:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

This is exactly what I was looking for. Thanks a lot.

On 1/4/08, James Gray <james@grayproductions.net> wrote:
>
> On Jan 4, 2008, at 12:49 PM, Nasir Khan wrote:
>
> > Is there an easy way of finding the location of my installed gem
> > programmatically.
>
> Sure:
>
> gem_spec = Gem::GemPathSearcher.new.find(require_name)
> gem_dir = File.join(gem_spec.full_gem_path, gem_spec.require_path)
>
> Hope that helps.
>
> James Edward Gray II
>
>