Frederick Cheung wrote: > > > On 9 Sep 2008, at 14:27, Rodrigo Rosenfeld Rosas wrote: > >> >> I tried to ask this question once in Ruby-talk and inside another >> post in >> this list. No one answered me and I doubt anyone is able to answer it. >> >> So, I tried changing the subject in a weird, although correct >> question, to >> see if someone could help me. >> >> In actionpack/lib/action_view/paths.rb, there is the following >> snippet: >> >> def templates_in_path >> (Dir.glob("[EMAIL PROTECTED]/**/*/**") | Dir.glob("[EMAIL >> PROTECTED]/**")).each do | >> file| >> unless File.directory?(file) >> yield Template.new(file.split("#{self}/").last, self) >> end >> end >> end >> >> That got me intrigued. What is the difference between >> Dir.glob("[EMAIL PROTECTED]/**/*/**") | Dir.glob("[EMAIL PROTECTED]/**") >> and just > > Did you try running them ? Two minutes in the console seems to > indicate that "[EMAIL PROTECTED]/**/*/**" matches files inside those folders > as > many levels down as you want > > whereas "[EMAIL PROTECTED]/** just lists those folders in @path > > Fred
Ok, I got, they are different. But playing a bit more with glob, I found out that (or, at least, it seems to): Dir.glob("[EMAIL PROTECTED]/**") == Dir.glob("[EMAIL PROTECTED]/*") and (Dir.glob("[EMAIL PROTECTED]/**/*/**") | Dir.glob("[EMAIL PROTECTED]/**")) == (Dir.glob("[EMAIL PROTECTED]/**/*/**") | Dir.glob("[EMAIL PROTECTED]/*")) == Dir.glob("[EMAIL PROTECTED]/**/*") Except for order. To be sure, try this: (Dir.glob("[EMAIL PROTECTED]/**/*/**") | Dir.glob("[EMAIL PROTECTED]/*")).sort == Dir.glob("[EMAIL PROTECTED]/**/*")Dir.glob("[EMAIL PROTECTED]/**/*").sort So, I would change my question: Wouldn't Dir.glob("[EMAIL PROTECTED]/**/*") be a better replacement to Dir.glob("[EMAIL PROTECTED]/**/*/**") | Dir.glob("[EMAIL PROTECTED]/**") ? Rodrigo. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---