[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

using gems without installing them (like jar files

Suraj Kurapati

6/30/2008 8:07:00 PM

Hello,

Is it possible to use gem files without having to install them, like you
can with jar files in Java?

For instance, I have a gem/ directory containing various gems, and I
would like to add gem/ to the load path and simply require() the gem by
name:

# add gem/ to load path
$: << File.join(File.dirname(__FILE__), 'gem')

# use the 'foo' gem
require 'foo' # loads gem/foo-1.0.0.gem/lib/foo.rb

If gem files in the load path can be treated as a virtual file system
(VFS) then this should be possible, no?

Thanks for your consideration.
--
Posted via http://www.ruby-....

3 Answers

Eric Hodel

6/30/2008 10:15:00 PM

0

On Jun 30, 2008, at 13:06 PM, Suraj Kurapati wrote:
> Is it possible to use gem files without having to install them, like
> you
> can with jar files in Java?

No.

> For instance, I have a gem/ directory containing various gems, and I
> would like to add gem/ to the load path and simply require() the gem
> by
> name:
>
> # add gem/ to load path
> $: << File.join(File.dirname(__FILE__), 'gem')
>
> # use the 'foo' gem
> require 'foo' # loads gem/foo-1.0.0.gem/lib/foo.rb

Instead you can do:

gem install -i ~/tmp/gems foo
GEM_HOME=~/tmp/gems ruby my_foo_using_program.rb
rm -r ~/tmp/gems

> If gem files in the load path can be treated as a virtual file system
> (VFS) then this should be possible, no?

Somebody would need to write that code, but it would only work for
gems without extensions to be compiled, and would not generate useful
documentation.

Suraj Kurapati

6/30/2008 10:37:00 PM

0

Eric Hodel wrote:
> Instead you can do:
>
> gem install -i ~/tmp/gems foo
> GEM_HOME=~/tmp/gems ruby my_foo_using_program.rb
> rm -r ~/tmp/gems

Awesome! Did not know about GEM_HOME.

>> If gem files in the load path can be treated as a virtual file system
>> (VFS) then this should be possible, no?
>
> Somebody would need to write that code, but it would only work for
> gems without extensions to be compiled, and would not generate useful
> documentation.

Those limitations are acceptable for me, as I'm trying to use pure-Ruby
gems anyway. I'll try to write the VFS code during this holiday weekend
and submit a patch next week.

Cheers.
--
Posted via http://www.ruby-....

Eric Hodel

7/1/2008 12:16:00 AM

0

On Jun 30, 2008, at 15:37 PM, Suraj Kurapati wrote:
> Eric Hodel wrote:
>> Instead you can do:
>>
>> gem install -i ~/tmp/gems foo
>> GEM_HOME=~/tmp/gems ruby my_foo_using_program.rb
>> rm -r ~/tmp/gems
>
> Awesome! Did not know about GEM_HOME.
>
>>> If gem files in the load path can be treated as a virtual file
>>> system
>>> (VFS) then this should be possible, no?
>>
>> Somebody would need to write that code, but it would only work for
>> gems without extensions to be compiled, and would not generate useful
>> documentation.
>
> Those limitations are acceptable for me, as I'm trying to use pure-
> Ruby
> gems anyway. I'll try to write the VFS code during this holiday
> weekend
> and submit a patch next week.

Were I writing it, I would make a Kernel#require overlay that knows
how to look inside a .gem file for the things it needs. No need to
extend File.