Class: Puppet::Plugins
Constant Summary collapse
- Paths =
Where we might find plugin initialization code
[]
- Loaded =
Code we have found (one-to-one with paths once searched)
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.known ⇒ Object
Return all the Puppet::Plugins we know about, searching any new paths.
-
.look_in(*paths) ⇒ Object
Add more places to look for plugins without adding duplicates or changing the order of ones we’ve already found.
-
.method_missing(hook, *args, &block) ⇒ Object
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.
Instance Method Summary collapse
-
#initialize(path) ⇒ Plugins
constructor
A new instance of Plugins.
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
69 70 71 |
# File 'lib/vendor/puppet/util/plugins.rb', line 69 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
69 70 71 |
# File 'lib/vendor/puppet/util/plugins.rb', line 69 def path @path end |
Class Method Details
.known ⇒ Object
Return all the Puppet::Plugins we know about, searching any new paths
37 38 39 40 41 42 43 |
# File 'lib/vendor/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 |
.look_in(*paths) ⇒ Object
Add more places to look for plugins without adding duplicates or changing the
order of ones we've already found.
48 49 50 |
# File 'lib/vendor/puppet/util/plugins.rb', line 48 def self.look_in(*paths) Paths.replace Paths | paths.flatten.collect { |path| File.(path) } end |
.method_missing(hook, *args, &block) ⇒ Object
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.
61 62 63 64 65 |
# File 'lib/vendor/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 |