On 8/21/06, Berger, Daniel <Daniel.Berger / qwest.com> wrote:
> > -----Original Message-----
> > From: Luke Kanies [mailto:luke / madstop.com]
> > Sent: Saturday, August 19, 2006 11:11 PM
> > To: ruby-talk ML
> > Subject: Re: Dir.bitbucket?
> >
> >
> > On Aug 19, 2006, at 11:34 PM, Daniel Berger wrote:
> >
> > > Hi all,
> > >
> > > Occasionally I have to do something like this:
> > >
> > > bitbucket = RUBY_PLATFORM.match('mswin') ? 'NUL' : '/dev/null'
> > >
> > > How about a Dir.bitbucket method? Or Dir.null, or whatever you want
> > > to call it.
> >
> > it's not quite the same thing, since it's not a part of the Ruby
> > core, but I've got a library, Facter[1], specifically meant to help
> > handle this kind of platform variety.  This kind of simple
> > code would
> > look like this:
> >
> > Facter.add :bitbucket do
> >       setcode do
> >               case Facter.operatingsystem
> >               when /mswin/i: 'NUL'
> >               when /amiga/i: 'NIL'
> >               when /openvms/i: 'NL:'
> >               else
> >                       '/dev/null'
> >               end
> >       end
> > end
>
> <snip>
>
> That's interesting, though personally I'd rather just have something in
> the core.  I mean, we have Dir.tmpdir (in the tmpdir package).  Why not
> Dir.bitbucket?

And, since we're effectively looking for a write-only file, it seems
that it would be better to make the implementation pure Ruby and
platform independent, sort of like a StringIO without a string,
instead of on platform specific blackholes like /dev/null or the
others.  Then it wouldn't need to change if and when a new platform
was to be supported.

And it would probably throw those bytes away even faster than if it
needed to talk to the OS!
-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/