Return all the Puppet::Plugins we know about, searching any new paths
# File lib/puppet/util/plugins.rb, line 37 def self.known Paths[Loaded.length...Paths.length].each { |path| file = File.join(path,'plugin_init.rb') Loaded << (File.exist?(file) && new(file)) } Loaded.compact end
Add more places to look for plugins without adding duplicates or changing the
order of ones we've already found.
# File lib/puppet/util/plugins.rb, line 48 def self.look_in(*paths) Paths.replace Paths | paths.flatten.collect { |path| File.expand_path(path) } end
Calling methods (hooks) on the class calls the method of the same name on
all plugins that use that hook, passing in the same arguments to each and returning an array containing the results returned by each plugin as an array of [plugin_name,result] pairs.
# File lib/puppet/util/plugins.rb, line 61 def self.method_missing(hook,*args,&block) known. select { |p| p.respond_to? hook }. collect { |p| [p.name,p.send(hook,*args,&block)] } end
# File lib/puppet/util/plugins.rb, line 70 def initialize(path) @name = @path = path class << self private def define_hooks eval File.read(path),nil,path,1 end end define_hooks end