On Feb 18, 2011, at 1:20 PM, Ian Ward Comfort wrote: > On 18 Feb 2011, at 12:29 PM, Luke Kanies wrote: >> On Feb 18, 2011, at 11:37 AM, Ian Ward Comfort wrote: >>> Heh, right. I was trying to think of a clean way to give types a way to >>> say, "autorequire the first of these dependencies that's found in the >>> catalog, and ignore the rest". Adding an autorequirefirst method would do >>> it in a backwards-compatible way, but that feels icky. >> >> It's actually pretty straightforward to do the trimming, I think - we >> currently just return the parent class, but we should instead search through >> possible parent dirs and see which ones are in the catalog. Something like: >> >> autorequire(:file) do >> dirs = File.dirname(self[:path]).split(File::SEPARATOR)[1..-1].inject([""]) >> { |list, d| list << File.join(list[-1], d); list }[1..-1].reverse >> parent = dirs.find { |dir| catalog.resource(:file, dir) } >> parent # either nil or a filename; works the same either way >> end > > Ah, hmm. Is that legit? Type.autorequire takes rel_catalog, which appears to > be the relative catalog against which autorequires are to be generated, while > this always uses the resource's catalog. But maybe rel_catalog is only > supposed to be for picking the final resources... or, actually, it never > seems to be used anyway. > > OK, I'll give this approach a shot.
Are we looking at the same code? I'm comparing to the existing autorequire in File: autorequire(:file) do basedir = File.dirname(self[:path]) if basedir != self[:path] basedir else nil end end -- Risk! Risk anything! Care no more for the opinions of others, for those voices. Do the hardest thing on earth for you. Act for yourself. Face the truth. -- Katherine Mansfield --------------------------------------------------------------------- Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to puppet-dev@googlegroups.com. To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.