autoload ain't down with the program

T

Trans

I run into a bit of a snag. I've augmented the #require and #load
methods and noticed that #autoload doesn't pick up on it --though the
docs say #autoload uses #require. Apparently it uses it's own internal
code though, separate from any defined in the script. So there seems
to be no way to override #autoload to tie in these augmentations.

This also has an effect on Rubygems, btw. Notice:

require 'rubygems'
autoload:)RedCloth, 'redcloth')
p RedCloth

produces

no such file to load -- redcloth (LoadError)

even though the redcloth gem is in fact installed.

I suspect there's no way around this. If so, can we get that fixed in
the next release of Ruby?

Thanks,
-T.

(I know, this should probably go to ruby-core list. But I
(purposefully) do not subscribe to that list any more.)
 
A

ara.t.howard

I run into a bit of a snag. I've augmented the #require and #load
methods and noticed that #autoload doesn't pick up on it --though the
docs say #autoload uses #require. Apparently it uses it's own internal
code though, separate from any defined in the script. So there seems
to be no way to override #autoload to tie in these augmentations.

This also has an effect on Rubygems, btw. Notice:

require 'rubygems'
autoload:)RedCloth, 'redcloth')
p RedCloth

produces

no such file to load -- redcloth (LoadError)

even though the redcloth gem is in fact installed.

I suspect there's no way around this. If so, can we get that fixed in
the next release of Ruby?

Thanks,
-T.

(I know, this should probably go to ruby-core list. But I
(purposefully) do not subscribe to that list any more.)

it works for me:

cfp:~ > ruby -e' autoload "Dike", "dike.rb"; p Dike '
Dike


cfp:~ > ruby -e' require "rubygems"; autoload "Dike", "dike.rb"; p
Dike '
Dike

are you sure that autoload line works in isolation?

a @ http://codeforpeople.com/
 
A

ara.t.howard

I run into a bit of a snag. I've augmented the #require and #load
methods and noticed that #autoload doesn't pick up on it --though the
docs say #autoload uses #require. Apparently it uses it's own internal
code though, separate from any defined in the script. So there seems
to be no way to override #autoload to tie in these augmentations.

This also has an effect on Rubygems, btw. Notice:

require 'rubygems'
autoload:)RedCloth, 'redcloth')
p RedCloth

produces

no such file to load -- redcloth (LoadError)

even though the redcloth gem is in fact installed.

I suspect there's no way around this. If so, can we get that fixed in
the next release of Ruby?

Thanks,
-T.

(I know, this should probably go to ruby-core list. But I
(purposefully) do not subscribe to that list any more.)

it works for me:

cfp:~ > ruby -e' autoload "Dike", "dike.rb"; p Dike '
Dike


cfp:~ > ruby -e' require "rubygems"; autoload "Dike", "dike.rb"; p
Dike '
Dike

are you sure that autoload line works in isolation?

a @ http://codeforpeople.com/
 
T

Trans

it works for me:

cfp:~ > ruby -e' autoload "Dike", "dike.rb"; p Dike '
Dike

cfp:~ > ruby -e' require "rubygems"; autoload "Dike", "dike.rb"; p
Dike '
Dike

are you sure that autoload line works in isolation?

Isolation from? Where do you have dike.rb installed? Is it a gem?

$ ruby -e'require "rubygems"; require "redcloth.rb"; p RedCloth'
RedCloth
$ ruby -e'require "rubygems"; autoload "RedCloth", "redcloth.rb"; p
RedCloth'
-e:1: no such file to load -- redcloth.rb (LoadError)

$ ruby --version
ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]

$ gem --version
0.9.4

T.
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top