From: meredith Date: 2001-04-23T07:40:04+09:00 Subject: [ruby-talk:14047] Re: Automatic inclusion of modules In article <3ae25f14.80438284@news-server>, harryo@zipworld.com.au wrote: > I've written some cde that I'd like to be available to all of my Ruby > programs, without having to do a "Require 'xxx'" in every one. > > Is there an easy way to do this? > > Since things like Object are defined without me having to specify > anything in my source, I fugured there might be some place I could > specify other modules to be included every time the interpreter is > run. > > In case anyone's interested, what it does is allow me to do things > like ... > > fred = new Fred("hello", 1, new Time()); > > rather than > > fred = Fred.new("hello", 1, Time.new()); > > Having written C++ and Java for so long, I'm always using the former > by mistake and having to fix it. > > At the moment, I'm quite happy to live with the minor extra call > overhead ... although, I'll probably profile it one of these days and > discover that my code's spending all it's time handling my Luddite > code :-). > > TIA > Perhaps this isn't what you're looking for, but there's the -r command-line option which requires the named library before executing. Since you can put command-line options in the env variable RUBYOPT, perhaps this might do what you're looking for? -- Meredith --A lart a day keeps the spam away (Email will be read, as long as it's not spam)