puppetlabs-stdlib/fact.rb
Krzysztof Wilczynski 0e3c0385ef Removing string interpolation from fact.rb. I am not sure whether
we should fiddle with this.  The old behaviour e.g. evaluate when
inside "" and don't do anything when inside '' is probably better
choice in the end as people are used to it working that way.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
2011-04-26 04:21:32 +01:00

32 lines
828 B
Ruby

#
# fact.rb
#
module Puppet::Parser::Functions
newfunction(:fact, :type => :rvalue, :doc => <<-EOS
EOS
) do |arguments|
raise(Puppet::ParseError, "fact(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
fact = arguments[0]
raise(Puppet::ParseError, 'fact(): You must provide ' +
'fact name') if fact.empty?
result = lookupvar(fact) # Get the value of interest from Facter ...
#
# Now this is a funny one ... Puppet does not have a concept of
# returning neither undef nor nil back for use within the Puppet DSL
# and empty string is as closest to actual undef as you we can get
# at this point in time ...
#
result = (result and not result.empty?) ? result : ''
return result
end
end
# vim: set ts=2 sw=2 et :