summaryrefslogtreecommitdiff
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-11-14 13:51:42 -0800
committerKen Barber <ken@bob.sh>2011-11-14 13:51:42 -0800
commitaa9948bfb32c4d88a04f24586224b628b5be0c8d (patch)
treec4e3c3655fc798749447935e0cf9cfe4df4a5df2 /lib/puppet/parser
parent86e86089fb41cb6fb2d6b7e358ed2afe0506fbeb (diff)
parent05c67671fd442c4fc2f20293075495bb97879855 (diff)
Merge pull request #25 from bodepd/feature/master/10802_get_module_path
(#10802) add new function get_module_path
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions/get_module_path.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/get_module_path.rb b/lib/puppet/parser/functions/get_module_path.rb
new file mode 100644
index 0000000..4d2b50b
--- /dev/null
+++ b/lib/puppet/parser/functions/get_module_path.rb
@@ -0,0 +1,17 @@
+module Puppet::Parser::Functions
+ newfunction(:get_module_path, :type =>:rvalue, :doc => <<-EOT
+ Returns the absolute path of the specified module for the current
+ environment.
+
+ Example:
+ $module_path = get_module_path('stdlib')
+ EOT
+ ) do |args|
+ raise(Puppet::ParseError, "get_module_name(): Wrong number of arguments, expects one") unless args.size == 1
+ if module_path = Puppet::Module.find(args[0], compiler.environment.to_s)
+ module_path.path
+ else
+ raise(Puppet::ParseError, "Could not find module #{args[0]} in environment #{compiler.environment}")
+ end
+ end
+end