The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Autorequire is Basically Gone, Everyone

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Autorequire is Basically Gone, Everyone Posted: Aug 13, 2006 12:23 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Autorequire is Basically Gone, Everyone
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

I’ve had a handful of e-mail about the Hpricot gem not working. And here’s the code that’s cited:

 require 'rubygems'
 require_gem 'hpricot'

If you’re on Ruby-Talk or RubyGems-Devel, this has been circulating since late last year, but it’s still a bit of hazy folklore really. The thing is: require_gem doesn’t do what you think it does. At least, now that autorequire is deprecated.

There was a time when autorequire would let you set a script which would be loaded when require_gem gets called. In the case of Hpricots previous, you call require_gem 'hpricot' and then the gem gets loaded and its lib/hpricot.rb as well.

But these days it’s kosher to say:

 require 'rubygems'
 require_gem 'hpricot', '>=0.4'
 require 'hpricot'

So require_gem doesn’t load any scripts. It just lets us set up specifically what gem we’ll be using. If you’re just using the latest Hpricot, go:

 require 'rubygems'
 require 'hpricot'

At least, from what I’ve read, that’s the new science.

Read: Autorequire is Basically Gone, Everyone

Topic: A New Direction Previous Topic   Next Topic Topic: Security through Obscurity ? Not !

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use