[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Gems not working

Vincent Predoehl

6/28/2007 5:30:00 PM

I do not have rails, but I like to use Ruby Gems. I installed gem
hpricot and when I run my script with 'ruby', it has trouble finding the
Hpricot library. When I run the same code in IRB, it finds the gem. I
do have require 'rubygems' before require 'hpricot'. The code fails on
line 5, where I use the hpricot library for the first time ( which seems
strange )

require 'rubygems'
require 'pricot'
require 'open-uri'
# load the RedHanded home page
doc = Hpricot(open("http://redhanded.hobix.com/index....))
# change the CSS class on links
(doc/"span.entryPermalink").set("class", "newLinks")
# remove the sidebar
(doc/"#sidebar").remove
# print the altered HTML
puts doc


This situation occurs when I run the script from teh command line:

ruby hpricot.rb

The same code runs perfectly in IRB. It would seem that IRB knows more
about gems while the ruby interpretor does not. What can I do about
this? Thanks.

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

4 Answers

Alex Young

6/28/2007 6:17:00 PM

0

Vincent Predoehl wrote:
> I do not have rails, but I like to use Ruby Gems. I installed gem
> hpricot and when I run my script with 'ruby', it has trouble finding the
> Hpricot library. When I run the same code in IRB, it finds the gem. I
> do have require 'rubygems' before require 'hpricot'. The code fails on
> line 5, where I use the hpricot library for the first time ( which seems
> strange )
>
> require 'rubygems'
> require 'pricot'
-----------^ typo?

--
Alex

Vincent Predoehl

6/28/2007 6:28:00 PM

0

Alex Young wrote:
> Vincent Predoehl wrote:
>> I do not have rails, but I like to use Ruby Gems. I installed gem
>> hpricot and when I run my script with 'ruby', it has trouble finding the
>> Hpricot library. When I run the same code in IRB, it finds the gem. I
>> do have require 'rubygems' before require 'hpricot'. The code fails on
>> line 5, where I use the hpricot library for the first time ( which seems
>> strange )
>>
>> require 'rubygems'
>> require 'pricot'
> -----------^ typo?

I saw the typo and fixed it. I regret the typo because it only added to
the confusion, but I still have the same problem.

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

Alex Young

6/28/2007 6:35:00 PM

0

Vincent Predoehl wrote:
> Alex Young wrote:
>> Vincent Predoehl wrote:
>>> I do not have rails, but I like to use Ruby Gems. I installed gem
>>> hpricot and when I run my script with 'ruby', it has trouble finding the
>>> Hpricot library. When I run the same code in IRB, it finds the gem. I
>>> do have require 'rubygems' before require 'hpricot'. The code fails on
>>> line 5, where I use the hpricot library for the first time ( which seems
>>> strange )
>>>
>>> require 'rubygems'
>>> require 'pricot'
>> -----------^ typo?
>
> I saw the typo and fixed it. I regret the typo because it only added to
> the confusion, but I still have the same problem.
>
What platform is this on? What's the exact error?

--
Alex

Ryan Davis

6/28/2007 6:38:00 PM

0


On Jun 28, 2007, at 10:30 , Vincent Predoehl wrote:

> require 'rubygems'
> require 'pricot'
> ...
>
> This situation occurs when I run the script from teh command line:
>
> ruby hpricot.rb

name the script different from the thing you are requiring... 'test-
hpricot.rb' maybe.