On Dec 6, 11:12 pm, MonkeeSage <MonkeeS... / gmail.com> wrote: > On Dec 6, 10:54 pm, MonkeeSage <MonkeeS... / gmail.com> wrote: > > > > > On Dec 6, 9:20 pm, "ara.t.howard" <ara.t.how... / gmail.com> wrote: > > > > On Dec 6, 2007, at 7:05 PM, MonkeeSage wrote: > > > > > Ps. Your gemspec needs a dependency on main. > > > > ooooops. thanks! > > > > a @http://codeforpeople.com/ > > > -- > > > we can deny everything, except that we have the possibility of being > > > better. simply reflect on that. > > > h.h. the 14th dalai lama > > > NP. I really like this package, BTW. :) > > > A problem I just ran into is dot-files (e.g., .tesfile). It looks like > > the glob pattern (constructued on line 115) is the problem. In a > > directory with .testfile, I get this output: > > > $ ruby -w 'p Dir["./**/**"]' > > [] > > > $ ruby -e 'p Dir["./.*"]' > > ["..", ".testfile", "."] > > > But adding a dot to the double star doesn't work correctly (i.e., > > "./.**/**" get treated as "./../*", doh). I'm not sure there's any > > easy way to do it with Dir#glob. > > > Regards, > > Jordan > > Not sure what the difference in performance is with Find#fidn vs. > Dir#glob, but as a drop-in replacement... > > --- search.old 2007-12-06 23:09:34.000000000 -0600 > +++ search 2007-12-06 23:10:13.000000000 -0600 > @@ -1,6 +1,7 @@ > #! /usr/bin/env ruby > > require 'main' > +require 'find' > > Main { > description <<-txt > @@ -112,9 +113,8 @@ > end > > def each_entry_with_lines > - glob = File.join param['Directory'].value, '**', '**' > filters = build_filter_list > - Dir.glob(glob) do |entry| > + Find.find param['Directory'].value do |entry| > next unless filters.match(entry) > test ?f, entry or next > lines = IO.readlines entry rescue next > > Might I also suggest that you filter on the file's basename? One might > except... > > search -F "^\." -a . "blah" > > ...to match all dot-files in ./ which contain "blah", but you actually > need something like this since you're running the filter against the > absolute path... > > search -F ".*/*\." -a . "blah" > > Regards, > Jordan Testing on a few different directories and filter patterns, the Find#find version (w/ filters.match(File.basename(entry))) appears to be about the same a the Dir#glob version for speed (about two tenths of a second slower for a directory with 2109 files and a filter pattern of ".*"). Regards, Jordan