Autorequire is Basically Gone, Everyone #
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.
andre
any news on gems being integrated into ruby so that the “require ‘rubygems’ line isn’t needed anymore?
FlashHater
thanks for the heads up, _why!
Danno
Would it be possible to have rubygems functionality added automagically without necessarily having it required implicitly?
Like maybe some sort of functionality where if a require fails, then and only then is rubygems loaded?
Arthur
Didn’t rubygems once overwrite the default require method? I think I remember seeing that…
dayne
Danno,
If you set your RUBYOPT environment variable to ‘rubygems’ it will do that for you so you don’t have to do the
require 'rubygems'
partMenTaLguY
RubyGems is eventually slated to become part of Ruby proper, isn’t it? Then we won’t need that explicit require anymore.
why
Well, it’s supposed to be packaged with Ruby. I don’t think there are plans to alter
require
.MenTaLguY
Hmm, that’s kind of a shame. I mean—do the Perlistas have to
use CPAN;
everywhere just to be safe?mike hogan
Might be worth changing the code here: http://balloon.hobix.com/hpricot
Thats what I was using to guide me.
Ta.
why
Oh, there we go, thanks mike hogan.
disgruntled
Will ruby ever have proper documentation? Last thing I heard was the same as Andre. Rubygems would be included with 1.8.5 (I think). Now its not? Or is it? Does anyone know? The point is you never really know without trawling the mailing lists and various blogs. In contrast, one can go to the Python website and EVERYTHING is documented. You download Python and docs abound. Wondering what is set to change in 2.5? No problem, its documented. I’m not a python lover but it is nice to know most questions are answered in the docs. Will Ruby ever get to this stage? Lets bear in mind it has been very popular for 2-3 years now. Sorry for the rant.
Solution
disguntled: http://blog.caboo.se/pages/documentation_drive
disgruntled
thats rails covered – what about ruby???
no doubt there will be a cost for this outsourced documentation.
BUY THE PDF NOW FOR ONLY $45.00!
Rails is getting a lot of bad press for its disregard for docs in favour of letting publishers charge to be able to get started. thank goodness for shareaza.
why
disgruntled: Hey, you should help us.
disgruntled
the thing is why, this must start with the ruby core developers surely? More organisation is needed from there downwards. patches and new features should be tracked. I think it needs to be taken a lot more seriously. The efforts of volunteers to trawl through source code and mailing lists is not the answer. Nor is setting up a rails charity.
We all know Ruby is a great language but lets be honest, it could be a good deal better in this regard.
At the very least an up to date tutorial is a must (not including cartoon foxes of chunky bacon)!
Thanks for listening…
...hey, where did everybody go?
Harold
But the cartoon foxes of chunky bacon have gotten us this far.
MonkeeSage
I wonder what’s wrong with RubyGems Manuals, Ruby Documentation Project, Ruby Manual, or just the
ri
command?disgruntled
MonkeeSage: with the exception of ri, none of these excellent projects come with Ruby. A new user should not be expected to download a programming language and then have to go hunting around to learn how to use it. I think folk are oblivious to how serious a problem this is. Ruby is shambolic in this respect.
Maybe Why could condense his excellent tutorial and get that bundled with Ruby. That would be a great start. After he has finished the latest chapter of course.
Come on. lets not go burying our heads in the sand. Ruby documentation stinks. The pickaxe is a great book, but buying a book should be optional with open source stuff. A way to advance your knowledge. Not the ONLY way to get started.
MonkeeSage
disgruntled: I do think that the documentation could be a bit better in some areas, and more accessible all around, and changes (or plans for the future) could be tracked somewhere obvious like ruby-lang.org; but in fairness, the API and library docs can be generated from the ruby source (run rdoc in the source directory) and there is a changelog and todo list in the root directory (also Mauricio Fernandez has been tracking API changes between 1.8.x and 1.9/HEAD here). It could be better, but it could also be alot worse also!
Gregory
disgruntled: You can only say so much before someone asks you politely to scratch your own itch. And when you just continue to rant, it seems like you’re more interested in a back scratcher than anything else.
Ruby’s english documentation is relatively new. It is a big project to document a programming language, and if it is something that bothers you so greatly, you should be asking how you can help, instead of telling us how great python is.
MonkeeSage
I think disgruntled does have a point that the docs should be more accessible to newbies (both in presentation and availability) and that a newbie shouldn’t have to go hunting through a bunch of mailing list posts in order to figure out how something works.
Of course, redhanded (and Why’s page) fill a large part of the gap in that respect, by showing you how to wear your ruby slippers to work (fear the slippers!) and so forth; but still, more is better.
But Gregory also has a point that when something is broken it doesn’t do much good to simply complain about over and over, witout offering any alternatives. “Show us your patch” is a pretty standard byword in any programing community.
As for python, when I was learning the API , I don’t remember any documentation being distrubuted with the interpreter by default. I recall many hours spent on docs.python.org and on google looking up PEPs.
Ps. Many of us with “alternative learning patterns” find the “chunky bacon” approach to be much more helpful than the dry, hum-drum approach of most tutorials and introductions to programing languages.
MenTaLguY
Yeah, maybe chunky bacon is not for everyone, but it is totally the reason I am a Ruby hacker today. It got me over the learning hump.
I’m also not convinced Python is a good role model here. I mean, they’ve been talking about having something like
CPAN.pm
or RubyGems since before RubyGems existed. A lot of requirements documents and SIGs later, they still don’t have anything, and some have retreated deep into the soft, loving arms of denial.Docmentation is good and all, but there’s also something to be said for doing.