I fixed the problem by prefixing the one-line definition of basename with a return.
Should I infer Puppet doesn't support the standard Ruby mechanism of returning the last evaluated result within a function? I did have: module Puppet::Parser::Functions newfunction(:basename, :type => :rvalue) do |args| File.basename(*args) end end ..which resulted in: err: Could not retrieve catalog from remote server: Error 400 on SERVER: undefined method `basename' I now have: module Puppet::Parser::Functions newfunction(:basename, :type => :rvalue) do |args| return File.basename(*args) end end ..which works like a charm. Cheers, David On Thursday, November 29, 2012 12:04:53 PM UTC, KomodoDave wrote: > > Hmm.. actually there's still something amiss. > > Doing the include as described above changed the error from: > > Error 400 on SERVER: Unknown function utils::basename > > > to: > > Error 400 on SERVER: Function 'basename' does not return a value > > > ..which made me think it was now being found. > > I then fixed the bug by adding to basename definition the required :type > => :rvalue . > > However, instead of solving the issue I now see the message: > > Error 400 on SERVER: undefined method `basename' > > > Any suggestions would be most welcome at this point! > > Thank you. > > David > > > On Thursday, November 29, 2012 11:58:09 AM UTC, KomodoDave wrote: >> >> Ah, I've got it: simply include the module then call the function >> unqualified: >> >> include utils >> # ... >> basename(args) >> >> >> David >> >> >> On Thursday, November 29, 2012 11:37:01 AM UTC, KomodoDave wrote: >>> >>> I have a utils module that contains common utilities. Most are defined >>> types. >>> >>> However, I've just added the first custom function in >>> utils/lib/puppet/parser/functions/basename.rb . >>> >>> It seems this cannot be referenced in the intuitive fashion from another >>> module, namely: >>> >>> utils::basename(args) >>> >>> Is it possible to call a custom function from another module? If so, >>> what is the syntax? If not, is there a workaround besides copying the >>> custom function to the referencing module? >>> >>> Sincere thanks, >>> >>> David >>> >> -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/MYBHiQWXeNIJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.