Switch to .ruby extension?

Karl von Laudermann [mailto:doodpants@mailinator.com] :

Neil Stevens <neil @ hakubi.us> :

I don't understand why it matters what the file names are for
libraries. What are you going to do if/when ruby starts getting
some preprocessing like Python gets? If you're hard-coding the
full file names that'll break your scripts, won't it?

I'm talking about my own multi-file Ruby programs, not libraries.
If my main script uses require or load to access the other scripts
in the same directory, I either have to name those other scripts
with .rb, or include the extension in the require/load command.

Or am I the only one who splits my larger Ruby programs into
several files for managability? Maybe it's just a habit I've
carried over from Java.

No, I do that. But when I do that, I tend to do:

  program # no extension, but #!/usr/bin/env ruby at the top
  program.bat # wrapper to "program" for Windows users.
  lib/program/ # all of the supporting stuff for the program is
                  # in a private lib directory. 'program' uses
                  # $:.unshift ".\lib" to make this work.

-austin

ยทยทยท

--
austin ziegler * austin.ziegler@evault.com

Austin Ziegler wrote:

  program # no extension, but #!/usr/bin/env ruby at the top
  program.bat # wrapper to "program" for Windows users.
  lib/program/ # all of the supporting stuff for the program is
                  # in a private lib directory. 'program' uses
                  # $:.unshift ".\lib" to make this work.

This is also useful, in the main program file:

app_dir = File.dirname(__FILE__)
$LOAD_PATH.unshift(File.join(appdir, "lib"))

This way, it doesn't matter what the current dir is when the program is run. If it's called from a batch file or a symlink somewhere, it will still find its libs.