[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Logging when files are required/loaded

mlanza

1/11/2008 2:04:00 AM

Hi all,

I am wondering if there is a quick and dirty way of displaying via
"puts" the relative path name of files as required or loaded within the
console. It would be useful for debugging. Presently I have a line at
the top of my files something like:

puts "Loading somefile.rb..."

This has been invaluable for diagnosing most errors.

Obviously, in a dynamic language this seems silly. Somehow I know the
ability to do this in a few lines of code is build straight into ruby.

Thanks much.
Mario
--
Posted via http://www.ruby-....

2 Answers

Xavier Noria

1/11/2008 2:12:00 AM

0

On Jan 11, 2008, at 3:04 AM, Mario T. Lanza wrote:

> I am wondering if there is a quick and dirty way of displaying via
> "puts" the relative path name of files as required or loaded within
> the
> console. It would be useful for debugging. Presently I have a line
> at
> the top of my files something like:
>
> puts "Loading somefile.rb..."
>
> This has been invaluable for diagnosing most errors.
>
> Obviously, in a dynamic language this seems silly. Somehow I know the
> ability to do this in a few lines of code is build straight into ruby.


Sure, it is a matter of aliasing:

$ irb
irb(main):001:0> def require_with_puts(filename) puts filename;
require_without_puts(filename); end
=> nil
irb(main):002:0> alias require_without_puts require
=> nil
irb(main):003:0> alias require require_with_puts
=> nil
irb(main):004:0> require 'rubygems'
rubygems
rubygems/rubygems_version
rubygems/defaults
thread
thread.so
rbconfig
rbconfig/datadir
rubygems/exceptions
rubygems
rubygems/version
rubygems
rubygems/requirement
rubygems/version
rubygems/requirement
rubygems/dependency
rubygems
rubygems/gem_path_searcher
rubygems
rubygems/source_index
rubygems
rubygems/user_interaction
rubygems/specification
rubygems
rubygems/version
rubygems/platform
rubygems
rubygems/platform
rubygems/builder
rubygems/custom_require
rubygems
=> true

-- fxn


mlanza

1/20/2008 2:03:00 PM

0

Thanks! I new this would be quite easy.
--
Posted via http://www.ruby-....