| OLD | NEW |
| (Empty) |
| 1 module Puppet::Parser::Functions | |
| 2 | |
| 3 newfunction(:manifest_exists, :type => :rvalue, :doc => <<-'begin') do |args| | |
| 4 Determine if a Puppet manifest (*.pp file) exists for the given type name, | |
| 5 within the Puppet hierarchy of the (adblockplus) module's parent directory | |
| 6 begin | |
| 7 | |
| 8 if args.size != 1 | |
| 9 message = "Usage: manifest_exists('some::definition::name')" | |
| 10 raise Puppet::ParseError, message | |
| 11 end | |
| 12 | |
| 13 # 'foo::bar::baz' => 'foo', ['bar', 'baz'] | |
| 14 module_name, *remainder = args[0].to_s.split('::') | |
| 15 | |
| 16 base_directory = File.expand_path(File.join( | |
| 17 File.dirname(__FILE__), | |
| 18 '..', # parser | |
| 19 '..', # puppet | |
| 20 '..', # lib | |
| 21 '..', # $module | |
| 22 '..' # modules | |
| 23 )) | |
| 24 | |
| 25 manifest_path = File.join( | |
| 26 base_directory, | |
| 27 module_name, | |
| 28 'manifests', | |
| 29 File.join(*remainder) << '.pp' | |
| 30 ) | |
| 31 | |
| 32 return File.exists? manifest_path | |
| 33 | |
| 34 end | |
| 35 end | |
| OLD | NEW |