[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Determining what file contains a module/class

Nicholas Wieland

5/21/2005 9:01:00 PM

Hi *,
I need to find the file that contains a known module or class, to
"inspect" the source code and extract what I need from the file.
Something like:

>> require 'digest'
>> Digest::base_file
'/usr/local/lib/ruby/1.8/digest.rb'

I already had some suggestions on IRC that involve scanning through all
the files in the path with a regexp, and in fact it solves my problem,
but I think it's a bit overcomplicated, so I'd like to know if there's
some other way that avoids all that scanning.

TIA,
ngw

--
checking for life_signs in -lKenny... no
Oh my god, make (1) killed Kenny ! You, bastards !

nicholas_wieland-at-yahoo-dot-it



3 Answers

Austin Ziegler

5/23/2005 2:39:00 PM

0

On 5/21/05, Nicholas Wieland <nicholas_wieland@yahoo.it> wrote:
> Hi *,
> I need to find the file that contains a known module or class, to
> "inspect" the source code and extract what I need from the file.
> Something like:
>
> >> require 'digest'
> >> Digest::base_file
> '/usr/local/lib/ruby/1.8/digest.rb'

The problem in this case is that digest is specifically in digest.so,
not digest.rb. It also doesn't help if a module or class is defined
across multiple files, which is certainly permitted in Ruby.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Gene Tani

5/23/2005 9:11:00 PM

0

For ruby-coded classes/modules only, Hugh Sasse's comprehensive RDOC of
every file/ class/method (builtins only, no Std. Lib):

http://www.eng.cse.dmu.ac.uk/~hgs/ruby/RUBY_SNAPSHOT_RDOC/...

(Also not sure which 1.8 snapshot this is)


Austin Ziegler wrote:
> On 5/21/05, Nicholas Wieland <nicholas_wieland@yahoo.it> wrote:
> > Hi *,
> > I need to find the file that contains a known module or class, to
> > "inspect" the source code and extract what I need from the file.
> > Something like:
> >
> > >> require 'digest'
> > >> Digest::base_file
> > '/usr/local/lib/ruby/1.8/digest.rb'
>
> The problem in this case is that digest is specifically in digest.so,
> not digest.rb. It also doesn't help if a module or class is defined
> across multiple files, which is certainly permitted in Ruby.
>
> -austin
> --
> Austin Ziegler * halostatue@gmail.com
> * Alternate: austin@halostatue.ca

Nicholas Wieland

5/24/2005 6:57:00 AM

0

- Austin Ziegler :
> On 5/21/05, Nicholas Wieland <nicholas_wieland@yahoo.it> wrote:
> > Hi *,
> > I need to find the file that contains a known module or class, to
> > "inspect" the source code and extract what I need from the file.
> > Something like:
> >
> > >> require 'digest'
> > >> Digest::base_file
> > '/usr/local/lib/ruby/1.8/digest.rb'
>
> The problem in this case is that digest is specifically in digest.so,
> not digest.rb. It also doesn't help if a module or class is defined
> across multiple files, which is certainly permitted in Ruby.

Well, I've used digest just to make an example, my question was more
general :=)
Actually I'm using something like:

SCRIPT_LINES__ = {}
require 'net/ftp'
SCRIPT_LINES__.keys

that solves two problems in one.

TIA,
ngw

--
checking for life_signs in -lKenny... no
Oh my god, make (1) killed Kenny ! You, bastards !

nicholas_wieland-at-yahoo-dot-it


___________________________________
Nuovo Yahoo! Messenger: E' molto più divertente: Audibles, Avatar, Webcam, Giochi, Rubrica? Scaricalo ora!
http://it.messenge...