Thanks for all of the help everyone.

I was messing about with this last night and here's what I found as my solution.

Peter's solution of a 'require' has the potential to hit the
double-load scenario in Ruby which throws an exception. This was rare
but happened occasionaly.

What I ended up with is:

newfunction(:foo....) do ...
   
Puppet::Parser::Functions.autoloader.load(File.expand_path(File.dirname(__FILE__)
+ '/../../utils/whatever.rb'))
   ...
end

It's not too pretty but it doesn't scan the entire namespace and it
appears to work as long as what you need are other puppet functions.

Unfortunately, this does not work for normal libraries and so you
would have to do a require as Peter said. If we could get native
support for a util directory in modules, that would be most helpful.

Thanks,

Trevor

On Fri, Nov 18, 2011 at 5:00 AM, Ken Barber <k...@puppetlabs.com> wrote:
> 'Trocla' itself looks really interesting Peter ...
>
> On Fri, Nov 18, 2011 at 8:03 AM, Peter Meier <peter.me...@immerda.ch> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>>> The problem that I'm having is getting the autoloader to find it.
>>>
>>> I've called it 'module Foobar' with no luck.
>>>
>>> Should I be using a require with file expansion?
>>
>> I think I used what you need in my trocla functions:
>>
>> https://github.com/duritong/puppet-trocla/blob/master/lib/puppet/parser/functions/trocla.rb#L29
>>
>> Although it's not a module I include in my function it is the
>> necessary part that loads the code and makes it available.
>>
>> ~pete
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.11 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>
>> iEYEARECAAYFAk7GEWIACgkQbwltcAfKi39wTgCfaID58BFcLbzDclYya+stIuc0
>> kvAAn2UI7K6rf5pl0uCGIvzjwf1xWKJK
>> =1TUB
>> -----END PGP SIGNATURE-----
>>
>> --
>> 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.
>>
>>
>
> --
> 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.
>
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvaug...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

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

Reply via email to