| Index: modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb |
| diff --git a/modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb b/modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0ab4ed898dfce318930c318221515cbbb705d3fc |
| --- /dev/null |
| +++ b/modules/adblockplus/lib/puppet/parser/functions/manifest_exists.rb |
| @@ -0,0 +1,35 @@ |
| +module Puppet::Parser::Functions |
| + |
| + newfunction(:manifest_exists, :type => :rvalue, :doc => <<-'begin') do |args| |
| + Determine if a Puppet manifest (*.pp file) exists for the given type name, |
| + within the Puppet hierarchy of the (adblockplus) module's parent directory |
| + begin |
| + |
| + if args.size != 1 |
| + message = "Usage: manifest_exists('some::definition::name')" |
| + raise Puppet::ParseError, message |
| + end |
| + |
| + # 'foo::bar::baz' => 'foo', ['bar', 'baz'] |
| + module_name, *remainder = args[0].to_s.split('::') |
| + |
| + base_directory = File.expand_path(File.join( |
| + File.dirname(__FILE__), |
| + '..', # parser |
| + '..', # puppet |
| + '..', # lib |
| + '..', # $module |
| + '..' # modules |
| + )) |
| + |
| + manifest_path = File.join( |
| + base_directory, |
| + module_name, |
| + 'manifests', |
| + File.join(*remainder) << '.pp' |
| + ) |
| + |
| + return File.exists? manifest_path |
| + |
| + end |
| +end |