[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[ANN] Find

Bertram Scharpf

10/7/2007 12:41:00 PM

Hi,

the Ruby built-in Find module lacks a lot of features the
GNU find tools has. I wrote a new one (~170 lines).

<http://www.bertram-.../tmp/f...

Maybe somebody likes it.

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...

7 Answers

Daniel Berger

10/7/2007 1:32:00 PM

0



On Oct 7, 6:41 am, Bertram Scharpf <li...@bertram-scharpf.de> wrote:
> Hi,
>
> the Ruby built-in Find module lacks a lot of features the
> GNU find tools has. I wrote a new one (~170 lines).
>
> <http://www.bertram-scharpf.de/tmp/f...
>
> Maybe somebody likes it.

I wrote file-find not long ago:

http://raa.ruby-lang.org/project/...

Regards,

Dan


Tomas Pospisek

10/7/2007 9:18:00 PM

0

Terry Poulin

10/8/2007 2:12:00 AM

0

Tomas Pospisek's Mailing Lists wrote:
> On Sun, 7 Oct 2007, Daniel Berger wrote:
>
>>
>>
>> On Oct 7, 6:41 am, Bertram Scharpf <li...@bertram-scharpf.de> wrote:
>>> Hi,
>>>
>>> the Ruby built-in Find module lacks a lot of features the
>>> GNU find tools has. I wrote a new one (~170 lines).
>>>
>>> <http://www.bertram-scharpf.de/tmp/f...
>>>
>>> Maybe somebody likes it.
>>
>> I wrote file-find not long ago:
>>
>> http://raa.ruby-lang.org/project/...
>
> Time to merge stuff into Ruby proper if so many (...) people see the need
> to improve the aparently meager features of the built-in find?
> *t
>
> --
> -----------------------------------------------------------
> Tomas Pospisek
> http://sour... - Linux & Open Source Solutions
> -----------------------------------------------------------
>
>

As long as it doesn't get more bigger and fatter then GNU Find is....


Then I'd be happy :-)



--

Email and shopping with the feelgood factor!
55% of income to good causes. http://www.ip...


Daniel Berger

10/8/2007 2:16:00 AM

0



On Oct 7, 3:17 pm, Tomas Pospisek's Mailing Lists <t...@sourcepole.ch>
wrote:
> On Sun, 7 Oct 2007, Daniel Berger wrote:
>
> > On Oct 7, 6:41 am, Bertram Scharpf <li...@bertram-scharpf.de> wrote:
> >> Hi,
>
> >> the Ruby built-in Find module lacks a lot of features the
> >> GNU find tools has. I wrote a new one (~170 lines).
>
> >> <http://www.bertram-scharpf.de/tmp/f...
>
> >> Maybe somebody likes it.
>
> > I wrote file-find not long ago:
>
> >http://raa.ruby-lang.org/project/...
>
> Time to merge stuff into Ruby proper if so many (...) people see the need
> to improve the aparently meager features of the built-in find?
> *t

My experience on ruby-core tells me that the odds of getting the
radical changes we would want into the stdlib are about nil unless
there's a general outcry.

Regards,

Dan


gga

10/8/2007 11:33:00 AM

0


> >
> > >> the Ruby built-in Find module lacks a lot of features the
> > >> GNU find tools has. I wrote a new one (~170 lines).
> >
> > >> <http://www.bertram-scharpf.de/tmp/f...
> >
> > >> Maybe somebody likes it.
> >
> > > I wrote file-find not long ago:
> >
> > >http://raa.ruby-lang.org/project/...
> >

Both seem complementary. Bertram has sorting built-in and is not
backwards compatible.

After a quick look, Bertram's code also has silly inefficient things
like:
dir = (Dir.open @fullpath do |d| d.entries end) - SPECIAL_DIRS
which can just be:
dir = Dir.entries(@fullpath) - SPECIAL_DIRS
and the Etc module may be checked several times depending on what you
request.

Daniel's has searching based on different much more rich criteria and
also breaks backwards compatibility. It lacks sorting and the docs
lack simple examples. I did not check the code yet.

Bertram Scharpf

10/8/2007 11:57:00 AM

0

Hi,

Am Montag, 08. Okt 2007, 20:35:04 +0900 schrieb gga:
>
> > >
> > > >> the Ruby built-in Find module lacks a lot of features the
> > > >> GNU find tools has. I wrote a new one (~170 lines).
> > >
> > > >> <http://www.bertram-.../tmp/f...
> > >
> > > >> Maybe somebody likes it.
> > >
> > > > I wrote file-find not long ago:
> > >
> > > >http://raa.ruby-lang.org/project/...
> > >
>
> Both seem complementary. Bertram has sorting built-in and is not
> backwards compatible.
>
> After a quick look, Bertram's code also has silly inefficient things
> like:
> dir = (Dir.open @fullpath do |d| d.entries end) - SPECIAL_DIRS
> which can just be:
> dir = Dir.entries(@fullpath) - SPECIAL_DIRS

Argh!

> and the Etc module may be checked several times depending on what you
> request.

I already corrected this yesterday and upload it now.

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...

ara.t.howard

10/8/2007 2:28:00 PM

0


On Oct 7, 2007, at 6:41 AM, Bertram Scharpf wrote:

> Hi,
>
> the Ruby built-in Find module lacks a lot of features the
> GNU find tools has. I wrote a new one (~170 lines).
>
> <http://www.bertram-scharpf.de/tmp/f...
>
> Maybe somebody likes it.
>

this is one of the very smallest directories i am working with:

[cfadmin@yacht cfadmin]$ find /mnt/yacht0/data/night_files/|wc -l
69287


[cfadmin@yacht cfadmin]$ ruby a.rb
user system total real
bertram.scharpf.find 2.140000 1.230000 3.370000 ( 7.602333)
alib.util.find 1.360000 0.440000 1.800000 ( 1.812519)


[cfadmin@yacht cfadmin]$ cat a.rb
require 'benchmark'
require 'alib'
require 'bertram.scharpf.find.rb'

top = '/mnt/yacht0/data/night_files/'

Benchmark.bm do |b|
b.report('bertram.scharpf.find'){ Find.open(top){|x|} }
b.report('alib.util.find'){ alib.util.find(top){|x|} }
end


also there is alib.util.find2 which yields the stat together with the
path, preventing and extra stat on the pathname. in practice doing
something like

def method_missing m, *a, &b
stat.send m, *a, &b
end

means you have to use a ton of code since it's possible that

f.size ### no error
f.mtime ### ENOENT

btw mine

http://codeforp...lib/ruby/alib/alib-0.5.0/lib/a...
find2.rb

isn't a spectacular implementation, it is based on Motoyuki
Kasahara's 2001 lib, which used to be on the raa, called find2 - but
it's reasonably fast, does depth and breath, caches stats, and
handles files evaporation from the filesystem or not being accessible
due to permissions errors.

i think all these libraries prove that a new find mechanism needs to
be incorporated into the stdlib! we should take the best features
from all the various libs and propose a new library that is backward
compatible with the built-in find.


kind regards.

a @ http://codeforp...
--
it is not enough to be compassionate. you must act.
h.h. the 14th dalai lama