Intermittant problem with Hpricot

Hi, I have already posted this question to the Ruby list, but it may be
a Rails-related problem, so I’m cross-posting.

I’ve run into a wierd problem with the Hpricot gem. I don’t know if
this is a problem with gems in general on my system, or if it’s specific
to Hpricot, so I’m posting here.

Basically I have code as follows:
require ‘rubygems’
require ‘net/http’
require ‘uri’
require_gem ‘hpricot’

class Page
def some_function(html_text)
doc = Hpricot(html_text)
doc.search("/html/body//img").each do |img|
logger.debug("== Found an image: #{img} ==")
src = img[/src="/]
logger.debug(“src = #{src}”)
end
end
end

When the function is called, sometimes I get a message saying that
function Hpricot does not exist for the object of type Page. this
continues for the entire programming session.

But sometimes, when I sit down to work on the project, the code works!
It continues working until I restart the Rails server (this is a Rails
project running on MacOSX).

Does anyone have any idea what might be causing this problem, and how to
correct it?

Alli

Of interest, if I replace the
doc = HPricot(html_text)
by
doc = Hpricot.parse(html_text)

everything works just fine, all of the time. But I still don’t
understand why Rails doesn’t find the module level function all of the
time. Anyone have any ideas?

Alli