general query about ruby libraries

  • Thread starter Sandip Gangakhedkar
  • Start date
S

Sandip Gangakhedkar

Hi all,

I would like to know where exactly to unpack external ruby libraries for
future use. I'm using aaronp's mechanize library (zip file)...and it
uses the require 'mechanize' directive.

Thanks,
Sandip
 
7

7stud --

Sandip said:
Hi all,

I would like to know where exactly to unpack external ruby libraries for
future use. I'm using aaronp's mechanize library (zip file)...and it
uses the require 'mechanize' directive.

Thanks,
Sandip

I think the generally accepted way to install a 3rd party library is to
use RubyGems:

"RubyGems is a standardized packaging and installation framework for
libraries and applications, making it easy to locate, install, upgrade,
and uninstall Ruby packages." pickaxe2 p 215.

That's what I do. You need to install RubyGems and learn how to use it.
 
D

David Masover

Sandip Gangakhedkar wrote:
I think the generally accepted way to install a 3rd party library is to
use RubyGems:

Just to simplify: After installing rubyGems, the command you probably want is:

gem install mechanize

Or, on many Unix systems:

sudo gem install mechanize
 
S

Sandip Gangakhedkar

David said:
Just to simplify: After installing rubyGems, the command you probably
want is:

gem install mechanize

Or, on many Unix systems:

sudo gem install mechanize

What about tarballs? Or zip files?
I am aware of RubyGems. However, lots of new and recent libraries,
especially the ones hosted on github are not yet available as gems.

Thanks,
Sandip
 
S

Stefano Crocco

What about tarballs? Or zip files?
I am aware of RubyGems. However, lots of new and recent libraries,
especially the ones hosted on github are not yet available as gems.

Thanks,
Sandip

To know where ruby looks for files, you can look at the contents of the $:
global variable in ruby:

ruby -e 'puts $:'

On my (gentoo linux) system, the output is:
/usr/lib/ruby/site_ruby/1.8
/usr/lib/ruby/site_ruby/1.8/i686-linux
/usr/lib/ruby/site_ruby
/usr/lib/ruby/1.8
/usr/lib/ruby/1.8/i686-linux
 
D

David Masover

What about tarballs? Or zip files?
I am aware of RubyGems. However, lots of new and recent libraries,
especially the ones hosted on github are not yet available as gems.

If a library is new enough to not be available as a gem, I'm not sure I'd want
to install it system-wide. You can always put it somewhere in your home
directory and add it to the RUBYLIB environment variable.
 
S

Stefano Crocco

If a library is new enough to not be available as a gem, I'm not sure I'd
want to install it system-wide. You can always put it somewhere in your
home directory and add it to the RUBYLIB environment variable.

I wouldn't be so categorical. There are libraries which are quite new and
still, for various reasons, aren't packaged as gems. One which comes
immediately to my mind, because I use it, is qt-ruby, the ruby bindings for
the Qt toolkit. Other are (I think) ruby-gtk2 and ruby-gnome. Then, there's
fastri, which offers both gem and tar.gz versions whose release note states:

RubyGems adds a noticeable overhead to fri, making it run slower than if you
installed it directly from the tarball with setup.rb.

If someone is concerned about speed, he may choose to install the tar.gz
version.

So, there may be more than one reason for which a library is not released as
gems, although I wouldn't deny that in most cases your statement is correct.

Stefano
 
A

Avdi Grimm

What about tarballs? Or zip files?
I am aware of RubyGems. However, lots of new and recent libraries,
especially the ones hosted on github are not yet available as gems.

Github gems are all available via rubygems so long as the package
maintainer enables the option. See http://gems.github.com/

Do note the warning there, though. Permanently adding github as a gem
source royally b0rked my rubygems installation. Stick with the manual
source specification for now. E.g.

sudo gem install mojombo-grit -s http://gems.github.com


--
Avdi

Home: http://avdi.org
Developer Blog: http://avdi.org/devblog/
Twitter: http://twitter.com/avdi
Journal: http://avdi.livejournal.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top