[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Dir.bitbucket?

Berger, Daniel

8/21/2006 2:33:00 PM

> -----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?

Regards,

Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.

13 Answers

Rick DeNatale

8/21/2006 5:21:00 PM

0

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.denh...

Jeff Schwab

8/21/2006 5:53:00 PM

0

Rick DeNatale wrote:
> 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!

/dev/null isn't read-only; it just looks like an empty file. It's a lot
more convenient than having to create your own empty input files. If
there's going to be a pure-ruby solution, though, can we have the
equivalent of /dev/zero, too?

Jeff Schwab

8/21/2006 5:54:00 PM

0

Jeffrey Schwab wrote:
> Rick DeNatale wrote:
>> 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!
>
> /dev/null isn't read-only; it just looks like an empty file. It's a lot

s/read/write/

> more convenient than having to create your own empty input files. If
> there's going to be a pure-ruby solution, though, can we have the
> equivalent of /dev/zero, too?

Nobuyoshi Nakada

8/22/2006 5:07:00 AM

0

Hi,

At Tue, 22 Aug 2006 02:21:05 +0900,
Rick DeNatale wrote in [ruby-talk:209686]:
> 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.

It doesn't work with child processes, which would be expected
in many cases.

I wonder if the name bitbucket is nice.

--
Nobu Nakada

Daniel Berger

8/22/2006 5:56:00 AM

0

nobu@ruby-lang.org wrote:
> Hi,
>
> At Tue, 22 Aug 2006 02:21:05 +0900,
> Rick DeNatale wrote in [ruby-talk:209686]:
>
>> 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.
>>
>
> It doesn't work with child processes, which would be expected
> in many cases.
>
> I wonder if the name bitbucket is nice.
>
>
Dir.bitbucket
Dir.devnull
Dir.null_device
Dir.null
Dir.black_hole

I guess I'm leaning towards Dir.null_device in terms of most technically
descriptive. It doesn't quite roll off the tongue as nicely as
"bitbucket", though. :)

Regards,

Dan



Ara.T.Howard

8/22/2006 6:15:00 AM

0

Scott Baldwin

8/22/2006 7:25:00 AM

0

On 8/22/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
> On Tue, 22 Aug 2006, Daniel Berger wrote:
>
> > nobu@ruby-lang.org wrote:
> >> Hi,
> >>
> >> At Tue, 22 Aug 2006 02:21:05 +0900,
> >> Rick DeNatale wrote in [ruby-talk:209686]:
> >>
> >>> 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.
> >>>
> >>
> >> It doesn't work with child processes, which would be expected
> >> in many cases.
> >>
> >> I wonder if the name bitbucket is nice.
> >>
> >>
> > Dir.bitbucket
> > Dir.devnull
> > Dir.null_device
> > Dir.null
> > Dir.black_hole
> >
> > I guess I'm leaning towards Dir.null_device in terms of most technically
> > descriptive. It doesn't quite roll off the tongue as nicely as "bitbucket",
> > though. :)
> >
> > Regards,
> >
> > Dan
>
> why 'Dir' though? why not File?
>
> -a
> --
> to foster inner awareness, introspection, and reasoning is more efficient than
> meditation and prayer.
> - h.h. the 14th dali lama
>
>

Agreed. File would be a better location for the it.

Hal E. Fulton

8/22/2006 7:38:00 AM

0

Scott Baldwin wrote:
>
> Agreed. File would be a better location for the it.
>

Or even IO perhaps?


Hal


Nobuyoshi Nakada

8/22/2006 1:57:00 PM

0

Hi,

At Tue, 22 Aug 2006 16:37:34 +0900,
Hal Fulton wrote in [ruby-talk:209823]:
> > Agreed. File would be a better location for the it.
> >
>
> Or even IO perhaps?

IO isn't always associated with a certain path.

I'd prefer File.null.

--
Nobu Nakada

John Johnson

8/22/2006 5:36:00 PM

0

On Tue, 22 Aug 2006 01:56:17 -0400, Daniel Berger <djberg96@gmail.com> =

wrote:

> nobu@ruby-lang.org wrote:
> Dir.bitbucket
> Dir.devnull
> Dir.null_device
> Dir.null
> Dir.black_hole
>
> I guess I'm leaning towards Dir.null_device in terms of most technical=
ly =

> descriptive. It doesn't quite roll off the tongue as nicely as =

> "bitbucket", though. :)

How about:

oblivion =3D File.open(nil, 'w')

Seems intuitive.

Regards,
JJ

-- =

Using Opera's revolutionary e-mail client: http://www.opera...